structure.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /**
  2. * Copyright (c) 2017 molio contributors, licensed under MIT, See LICENSE file for more info.
  3. *
  4. * @author David Sehnal <david.sehnal@gmail.com>
  5. */
  6. import { Vec3, Mat4 } from '../mol-base/math/linear-algebra'
  7. import AtomSet from './atom-set'
  8. import Model from './model'
  9. export type Operator =
  10. | { kind: Operator.Kind.Identity }
  11. | { kind: Operator.Kind.Symmetry, hkl: number[], index: number, name: string, transform: Mat4, inverse: Mat4 }
  12. | { kind: Operator.Kind.Assembly, assemblyName: string, index: number, transform: Mat4, inverse: Mat4 }
  13. | { kind: Operator.Kind.Custom, name: string, transform: Mat4, inverse: Mat4 }
  14. export namespace Operator {
  15. export enum Kind { Identity, Symmetry, Assembly, Custom }
  16. }
  17. export interface Unit extends Readonly<{
  18. // Structure-level unique identifier of the unit.
  19. id: number,
  20. // Each unit can only contain atoms from a single "chain"
  21. // the reason for this is to make symmetry and assembly transforms fast
  22. // without having to look at the actual contents of the unit
  23. // multiple units can point to the same chain
  24. chainIndex: number,
  25. // Provides access to the underlying data.
  26. model: Model,
  27. // Determines the operation applied to this unit.
  28. // The transform and and inverse a baked into the "getPosition" function
  29. operator: Operator
  30. }> {
  31. // returns the untransformed position. Used for spatial queries.
  32. getInvariantPosition(atom: number, slot: Vec3): Vec3
  33. // gets the transformed position of the specified atom
  34. getPosition(atom: number, slot: Vec3): Vec3
  35. }
  36. export interface Structure { units: { [id: number]: Unit }, atoms: AtomSet }
  37. export namespace Structure {
  38. export const Empty: Structure = { units: {}, atoms: AtomSet.Empty };
  39. export enum Algebra { AddUnit, RemoveUnit, UpdateConformation /* specify which units map to which */ }
  40. }
  41. // export interface Selection { structure: Structure, sets: AtomSet[] }
  42. // type SelectionImpl = Structure | Structure[]