@chemistry/crystalview 1.0.8 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/README.md +24 -20
  2. package/dist/{src/camera → camera}/Camera.d.ts +69 -63
  3. package/dist/camera/Camera.d.ts.map +1 -0
  4. package/dist/camera/Camera.js +225 -0
  5. package/dist/camera/Camera.js.map +1 -0
  6. package/dist/camera/ICamera.d.ts +9 -0
  7. package/dist/camera/ICamera.d.ts.map +1 -0
  8. package/dist/camera/ICamera.js +2 -0
  9. package/dist/camera/ICamera.js.map +1 -0
  10. package/dist/{src/crystal-view.d.ts → crystal-view.d.ts} +25 -24
  11. package/dist/crystal-view.d.ts.map +1 -0
  12. package/dist/crystal-view.js +169 -0
  13. package/dist/crystal-view.js.map +1 -0
  14. package/dist/crystalview.css +47 -0
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.d.ts.map +1 -0
  17. package/dist/index.js +2 -0
  18. package/dist/index.js.map +1 -0
  19. package/dist/{src/molecule3d → molecule3d}/Atom.d.ts +14 -13
  20. package/dist/molecule3d/Atom.d.ts.map +1 -0
  21. package/dist/molecule3d/Atom.js +15 -0
  22. package/dist/molecule3d/Atom.js.map +1 -0
  23. package/dist/{src/molecule3d → molecule3d}/Bond.d.ts +8 -7
  24. package/dist/molecule3d/Bond.d.ts.map +1 -0
  25. package/dist/molecule3d/Bond.js +8 -0
  26. package/dist/molecule3d/Bond.js.map +1 -0
  27. package/dist/{src/molecule3d → molecule3d}/CellAtom.d.ts +96 -96
  28. package/dist/molecule3d/CellAtom.d.ts.map +1 -0
  29. package/dist/molecule3d/CellAtom.js +83 -0
  30. package/dist/molecule3d/CellAtom.js.map +1 -0
  31. package/dist/{src/molecule3d → molecule3d}/Link.d.ts +15 -14
  32. package/dist/molecule3d/Link.d.ts.map +1 -0
  33. package/dist/molecule3d/Link.js +9 -0
  34. package/dist/molecule3d/Link.js.map +1 -0
  35. package/dist/{src/molecule3d → molecule3d}/Marker.d.ts +9 -8
  36. package/dist/molecule3d/Marker.d.ts.map +1 -0
  37. package/dist/molecule3d/Marker.js +8 -0
  38. package/dist/molecule3d/Marker.js.map +1 -0
  39. package/dist/{src/molecule3d → molecule3d}/MarkerContact.d.ts +7 -6
  40. package/dist/molecule3d/MarkerContact.d.ts.map +1 -0
  41. package/dist/molecule3d/MarkerContact.js +7 -0
  42. package/dist/molecule3d/MarkerContact.js.map +1 -0
  43. package/dist/{src/molecule3d → molecule3d}/Molecule3D.d.ts +45 -44
  44. package/dist/molecule3d/Molecule3D.d.ts.map +1 -0
  45. package/dist/molecule3d/Molecule3D.js +126 -0
  46. package/dist/molecule3d/Molecule3D.js.map +1 -0
  47. package/dist/{src/molecule3d → molecule3d}/MoleculeBuilder.d.ts +20 -19
  48. package/dist/molecule3d/MoleculeBuilder.d.ts.map +1 -0
  49. package/dist/molecule3d/MoleculeBuilder.js +130 -0
  50. package/dist/molecule3d/MoleculeBuilder.js.map +1 -0
  51. package/dist/molecule3d/MoleculeConnector.d.ts +10 -0
  52. package/dist/molecule3d/MoleculeConnector.d.ts.map +1 -0
  53. package/dist/molecule3d/MoleculeConnector.js +106 -0
  54. package/dist/molecule3d/MoleculeConnector.js.map +1 -0
  55. package/dist/{src/molecule3d → molecule3d}/UnitCell.d.ts +36 -35
  56. package/dist/molecule3d/UnitCell.d.ts.map +1 -0
  57. package/dist/molecule3d/UnitCell.js +227 -0
  58. package/dist/molecule3d/UnitCell.js.map +1 -0
  59. package/dist/molecule3d/io/IMoleculeReader.d.ts +8 -0
  60. package/dist/molecule3d/io/IMoleculeReader.d.ts.map +1 -0
  61. package/dist/molecule3d/io/IMoleculeReader.js +2 -0
  62. package/dist/molecule3d/io/IMoleculeReader.js.map +1 -0
  63. package/dist/{src/molecule3d → molecule3d}/io/MoleculeReaderJCIF.d.ts +12 -11
  64. package/dist/molecule3d/io/MoleculeReaderJCIF.d.ts.map +1 -0
  65. package/dist/molecule3d/io/MoleculeReaderJCIF.js +112 -0
  66. package/dist/molecule3d/io/MoleculeReaderJCIF.js.map +1 -0
  67. package/dist/{src/painter → painter}/CanvasContext.d.ts +15 -14
  68. package/dist/painter/CanvasContext.d.ts.map +1 -0
  69. package/dist/painter/CanvasContext.js +67 -0
  70. package/dist/painter/CanvasContext.js.map +1 -0
  71. package/dist/painter/Painter.d.ts +36 -0
  72. package/dist/painter/Painter.d.ts.map +1 -0
  73. package/dist/painter/Painter.js +235 -0
  74. package/dist/painter/Painter.js.map +1 -0
  75. package/dist/ui/ContextMenu.d.ts +24 -0
  76. package/dist/ui/ContextMenu.d.ts.map +1 -0
  77. package/dist/ui/ContextMenu.js +140 -0
  78. package/dist/ui/ContextMenu.js.map +1 -0
  79. package/dist/{src/ui → ui}/ContextMenuItem.d.ts +18 -17
  80. package/dist/ui/ContextMenuItem.d.ts.map +1 -0
  81. package/dist/ui/ContextMenuItem.js +66 -0
  82. package/dist/ui/ContextMenuItem.js.map +1 -0
  83. package/package.json +68 -87
  84. package/dist/crystal-view.min.js +0 -24
  85. package/dist/src/molecule3d/MoleculeConnector.d.ts +0 -9
  86. package/dist/src/painter/Painter.d.ts +0 -35
  87. package/dist/src/ui/ContextMenu.d.ts +0 -24
  88. package/package-lock.json +0 -9410
@@ -0,0 +1,9 @@
1
+ export class Link {
2
+ constructor(atom, symetry, order) {
3
+ this.atom = atom;
4
+ this.symetry = symetry;
5
+ this.order = order ?? 1;
6
+ this.fractional = symetry.project(atom.fractional);
7
+ }
8
+ }
9
+ //# sourceMappingURL=Link.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Link.js","sourceRoot":"","sources":["../../src/molecule3d/Link.ts"],"names":[],"mappings":"AAIA,MAAM,OAAO,IAAI;IAUf,YAAY,IAAc,EAAE,OAAkB,EAAE,KAAc;QAC5D,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC;QACxB,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;CACF"}
@@ -1,8 +1,9 @@
1
- import { Matrix3x4, Vec3 } from "@chemistry/math";
2
- import { CellAtom } from "./CellAtom";
3
- export declare class Marker {
4
- position: Vec3;
5
- symetry: Matrix3x4;
6
- cellAtom: CellAtom;
7
- constructor(position: Vec3, symetry: Matrix3x4, cellAtom: CellAtom);
8
- }
1
+ import { Matrix3x4, Vec3 } from '@chemistry/math';
2
+ import { CellAtom } from './CellAtom.js';
3
+ export declare class Marker {
4
+ position: Vec3;
5
+ symetry: Matrix3x4;
6
+ cellAtom: CellAtom;
7
+ constructor(position: Vec3, symetry: Matrix3x4, cellAtom: CellAtom);
8
+ }
9
+ //# sourceMappingURL=Marker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Marker.d.ts","sourceRoot":"","sources":["../../src/molecule3d/Marker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,qBAAa,MAAM;IACV,QAAQ,EAAE,IAAI,CAAC;IACf,OAAO,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,QAAQ,CAAC;gBAEd,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ;CAKnE"}
@@ -0,0 +1,8 @@
1
+ export class Marker {
2
+ constructor(position, symetry, cellAtom) {
3
+ this.position = position;
4
+ this.symetry = symetry;
5
+ this.cellAtom = cellAtom;
6
+ }
7
+ }
8
+ //# sourceMappingURL=Marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Marker.js","sourceRoot":"","sources":["../../src/molecule3d/Marker.ts"],"names":[],"mappings":"AAGA,MAAM,OAAO,MAAM;IAKjB,YAAY,QAAc,EAAE,OAAkB,EAAE,QAAkB;QAChE,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF"}
@@ -1,6 +1,7 @@
1
- import { Vec3 } from "@chemistry/math";
2
- export declare class MarkerContact {
3
- position1: Vec3;
4
- position2: Vec3;
5
- constructor(position1: Vec3, position2: Vec3);
6
- }
1
+ import { Vec3 } from '@chemistry/math';
2
+ export declare class MarkerContact {
3
+ position1: Vec3;
4
+ position2: Vec3;
5
+ constructor(position1: Vec3, position2: Vec3);
6
+ }
7
+ //# sourceMappingURL=MarkerContact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkerContact.d.ts","sourceRoot":"","sources":["../../src/molecule3d/MarkerContact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAEvC,qBAAa,aAAa;IACjB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;gBAEX,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI;CAI7C"}
@@ -0,0 +1,7 @@
1
+ export class MarkerContact {
2
+ constructor(position1, position2) {
3
+ this.position1 = position1;
4
+ this.position2 = position2;
5
+ }
6
+ }
7
+ //# sourceMappingURL=MarkerContact.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarkerContact.js","sourceRoot":"","sources":["../../src/molecule3d/MarkerContact.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,aAAa;IAIxB,YAAY,SAAe,EAAE,SAAe;QAC1C,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC7B,CAAC;CACF"}
@@ -1,44 +1,45 @@
1
- import { Vec3 } from "@chemistry/math";
2
- import { Atom } from "./Atom";
3
- import { Bond } from "./Bond";
4
- import { CellAtom } from "./CellAtom";
5
- import { Marker } from "./Marker";
6
- import { MarkerContact } from "./MarkerContact";
7
- import { UnitCell } from "./UnitCell";
8
- export declare class Molecule3D {
9
- title: string;
10
- unitCell: UnitCell;
11
- cellAtoms: CellAtom[];
12
- atoms: Atom[];
13
- bonds: Bond[];
14
- markers: Marker[];
15
- markersContacts: MarkerContact[];
16
- private reader;
17
- private builder;
18
- private connector;
19
- private initConnectivity;
20
- private center;
21
- private radius;
22
- constructor();
23
- load(input: object): void;
24
- buildConnectivity(): void;
25
- clear(): void;
26
- addCellAtom(data: {
27
- type: string;
28
- label: string;
29
- x: number;
30
- y: number;
31
- z: number;
32
- occupancy: number;
33
- uiso: number;
34
- assembly: string;
35
- group: string;
36
- }): void;
37
- addAtom(atom: Atom): void;
38
- /**
39
- * Rerutn molecule center
40
- */
41
- getCenter(): Vec3;
42
- getRadius(): number;
43
- extendByMarker(makers: Marker): void;
44
- }
1
+ import { Vec3 } from '@chemistry/math';
2
+ import { Atom } from './Atom.js';
3
+ import { Bond } from './Bond.js';
4
+ import { CellAtom } from './CellAtom.js';
5
+ import { Marker } from './Marker.js';
6
+ import { MarkerContact } from './MarkerContact.js';
7
+ import { UnitCell } from './UnitCell.js';
8
+ export declare class Molecule3D {
9
+ title: string;
10
+ unitCell: UnitCell;
11
+ cellAtoms: CellAtom[];
12
+ atoms: Atom[];
13
+ bonds: Bond[];
14
+ markers: Marker[];
15
+ markersContacts: MarkerContact[];
16
+ private reader;
17
+ private builder;
18
+ private connector;
19
+ private initConnectivity;
20
+ private center;
21
+ private radius;
22
+ constructor();
23
+ load(input: object): void;
24
+ buildConnectivity(): void;
25
+ clear(): void;
26
+ addCellAtom(data: {
27
+ type: string;
28
+ label: string;
29
+ x: number;
30
+ y: number;
31
+ z: number;
32
+ occupancy: number;
33
+ uiso: number;
34
+ assembly: string;
35
+ group: string;
36
+ }): void;
37
+ addAtom(atom: Atom): void;
38
+ /**
39
+ * Rerutn molecule center
40
+ */
41
+ getCenter(): Vec3;
42
+ getRadius(): number;
43
+ extendByMarker(makers: Marker): void;
44
+ }
45
+ //# sourceMappingURL=Molecule3D.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Molecule3D.d.ts","sourceRoot":"","sources":["../../src/molecule3d/Molecule3D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,qBAAa,UAAU;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAG,QAAQ,CAAC;IAEpB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,KAAK,EAAE,IAAI,EAAE,CAAC;IACd,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,eAAe,EAAE,aAAa,EAAE,CAAC;IAExC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,OAAO,CAAkB;IACjC,OAAO,CAAC,SAAS,CAAoB;IAErC,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,MAAM,CAAS;;IAmBhB,IAAI,CAAC,KAAK,EAAE,MAAM;IAUlB,iBAAiB;IAOjB,KAAK;IAYL,WAAW,CAAC,IAAI,EAAE;QACvB,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACf;IAuBM,OAAO,CAAC,IAAI,EAAE,IAAI;IAOzB;;OAEG;IACI,SAAS,IAAI,IAAI;IA2CjB,SAAS,IAAI,MAAM;IA4BnB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAG5C"}
@@ -0,0 +1,126 @@
1
+ import { Vec3 } from '@chemistry/math';
2
+ import { CellAtom } from './CellAtom.js';
3
+ import { MoleculeReaderJCIF } from './io/MoleculeReaderJCIF.js';
4
+ import { MoleculeBuilder } from './MoleculeBuilder.js';
5
+ import { MoleculeConnector } from './MoleculeConnector.js';
6
+ export class Molecule3D {
7
+ constructor() {
8
+ this.reader = new MoleculeReaderJCIF();
9
+ this.title = '';
10
+ this.cellAtoms = [];
11
+ this.atoms = [];
12
+ this.bonds = [];
13
+ this.markers = [];
14
+ this.markersContacts = [];
15
+ this.initConnectivity = false;
16
+ this.builder = new MoleculeBuilder(this);
17
+ this.connector = new MoleculeConnector(this);
18
+ this.center = null;
19
+ this.radius = 0;
20
+ }
21
+ load(input) {
22
+ this.reader.loadMolecule(this, input);
23
+ // Connect atoms
24
+ this.buildConnectivity();
25
+ // Add unique Atoms
26
+ this.builder.addUniqueAtoms();
27
+ }
28
+ buildConnectivity() {
29
+ if (!this.initConnectivity) {
30
+ this.connector.buildConnectivity();
31
+ this.initConnectivity = true;
32
+ }
33
+ }
34
+ clear() {
35
+ this.title = '';
36
+ this.cellAtoms = [];
37
+ this.atoms = [];
38
+ this.bonds = [];
39
+ this.markers = [];
40
+ this.markersContacts = [];
41
+ this.center = null;
42
+ this.radius = 0;
43
+ }
44
+ addCellAtom(data) {
45
+ const o = data;
46
+ o.id = this.cellAtoms.length + 1;
47
+ o.unitCell = this.unitCell;
48
+ const atom = new CellAtom(o);
49
+ this.cellAtoms.push(atom);
50
+ }
51
+ addAtom(atom) {
52
+ this.atoms.push(atom);
53
+ this.center = null;
54
+ this.radius = 0;
55
+ }
56
+ /**
57
+ * Rerutn molecule center
58
+ */
59
+ getCenter() {
60
+ if (this.center) {
61
+ return this.center;
62
+ }
63
+ if (this.atoms.length === 0) {
64
+ return new Vec3(0, 0, 0);
65
+ }
66
+ if (this.atoms.length === 1) {
67
+ return new Vec3(this.atoms[0].position.x, this.atoms[0].position.y, this.atoms[0].position.z);
68
+ }
69
+ let minX = Infinity;
70
+ let minY = Infinity;
71
+ let maxX = -Infinity;
72
+ let minZ = Infinity;
73
+ let maxY = -Infinity;
74
+ let maxZ = -Infinity;
75
+ for (let i = this.atoms.length - 1; i >= 0; i--) {
76
+ const p = this.atoms[i].position;
77
+ if (minX > p.x) {
78
+ minX = p.x;
79
+ }
80
+ if (minY > p.y) {
81
+ minY = p.y;
82
+ }
83
+ if (minZ > p.z) {
84
+ minZ = p.z;
85
+ }
86
+ if (maxX < p.x) {
87
+ maxX = p.x;
88
+ }
89
+ if (maxY < p.y) {
90
+ maxY = p.y;
91
+ }
92
+ if (maxZ < p.z) {
93
+ maxZ = p.z;
94
+ }
95
+ }
96
+ this.center = new Vec3((minX + maxX) / 2, (minY + maxY) / 2, (minZ + maxZ) / 2);
97
+ return this.center;
98
+ }
99
+ getRadius() {
100
+ if (this.radius !== 0 && this.radius !== undefined) {
101
+ return this.radius;
102
+ }
103
+ this.radius = 0;
104
+ const center = this.getCenter();
105
+ let r2 = 0; // Radius squared
106
+ if (this.atoms.length === 0 || this.atoms.length === 1) {
107
+ return 0;
108
+ }
109
+ for (let i = this.atoms.length - 1; i >= 0; i--) {
110
+ const p = this.atoms[i].position;
111
+ const dx = p.x - center.x;
112
+ const dy = p.y - center.y;
113
+ const dz = p.z - center.z;
114
+ const r1 = dx * dx + dy * dy + dz * dz;
115
+ if (r1 > r2) {
116
+ r2 = r1;
117
+ }
118
+ }
119
+ this.radius = Math.sqrt(r2);
120
+ return this.radius;
121
+ }
122
+ extendByMarker(makers) {
123
+ this.builder.extendByMarker(makers);
124
+ }
125
+ }
126
+ //# sourceMappingURL=Molecule3D.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Molecule3D.js","sourceRoot":"","sources":["../../src/molecule3d/Molecule3D.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAGhE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,MAAM,OAAO,UAAU;IAkBrB;QACE,IAAI,CAAC,MAAM,GAAG,IAAI,kBAAkB,EAAE,CAAC;QACvC,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC;QAChB,IAAI,CAAC,OAAO,GAAG,EAAE,CAAC;QAClB,IAAI,CAAC,eAAe,GAAG,EAAE,CAAC;QAE1B,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAE7C,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;IAClB,CAAC;IAEM,IAAI,CAAC,KAAa;QACvB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAEtC,gBAAgB;QAChB,IAAI,CAAC,iBAAiB,EAAE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C,QAAQ,CAAC;YACjC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC1B,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC1B,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;YAC1B,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;YACvC,IAAI,EAAE,GAAG,EAAE,EAAE,CAAC;gBACZ,EAAE,GAAG,EAAE,CAAC;YACV,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,cAAc,CAAC,MAAc;QAClC,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -1,19 +1,20 @@
1
- import { Matrix3x4 } from "@chemistry/math";
2
- import { CellAtom } from "./CellAtom";
3
- import { Marker } from "./Marker";
4
- import { Molecule3D } from "./Molecule3D";
5
- export declare class MoleculeBuilder {
6
- private molecule;
7
- constructor(molecule: Molecule3D);
8
- /**
9
- * Add Unique Atoms to Molecule
10
- */
11
- addUniqueAtoms(): void;
12
- addAtomsBySymetry(symetryList: string[]): void;
13
- addAtomWithBonds(catom: CellAtom, symetry: Matrix3x4): Array<{
14
- atom: CellAtom;
15
- symetry: Matrix3x4;
16
- }>;
17
- extendByMarker(marker: Marker): void;
18
- addMarkers(): void;
19
- }
1
+ import { Matrix3x4 } from '@chemistry/math';
2
+ import { CellAtom } from './CellAtom.js';
3
+ import { Marker } from './Marker.js';
4
+ import { Molecule3D } from './Molecule3D.js';
5
+ export declare class MoleculeBuilder {
6
+ private molecule;
7
+ constructor(molecule: Molecule3D);
8
+ /**
9
+ * Add Unique Atoms to Molecule
10
+ */
11
+ addUniqueAtoms(): void;
12
+ addAtomsBySymetry(symetryList: string[]): void;
13
+ addAtomWithBonds(catom: CellAtom, symetry: Matrix3x4): {
14
+ atom: CellAtom;
15
+ symetry: Matrix3x4;
16
+ }[];
17
+ extendByMarker(marker: Marker): void;
18
+ addMarkers(): void;
19
+ }
20
+ //# sourceMappingURL=MoleculeBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoleculeBuilder.d.ts","sourceRoot":"","sources":["../../src/molecule3d/MoleculeBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAQ,MAAM,iBAAiB,CAAC;AAGlD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAG7C,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAa;gBAEjB,QAAQ,EAAE,UAAU;IAIhC;;OAEG;IACI,cAAc;IAId,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE;IAavC,gBAAgB,CACrB,KAAK,EAAE,QAAQ,EACf,OAAO,EAAE,SAAS,GACjB;QAAE,IAAI,EAAE,QAAQ,CAAC;QAAC,OAAO,EAAE,SAAS,CAAA;KAAE,EAAE;IA+CpC,cAAc,CAAC,MAAM,EAAE,MAAM;IA+B7B,UAAU;CA8ClB"}
@@ -0,0 +1,130 @@
1
+ import { Bond } from './Bond.js';
2
+ import { Marker } from './Marker.js';
3
+ import { MarkerContact } from './MarkerContact.js';
4
+ import { UnitCell } from './UnitCell.js';
5
+ export class MoleculeBuilder {
6
+ constructor(molecule) {
7
+ this.molecule = molecule;
8
+ }
9
+ /**
10
+ * Add Unique Atoms to Molecule
11
+ */
12
+ addUniqueAtoms() {
13
+ this.addAtomsBySymetry(['x,y,z']);
14
+ }
15
+ addAtomsBySymetry(symetryList) {
16
+ for (const catom of this.molecule.cellAtoms) {
17
+ for (const symetryCode of symetryList) {
18
+ const symetry = UnitCell.getMatrixFromSymetry(symetryCode);
19
+ // Add atom with bonds
20
+ this.addAtomWithBonds(catom, symetry);
21
+ }
22
+ }
23
+ this.addMarkers();
24
+ }
25
+ addAtomWithBonds(catom, symetry) {
26
+ const markers = [];
27
+ // build atoms connectivity
28
+ this.molecule.buildConnectivity();
29
+ // Predict inserted atom position
30
+ const predictedPostion = symetry.project(catom.fractional);
31
+ const zatom = catom.getChild(predictedPostion);
32
+ let atom;
33
+ // Atom with predicted position not found
34
+ if (!zatom) {
35
+ // Create Atom and Add it as Chield
36
+ atom = catom.createAtom(symetry, true);
37
+ this.molecule.addAtom(atom);
38
+ }
39
+ else {
40
+ atom = zatom;
41
+ }
42
+ // let makers = [];
43
+ // loop throught links
44
+ const links = catom.getLinks();
45
+ for (const link of links) {
46
+ // connected atom
47
+ const conAtom = link.atom;
48
+ // connected atom predicted position
49
+ const predicted = symetry.project(link.fractional);
50
+ const xatom = conAtom.getChild(predicted);
51
+ // Atom alredy exists ..
52
+ if (xatom) {
53
+ const bond = new Bond(atom, xatom, 1);
54
+ this.molecule.bonds.push(bond);
55
+ }
56
+ else {
57
+ markers.push({
58
+ atom: conAtom,
59
+ symetry,
60
+ });
61
+ }
62
+ }
63
+ return markers;
64
+ }
65
+ extendByMarker(marker) {
66
+ const markersList = [];
67
+ markersList.push({
68
+ atom: marker.cellAtom,
69
+ symetry: marker.symetry,
70
+ });
71
+ const sym = marker.symetry;
72
+ let j = 1000;
73
+ while (markersList.length > 0 && j > 0) {
74
+ j--;
75
+ const currentMarker = markersList.shift();
76
+ if (!currentMarker) {
77
+ continue;
78
+ }
79
+ if (!currentMarker.symetry.equals(sym)) {
80
+ continue;
81
+ }
82
+ {
83
+ const markers = this.addAtomWithBonds(currentMarker.atom, currentMarker.symetry);
84
+ markersList.push(...markers);
85
+ }
86
+ }
87
+ this.addMarkers();
88
+ }
89
+ addMarkers() {
90
+ const cellAtoms = this.molecule.cellAtoms;
91
+ const unitCell = this.molecule.unitCell;
92
+ const markersPositions = [];
93
+ this.molecule.markers = [];
94
+ this.molecule.markersContacts = [];
95
+ const markers = this.molecule.markers;
96
+ const markersContacts = this.molecule.markersContacts;
97
+ const inList = (position) => {
98
+ for (const mposition of markersPositions) {
99
+ if (mposition.equals(position)) {
100
+ return true;
101
+ }
102
+ }
103
+ return false;
104
+ };
105
+ // Loop througt all cell atoms
106
+ for (const catom of cellAtoms) {
107
+ for (const atom of catom.children) {
108
+ const atomSymetry = atom.symetry;
109
+ for (const link of catom.links) {
110
+ const conAtom = link.atom;
111
+ const symetry = link.symetry;
112
+ const totalSymetry = atomSymetry.multiply(symetry);
113
+ // var predicted1 = totalSymetry.multiple(conAtom.fractional);
114
+ let predicted = symetry.project(conAtom.fractional);
115
+ predicted = atomSymetry.project(predicted);
116
+ const xatom = conAtom.getChild(predicted);
117
+ if (!xatom) {
118
+ const mPosition = unitCell.fractToOrth(predicted);
119
+ if (!inList(mPosition)) {
120
+ markersPositions.push(mPosition);
121
+ markers.push(new Marker(mPosition, totalSymetry, conAtom));
122
+ markersContacts.push(new MarkerContact(atom.position, mPosition));
123
+ }
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ //# sourceMappingURL=MoleculeBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoleculeBuilder.js","sourceRoot":"","sources":["../../src/molecule3d/MoleculeBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,MAAM,OAAO,eAAe;IAG1B,YAAY,QAAoB;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IA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AC,CAAC;oBACnD,8DAA8D;oBAC9D,IAAI,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;oBACpD,SAAS,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;oBAC3C,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;oBAE1C,IAAI,CAAC,KAAK,EAAE,CAAC;wBACX,MAAM,SAAS,GAAG,QAAQ,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;wBAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC;4BACvB,gBAAgB,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;4BACjC,OAAO,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC,CAAC;4BAC3D,eAAe,CAAC,IAAI,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAC;wBACpE,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ import { Molecule3D } from './Molecule3D.js';
2
+ export declare class MoleculeConnector {
3
+ private molecule;
4
+ constructor(molecule: Molecule3D);
5
+ buildConnectivity(): void;
6
+ private calculateCellLinks;
7
+ private isSutableByAssembly;
8
+ private isConnected;
9
+ }
10
+ //# sourceMappingURL=MoleculeConnector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoleculeConnector.d.ts","sourceRoot":"","sources":["../../src/molecule3d/MoleculeConnector.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAK7C,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAa;gBAEjB,QAAQ,EAAE,UAAU;IAIzB,iBAAiB;IAWxB,OAAO,CAAC,kBAAkB;IA4F1B,OAAO,CAAC,mBAAmB;IAa3B,OAAO,CAAC,WAAW;CAWpB"}
@@ -0,0 +1,106 @@
1
+ import { Vec3 } from '@chemistry/math';
2
+ const CW_BOND_FROM = 0.4;
3
+ const CW_BOND_TO = 1.2;
4
+ export class MoleculeConnector {
5
+ constructor(molecule) {
6
+ this.molecule = molecule;
7
+ }
8
+ buildConnectivity() {
9
+ // no atoms ?
10
+ if (this.molecule.cellAtoms.length === 0) {
11
+ return;
12
+ }
13
+ // ORDER IS IMPORTANT
14
+ // Calculate Cell Links
15
+ this.calculateCellLinks();
16
+ }
17
+ calculateCellLinks() {
18
+ const cellAtoms = this.molecule.cellAtoms;
19
+ const unitCell = this.molecule.unitCell;
20
+ let maxRCow = -Infinity;
21
+ // get atom with bigest RcoW
22
+ for (const atom of cellAtoms) {
23
+ maxRCow = Math.max(atom.element.RCow, maxRCow);
24
+ }
25
+ // Maximal posible length
26
+ const maxRCow2 = maxRCow * 2 * CW_BOND_TO;
27
+ // Detect min and Max vectors of the cell atoms
28
+ let p1 = new Vec3(Infinity, Infinity, Infinity);
29
+ let p2 = new Vec3(-Infinity, -Infinity, -Infinity);
30
+ for (const atom of cellAtoms) {
31
+ p1.x = Math.min(p1.x, atom.position.x);
32
+ p1.y = Math.min(p1.y, atom.position.y);
33
+ p1.z = Math.min(p1.z, atom.position.z);
34
+ p2.x = Math.max(p2.x, atom.position.x);
35
+ p2.y = Math.max(p2.y, atom.position.y);
36
+ p2.z = Math.max(p2.z, atom.position.z);
37
+ }
38
+ // Double RVdW and fill by atoms
39
+ const vRcow = new Vec3(2 * maxRCow, 2 * maxRCow, 2 * maxRCow);
40
+ p1 = p1.sub(vRcow);
41
+ p2 = p2.add(vRcow);
42
+ const symetryList = unitCell.symetryList;
43
+ const translations = unitCell.transactionsFromOrthBox(p1, p2);
44
+ // Loop througt all cell atoms
45
+ for (let i = 0; i < cellAtoms.length; i++) {
46
+ const catom = cellAtoms[i];
47
+ // Loop throught all Symetries
48
+ for (const symetry of symetryList) {
49
+ // fill unit cell
50
+ const pre1 = symetry.project(catom.fractional);
51
+ // The atom inside unit cell
52
+ const pre2 = Vec3.getDecimal(pre1);
53
+ // Translation from orign to get atom
54
+ const transFromOrign = Vec3.sub(pre1, pre2);
55
+ for (const tr of translations) {
56
+ const pre3 = Vec3.add(pre2, tr); // new fractional coordinates
57
+ // Orth position prediction
58
+ const pred = unitCell.fractToOrth(pre3);
59
+ const px = p1.x <= pred.x && p2.x >= pred.x;
60
+ const py = p1.y <= pred.y && p2.y >= pred.y;
61
+ const pz = p1.z <= pred.z && p2.z >= pred.z;
62
+ if (px && py && pz) {
63
+ const trans = Vec3.sub(tr, transFromOrign);
64
+ for (let m = i + 1; m < cellAtoms.length; m++) {
65
+ const catom2 = cellAtoms[m];
66
+ if (!this.isSutableByAssembly(catom, catom2)) {
67
+ continue;
68
+ }
69
+ const disV = new Vec3(Math.abs(catom2.position.x - pred.x), Math.abs(catom2.position.y - pred.y), Math.abs(catom2.position.z - pred.z));
70
+ const covBond = disV.x <= maxRCow2 && disV.y <= maxRCow2 && disV.z <= maxRCow2;
71
+ if (!covBond) {
72
+ continue;
73
+ }
74
+ if (this.isConnected(catom2, catom, pred)) {
75
+ const sym = symetry.translate(trans);
76
+ const symInverse = sym.inverse();
77
+ catom2.addLink(catom, sym);
78
+ catom.addLink(catom2, symInverse);
79
+ }
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
85
+ }
86
+ isSutableByAssembly(atom1, atom2) {
87
+ if (atom1.assembly || atom2.assembly || atom1.group || atom2.group) {
88
+ if (atom1.group && atom1.group !== '-1' && atom1.group !== '1') {
89
+ return false;
90
+ }
91
+ if (atom2.group && atom2.group !== '-1' && atom2.group !== '1') {
92
+ return false;
93
+ }
94
+ return true;
95
+ }
96
+ return true;
97
+ }
98
+ isConnected(atom1, atom2, pred) {
99
+ const disV = new Vec3(atom1.position.x - pred.x, atom1.position.y - pred.y, atom1.position.z - pred.z);
100
+ const l = disV.length;
101
+ const r = atom1.element.RCow + atom2.element.RCow;
102
+ const hasBond = l <= r * CW_BOND_TO && l >= r * CW_BOND_FROM;
103
+ return hasBond;
104
+ }
105
+ }
106
+ //# sourceMappingURL=MoleculeConnector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MoleculeConnector.js","sourceRoot":"","sources":["../../src/molecule3d/MoleculeConnector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAIvC,MAAM,YAAY,GAAG,GAAG,CAAC;AACzB,MAAM,UAAU,GAAG,GAAG,CAAC;AAEvB,MAAM,OAAO,iBAAiB;IAG5B,YAAY,QAAoB;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEM,iBAAiB;QACtB,aAAa;QACb,IAAI,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACzC,OAAO;QACT,CAAC;QAED,qBAAqB;QACrB,uBAAuB;QACvB,IAAI,CAAC,kBAAkB,EAAE,CAAC;IAC5B,CAAC;IAEO,kBAAkB;QACxB,MAAM,SAAS,GAAG,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACxC,IAAI,OAAO,GAAG,CAAC,QAAQ,CAAC;QAExB,4BAA4B;QAC5B,KAAK,MAAM,IAAI,IAAI,SAAS,EAAE,CAAC;YAC7B,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjD,CAAC;QAED,yBAAyB;QACzB,MAAM,QAAQ,GAAG,OAAO,GAAG,CAAC,GAAG,UAAU,CAAC;QAC1C,+CAA+C;QAC/C,IAAI,EAAE,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAChD,IAAI,EAA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