react-cheminfo 0.135.0 → 0.136.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 (287) hide show
  1. package/lib/crystal/core/cellAtoms.d.ts +43 -0
  2. package/lib/crystal/core/cellAtoms.d.ts.map +1 -0
  3. package/lib/crystal/core/cellAtoms.js +70 -0
  4. package/lib/crystal/core/cellAtoms.js.map +1 -0
  5. package/lib/crystal/core/index.d.ts +2 -0
  6. package/lib/crystal/core/index.d.ts.map +1 -1
  7. package/lib/crystal/core/index.js +1 -0
  8. package/lib/crystal/core/index.js.map +1 -1
  9. package/lib/crystal/core/molecules.d.ts.map +1 -1
  10. package/lib/crystal/core/molecules.js +6 -40
  11. package/lib/crystal/core/molecules.js.map +1 -1
  12. package/lib/crystal3d/core/cellClip.d.ts +46 -0
  13. package/lib/crystal3d/core/cellClip.d.ts.map +1 -0
  14. package/lib/crystal3d/core/cellClip.js +198 -0
  15. package/lib/crystal3d/core/cellClip.js.map +1 -0
  16. package/lib/crystal3d/core/cellGeometry.d.ts +63 -0
  17. package/lib/crystal3d/core/cellGeometry.d.ts.map +1 -0
  18. package/lib/crystal3d/core/cellGeometry.js +153 -0
  19. package/lib/crystal3d/core/cellGeometry.js.map +1 -0
  20. package/lib/crystal3d/core/cellStack.d.ts +51 -0
  21. package/lib/crystal3d/core/cellStack.d.ts.map +1 -0
  22. package/lib/crystal3d/core/cellStack.js +79 -0
  23. package/lib/crystal3d/core/cellStack.js.map +1 -0
  24. package/lib/crystal3d/core/crystalView.d.ts +71 -0
  25. package/lib/crystal3d/core/crystalView.d.ts.map +1 -0
  26. package/lib/crystal3d/core/crystalView.js +48 -0
  27. package/lib/crystal3d/core/crystalView.js.map +1 -0
  28. package/lib/crystal3d/core/drawingSet.d.ts +31 -0
  29. package/lib/crystal3d/core/drawingSet.d.ts.map +1 -0
  30. package/lib/crystal3d/core/drawingSet.js +63 -0
  31. package/lib/crystal3d/core/drawingSet.js.map +1 -0
  32. package/lib/crystal3d/core/elementDrawing.d.ts +50 -0
  33. package/lib/crystal3d/core/elementDrawing.d.ts.map +1 -0
  34. package/lib/crystal3d/core/elementDrawing.js +100 -0
  35. package/lib/crystal3d/core/elementDrawing.js.map +1 -0
  36. package/lib/crystal3d/core/elementExtent.d.ts +42 -0
  37. package/lib/crystal3d/core/elementExtent.d.ts.map +1 -0
  38. package/lib/crystal3d/core/elementExtent.js +56 -0
  39. package/lib/crystal3d/core/elementExtent.js.map +1 -0
  40. package/lib/crystal3d/core/elementLabels.d.ts +31 -0
  41. package/lib/crystal3d/core/elementLabels.d.ts.map +1 -0
  42. package/lib/crystal3d/core/elementLabels.js +99 -0
  43. package/lib/crystal3d/core/elementLabels.js.map +1 -0
  44. package/lib/crystal3d/core/elementShapes.d.ts +43 -0
  45. package/lib/crystal3d/core/elementShapes.d.ts.map +1 -0
  46. package/lib/crystal3d/core/elementShapes.js +115 -0
  47. package/lib/crystal3d/core/elementShapes.js.map +1 -0
  48. package/lib/crystal3d/core/frame.d.ts +36 -0
  49. package/lib/crystal3d/core/frame.d.ts.map +1 -0
  50. package/lib/crystal3d/core/frame.js +35 -0
  51. package/lib/crystal3d/core/frame.js.map +1 -0
  52. package/lib/crystal3d/core/framing.d.ts +41 -0
  53. package/lib/crystal3d/core/framing.d.ts.map +1 -0
  54. package/lib/crystal3d/core/framing.js +79 -0
  55. package/lib/crystal3d/core/framing.js.map +1 -0
  56. package/lib/crystal3d/core/index.d.ts +42 -0
  57. package/lib/crystal3d/core/index.d.ts.map +1 -0
  58. package/lib/crystal3d/core/index.js +29 -0
  59. package/lib/crystal3d/core/index.js.map +1 -0
  60. package/lib/crystal3d/core/labelText.d.ts +19 -0
  61. package/lib/crystal3d/core/labelText.d.ts.map +1 -0
  62. package/lib/crystal3d/core/labelText.js +42 -0
  63. package/lib/crystal3d/core/labelText.js.map +1 -0
  64. package/lib/crystal3d/core/latticeBasis.d.ts +49 -0
  65. package/lib/crystal3d/core/latticeBasis.d.ts.map +1 -0
  66. package/lib/crystal3d/core/latticeBasis.js +89 -0
  67. package/lib/crystal3d/core/latticeBasis.js.map +1 -0
  68. package/lib/crystal3d/core/mat3.d.ts +68 -0
  69. package/lib/crystal3d/core/mat3.d.ts.map +1 -0
  70. package/lib/crystal3d/core/mat3.js +146 -0
  71. package/lib/crystal3d/core/mat3.js.map +1 -0
  72. package/lib/crystal3d/core/operationMatrix.d.ts +44 -0
  73. package/lib/crystal3d/core/operationMatrix.d.ts.map +1 -0
  74. package/lib/crystal3d/core/operationMatrix.js +172 -0
  75. package/lib/crystal3d/core/operationMatrix.js.map +1 -0
  76. package/lib/crystal3d/core/orientation.d.ts +62 -0
  77. package/lib/crystal3d/core/orientation.d.ts.map +1 -0
  78. package/lib/crystal3d/core/orientation.js +166 -0
  79. package/lib/crystal3d/core/orientation.js.map +1 -0
  80. package/lib/crystal3d/core/palette.d.ts +24 -0
  81. package/lib/crystal3d/core/palette.d.ts.map +1 -0
  82. package/lib/crystal3d/core/palette.js +34 -0
  83. package/lib/crystal3d/core/palette.js.map +1 -0
  84. package/lib/crystal3d/core/primitives.d.ts +133 -0
  85. package/lib/crystal3d/core/primitives.d.ts.map +1 -0
  86. package/lib/crystal3d/core/primitives.js +80 -0
  87. package/lib/crystal3d/core/primitives.js.map +1 -0
  88. package/lib/crystal3d/core/structureText.d.ts +20 -0
  89. package/lib/crystal3d/core/structureText.d.ts.map +1 -0
  90. package/lib/crystal3d/core/structureText.js +37 -0
  91. package/lib/crystal3d/core/structureText.js.map +1 -0
  92. package/lib/crystal3d/core/supercell.d.ts +20 -0
  93. package/lib/crystal3d/core/supercell.d.ts.map +1 -0
  94. package/lib/crystal3d/core/supercell.js +35 -0
  95. package/lib/crystal3d/core/supercell.js.map +1 -0
  96. package/lib/crystal3d/core/types.d.ts +166 -0
  97. package/lib/crystal3d/core/types.d.ts.map +1 -0
  98. package/lib/crystal3d/core/types.js +10 -0
  99. package/lib/crystal3d/core/types.js.map +1 -0
  100. package/lib/crystal3d/core/vec3.d.ts +75 -0
  101. package/lib/crystal3d/core/vec3.d.ts.map +1 -0
  102. package/lib/crystal3d/core/vec3.js +119 -0
  103. package/lib/crystal3d/core/vec3.js.map +1 -0
  104. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts +52 -0
  105. package/lib/crystal3d/ui/CrystalCanvas3D.d.ts.map +1 -0
  106. package/lib/crystal3d/ui/CrystalCanvas3D.js +242 -0
  107. package/lib/crystal3d/ui/CrystalCanvas3D.js.map +1 -0
  108. package/lib/crystal3d/ui/CrystalStructureView.d.ts +17 -0
  109. package/lib/crystal3d/ui/CrystalStructureView.d.ts.map +1 -0
  110. package/lib/crystal3d/ui/CrystalStructureView.js +76 -0
  111. package/lib/crystal3d/ui/CrystalStructureView.js.map +1 -0
  112. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts +22 -0
  113. package/lib/crystal3d/ui/CrystalStructureViewer.d.ts.map +1 -0
  114. package/lib/crystal3d/ui/CrystalStructureViewer.js +29 -0
  115. package/lib/crystal3d/ui/CrystalStructureViewer.js.map +1 -0
  116. package/lib/crystal3d/ui/CrystalViewControls.d.ts +25 -0
  117. package/lib/crystal3d/ui/CrystalViewControls.d.ts.map +1 -0
  118. package/lib/crystal3d/ui/CrystalViewControls.js +22 -0
  119. package/lib/crystal3d/ui/CrystalViewControls.js.map +1 -0
  120. package/lib/crystal3d/ui/CrystalViewer3D.d.ts +72 -0
  121. package/lib/crystal3d/ui/CrystalViewer3D.d.ts.map +1 -0
  122. package/lib/crystal3d/ui/CrystalViewer3D.js +70 -0
  123. package/lib/crystal3d/ui/CrystalViewer3D.js.map +1 -0
  124. package/lib/crystal3d/ui/crystalScene.d.ts +91 -0
  125. package/lib/crystal3d/ui/crystalScene.d.ts.map +1 -0
  126. package/lib/crystal3d/ui/crystalScene.js +10 -0
  127. package/lib/crystal3d/ui/crystalScene.js.map +1 -0
  128. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts +52 -0
  129. package/lib/crystal3d/ui/crystalStructureViewerProps.d.ts.map +1 -0
  130. package/lib/crystal3d/ui/crystalStructureViewerProps.js +2 -0
  131. package/lib/crystal3d/ui/crystalStructureViewerProps.js.map +1 -0
  132. package/lib/crystal3d/ui/index.d.ts +16 -0
  133. package/lib/crystal3d/ui/index.d.ts.map +1 -0
  134. package/lib/crystal3d/ui/index.js +12 -0
  135. package/lib/crystal3d/ui/index.js.map +1 -0
  136. package/lib/crystal3d/ui/useCrystalCaption.d.ts +14 -0
  137. package/lib/crystal3d/ui/useCrystalCaption.d.ts.map +1 -0
  138. package/lib/crystal3d/ui/useCrystalCaption.js +32 -0
  139. package/lib/crystal3d/ui/useCrystalCaption.js.map +1 -0
  140. package/lib/crystal3d/viewer/animate.d.ts +49 -0
  141. package/lib/crystal3d/viewer/animate.d.ts.map +1 -0
  142. package/lib/crystal3d/viewer/animate.js +83 -0
  143. package/lib/crystal3d/viewer/animate.js.map +1 -0
  144. package/lib/crystal3d/viewer/camera.d.ts +44 -0
  145. package/lib/crystal3d/viewer/camera.d.ts.map +1 -0
  146. package/lib/crystal3d/viewer/camera.js +103 -0
  147. package/lib/crystal3d/viewer/camera.js.map +1 -0
  148. package/lib/crystal3d/viewer/index.d.ts +13 -0
  149. package/lib/crystal3d/viewer/index.d.ts.map +1 -0
  150. package/lib/crystal3d/viewer/index.js +8 -0
  151. package/lib/crystal3d/viewer/index.js.map +1 -0
  152. package/lib/crystal3d/viewer/layerRegistry.d.ts +24 -0
  153. package/lib/crystal3d/viewer/layerRegistry.d.ts.map +1 -0
  154. package/lib/crystal3d/viewer/layerRegistry.js +39 -0
  155. package/lib/crystal3d/viewer/layerRegistry.js.map +1 -0
  156. package/lib/crystal3d/viewer/meshPrimitives.d.ts +13 -0
  157. package/lib/crystal3d/viewer/meshPrimitives.d.ts.map +1 -0
  158. package/lib/crystal3d/viewer/meshPrimitives.js +76 -0
  159. package/lib/crystal3d/viewer/meshPrimitives.js.map +1 -0
  160. package/lib/crystal3d/viewer/plugin.d.ts +133 -0
  161. package/lib/crystal3d/viewer/plugin.d.ts.map +1 -0
  162. package/lib/crystal3d/viewer/plugin.js +181 -0
  163. package/lib/crystal3d/viewer/plugin.js.map +1 -0
  164. package/lib/crystal3d/viewer/renderCell.d.ts +43 -0
  165. package/lib/crystal3d/viewer/renderCell.d.ts.map +1 -0
  166. package/lib/crystal3d/viewer/renderCell.js +53 -0
  167. package/lib/crystal3d/viewer/renderCell.js.map +1 -0
  168. package/lib/crystal3d/viewer/renderElements.d.ts +54 -0
  169. package/lib/crystal3d/viewer/renderElements.d.ts.map +1 -0
  170. package/lib/crystal3d/viewer/renderElements.js +77 -0
  171. package/lib/crystal3d/viewer/renderElements.js.map +1 -0
  172. package/lib/crystal3d/viewer/renderStructure.d.ts +55 -0
  173. package/lib/crystal3d/viewer/renderStructure.d.ts.map +1 -0
  174. package/lib/crystal3d/viewer/renderStructure.js +103 -0
  175. package/lib/crystal3d/viewer/renderStructure.js.map +1 -0
  176. package/lib/crystal3d/viewer/sceneParts.d.ts +32 -0
  177. package/lib/crystal3d/viewer/sceneParts.d.ts.map +1 -0
  178. package/lib/crystal3d/viewer/sceneParts.js +77 -0
  179. package/lib/crystal3d/viewer/sceneParts.js.map +1 -0
  180. package/lib/crystal3d/viewer/shapeLayer.d.ts +41 -0
  181. package/lib/crystal3d/viewer/shapeLayer.d.ts.map +1 -0
  182. package/lib/crystal3d/viewer/shapeLayer.js +57 -0
  183. package/lib/crystal3d/viewer/shapeLayer.js.map +1 -0
  184. package/lib/crystal3d/viewer/textLayer.d.ts +21 -0
  185. package/lib/crystal3d/viewer/textLayer.d.ts.map +1 -0
  186. package/lib/crystal3d/viewer/textLayer.js +59 -0
  187. package/lib/crystal3d/viewer/textLayer.js.map +1 -0
  188. package/lib/crystal3d/viewer/viewer.d.ts +110 -0
  189. package/lib/crystal3d/viewer/viewer.d.ts.map +1 -0
  190. package/lib/crystal3d/viewer/viewer.js +157 -0
  191. package/lib/crystal3d/viewer/viewer.js.map +1 -0
  192. package/lib/crystal3d.d.ts +12 -0
  193. package/lib/crystal3d.d.ts.map +1 -0
  194. package/lib/crystal3d.js +12 -0
  195. package/lib/crystal3d.js.map +1 -0
  196. package/lib/i18n/core/chromeCatalog.d.ts +1 -1
  197. package/lib/i18n/core/chromeCatalog.d.ts.map +1 -1
  198. package/lib/locales/de.json +19 -1
  199. package/lib/locales/en.json +19 -1
  200. package/lib/locales/es.json +19 -1
  201. package/lib/locales/fr.json +19 -1
  202. package/lib/locales/it.json +19 -1
  203. package/lib/molecule3d/ui/MoleculeCanvas3D.d.ts.map +1 -1
  204. package/lib/molecule3d/ui/MoleculeCanvas3D.js +16 -27
  205. package/lib/molecule3d/ui/MoleculeCanvas3D.js.map +1 -1
  206. package/lib/molstar/bonds/bondRule.d.ts +16 -0
  207. package/lib/molstar/bonds/bondRule.d.ts.map +1 -0
  208. package/lib/molstar/bonds/bondRule.js +23 -0
  209. package/lib/molstar/bonds/bondRule.js.map +1 -0
  210. package/lib/molstar/bonds/index.d.ts +9 -0
  211. package/lib/molstar/bonds/index.d.ts.map +1 -0
  212. package/lib/molstar/bonds/index.js +9 -0
  213. package/lib/molstar/bonds/index.js.map +1 -0
  214. package/lib/molstar/ui/MolstarToolbar.d.ts +47 -0
  215. package/lib/molstar/ui/MolstarToolbar.d.ts.map +1 -0
  216. package/lib/molstar/ui/MolstarToolbar.js +28 -0
  217. package/lib/molstar/ui/MolstarToolbar.js.map +1 -0
  218. package/lib/molstar/ui/index.d.ts +10 -0
  219. package/lib/molstar/ui/index.d.ts.map +1 -0
  220. package/lib/molstar/ui/index.js +8 -0
  221. package/lib/molstar/ui/index.js.map +1 -0
  222. package/lib/molstar/ui/useMolstarTools.d.ts +63 -0
  223. package/lib/molstar/ui/useMolstarTools.d.ts.map +1 -0
  224. package/lib/molstar/ui/useMolstarTools.js +36 -0
  225. package/lib/molstar/ui/useMolstarTools.js.map +1 -0
  226. package/package.json +2 -1
  227. package/src/crystal/core/cellAtoms.ts +106 -0
  228. package/src/crystal/core/index.ts +2 -0
  229. package/src/crystal/core/molecules.ts +7 -44
  230. package/src/crystal3d/core/cellClip.ts +229 -0
  231. package/src/crystal3d/core/cellGeometry.ts +193 -0
  232. package/src/crystal3d/core/cellStack.ts +87 -0
  233. package/src/crystal3d/core/crystalView.ts +114 -0
  234. package/src/crystal3d/core/drawingSet.ts +71 -0
  235. package/src/crystal3d/core/elementDrawing.ts +147 -0
  236. package/src/crystal3d/core/elementExtent.ts +81 -0
  237. package/src/crystal3d/core/elementLabels.ts +130 -0
  238. package/src/crystal3d/core/elementShapes.ts +141 -0
  239. package/src/crystal3d/core/frame.ts +56 -0
  240. package/src/crystal3d/core/framing.ts +101 -0
  241. package/src/crystal3d/core/index.ts +132 -0
  242. package/src/crystal3d/core/labelText.ts +44 -0
  243. package/src/crystal3d/core/latticeBasis.ts +110 -0
  244. package/src/crystal3d/core/mat3.ts +163 -0
  245. package/src/crystal3d/core/operationMatrix.ts +255 -0
  246. package/src/crystal3d/core/orientation.ts +229 -0
  247. package/src/crystal3d/core/palette.ts +43 -0
  248. package/src/crystal3d/core/primitives.ts +183 -0
  249. package/src/crystal3d/core/structureText.ts +43 -0
  250. package/src/crystal3d/core/supercell.ts +40 -0
  251. package/src/crystal3d/core/types.ts +186 -0
  252. package/src/crystal3d/core/vec3.ts +127 -0
  253. package/src/crystal3d/ui/CrystalCanvas3D.tsx +384 -0
  254. package/src/crystal3d/ui/CrystalStructureView.tsx +148 -0
  255. package/src/crystal3d/ui/CrystalStructureViewer.tsx +39 -0
  256. package/src/crystal3d/ui/CrystalViewControls.tsx +100 -0
  257. package/src/crystal3d/ui/CrystalViewer3D.tsx +183 -0
  258. package/src/crystal3d/ui/crystalScene.ts +100 -0
  259. package/src/crystal3d/ui/crystalStructureViewerProps.ts +54 -0
  260. package/src/crystal3d/ui/index.ts +20 -0
  261. package/src/crystal3d/ui/useCrystalCaption.ts +38 -0
  262. package/src/crystal3d/viewer/animate.ts +113 -0
  263. package/src/crystal3d/viewer/camera.ts +139 -0
  264. package/src/crystal3d/viewer/index.ts +13 -0
  265. package/src/crystal3d/viewer/layerRegistry.ts +47 -0
  266. package/src/crystal3d/viewer/meshPrimitives.ts +102 -0
  267. package/src/crystal3d/viewer/plugin.ts +258 -0
  268. package/src/crystal3d/viewer/renderCell.ts +98 -0
  269. package/src/crystal3d/viewer/renderElements.ts +121 -0
  270. package/src/crystal3d/viewer/renderStructure.ts +144 -0
  271. package/src/crystal3d/viewer/sceneParts.ts +119 -0
  272. package/src/crystal3d/viewer/shapeLayer.ts +108 -0
  273. package/src/crystal3d/viewer/textLayer.ts +85 -0
  274. package/src/crystal3d/viewer/viewer.ts +207 -0
  275. package/src/crystal3d.ts +12 -0
  276. package/src/locales/de.json +19 -1
  277. package/src/locales/en.json +19 -1
  278. package/src/locales/es.json +19 -1
  279. package/src/locales/fr.json +19 -1
  280. package/src/locales/it.json +19 -1
  281. package/src/molecule3d/ui/MoleculeCanvas3D.tsx +45 -71
  282. package/src/molstar/bonds/bondRule.ts +34 -0
  283. package/src/molstar/bonds/index.ts +9 -0
  284. package/src/molstar/ui/MolstarToolbar.tsx +103 -0
  285. package/src/molstar/ui/index.ts +14 -0
  286. package/src/molstar/ui/useMolstarTools.ts +98 -0
  287. package/styles/chrome.css +90 -0
@@ -0,0 +1,43 @@
1
+ import type { CrystalStructure } from './cif/types.ts';
2
+ import type { ExpandedAtom } from './expand.ts';
3
+ import type { Lattice } from './symmetry/lattice.ts';
4
+ import type { CrystalOperation } from './symmetry/types.ts';
5
+ /** Options of {@link crystalCellAtoms}. */
6
+ export interface CellAtomsOptions {
7
+ /**
8
+ * The most atoms one cell is expanded into; past it, none is returned.
9
+ * @default 100000
10
+ */
11
+ maxAtoms?: number;
12
+ }
13
+ /** What one cell of a crystal holds. */
14
+ export interface CellAtoms {
15
+ /** The cell. */
16
+ readonly lattice: Lattice;
17
+ /** The space group's operations, as the file states or implies them. */
18
+ readonly operations: ReadonlyArray<CrystalOperation<3>>;
19
+ /**
20
+ * Every atom of the cell, fractional and wrapped into [0, 1): each site that
21
+ * is not a dummy, expanded, with the major part of each disorder kept. Empty
22
+ * when the cell holds more than `maxAtoms`.
23
+ */
24
+ readonly atoms: readonly ExpandedAtom[];
25
+ /** How many atoms the expansion made, disorder included, counted past the cap. */
26
+ readonly count: number;
27
+ /** Whether the cell holds more than `maxAtoms`. */
28
+ readonly tooLarge: boolean;
29
+ }
30
+ /**
31
+ * The atoms one cell of a crystal holds, which is what a page draws or bonds.
32
+ *
33
+ * Every site that is not a dummy is expanded by the space group, and the
34
+ * disorder is resolved as `chooseDisorder` does: the atoms in no disorder group,
35
+ * and the major part of each.
36
+ * @param structure - What `readCif` returned.
37
+ * @param options - See {@link CellAtomsOptions}.
38
+ * @returns The cell's atoms, its lattice and its operations.
39
+ * @throws {Error} When the file names no space group and lists no operation, or
40
+ * its cell has angles no cell can have.
41
+ */
42
+ export declare function crystalCellAtoms(structure: CrystalStructure, options?: CellAtomsOptions): CellAtoms;
43
+ //# sourceMappingURL=cellAtoms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellAtoms.d.ts","sourceRoot":"","sources":["../../../src/crystal/core/cellAtoms.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE5D,2CAA2C;AAC3C,MAAM,WAAW,gBAAgB;IAC/B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wCAAwC;AACxC,MAAM,WAAW,SAAS;IACxB,gBAAgB;IAChB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IACxD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,kFAAkF;IAClF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,GAAE,gBAAqB,GAC7B,SAAS,CA2BX"}
@@ -0,0 +1,70 @@
1
+ import { chooseDisorder, isDummy } from "./disorder.js";
2
+ import { expandSite } from "./expand.js";
3
+ import { structureOperations } from "./operations.js";
4
+ import { createLattice } from "./symmetry/lattice.js";
5
+ /**
6
+ * The atoms one cell of a crystal holds, which is what a page draws or bonds.
7
+ *
8
+ * Every site that is not a dummy is expanded by the space group, and the
9
+ * disorder is resolved as `chooseDisorder` does: the atoms in no disorder group,
10
+ * and the major part of each.
11
+ * @param structure - What `readCif` returned.
12
+ * @param options - See {@link CellAtomsOptions}.
13
+ * @returns The cell's atoms, its lattice and its operations.
14
+ * @throws {Error} When the file names no space group and lists no operation, or
15
+ * its cell has angles no cell can have.
16
+ */
17
+ export function crystalCellAtoms(structure, options = {}) {
18
+ const { maxAtoms = 100_000 } = options;
19
+ const operations = structureOperations(structure);
20
+ const lattice = createLattice(structure.cell);
21
+ const { sites } = structure;
22
+ const expanded = expandSites(sites, operations, maxAtoms);
23
+ if (expanded.count > maxAtoms) {
24
+ return {
25
+ lattice,
26
+ operations,
27
+ atoms: [],
28
+ count: expanded.count,
29
+ tooLarge: true,
30
+ };
31
+ }
32
+ const kept = chooseDisorder(sites, expanded.atoms, lattice);
33
+ const atoms = [];
34
+ for (const atom of expanded.atoms) {
35
+ if (kept[atom.siteIndex] === 1)
36
+ atoms.push(atom);
37
+ }
38
+ return {
39
+ lattice,
40
+ operations,
41
+ atoms,
42
+ count: expanded.count,
43
+ tooLarge: false,
44
+ };
45
+ }
46
+ /**
47
+ * Every atom of the cell the sites that are not dummies make, counted past the cap.
48
+ * @param sites - The asymmetric unit.
49
+ * @param operations - The full coset list.
50
+ * @param maxAtoms - The most atoms kept.
51
+ * @returns The atoms, and how many the cell holds.
52
+ */
53
+ function expandSites(sites, operations, maxAtoms) {
54
+ const atoms = [];
55
+ let count = 0;
56
+ for (let index = 0; index < sites.length; index++) {
57
+ const site = sites[index];
58
+ if (isDummy(site))
59
+ continue;
60
+ const images = expandSite(site, index, operations);
61
+ count += images.length;
62
+ if (count > maxAtoms)
63
+ continue;
64
+ for (let image = 0; image < images.length; image++) {
65
+ atoms.push(images[image]);
66
+ }
67
+ }
68
+ return { atoms, count };
69
+ }
70
+ //# sourceMappingURL=cellAtoms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellAtoms.js","sourceRoot":"","sources":["../../../src/crystal/core/cellAtoms.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AA8BtD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAC9B,SAA2B,EAC3B,UAA4B,EAAE;IAE9B,MAAM,EAAE,QAAQ,GAAG,OAAO,EAAE,GAAG,OAAO,CAAC;IACvC,MAAM,UAAU,GAAG,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,EAAE,KAAK,EAAE,GAAG,SAAS,CAAC;IAC5B,MAAM,QAAQ,GAAG,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;IAC1D,IAA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,EAAE,EAAE,CAAC;YACnD,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAiB,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAC1B,CAAC"}
@@ -1,3 +1,5 @@
1
+ export type { CellAtoms, CellAtomsOptions } from './cellAtoms.ts';
2
+ export { crystalCellAtoms } from './cellAtoms.ts';
1
3
  export * from './cif/index.ts';
2
4
  export type { BondGraph, PeriodicComponent } from './components.ts';
3
5
  export { BOND_TOLERANCE, covalentBondLimit, covalentRadius, } from './covalentRadii.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/crystal/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,YAAY,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpE,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,OAAO,EACP,SAAS,GACV,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC1D,YAAY,EACV,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,gBAAgB,EAChB,uBAAuB,EACvB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/D,YA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AAM,cAAc,CAAC;AAC/D,YAAY,EACV,SAAS,EACT,UAAU,EACV,mBAAmB,EACnB,aAAa,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -1,3 +1,4 @@
1
+ export { crystalCellAtoms } from "./cellAtoms.js";
1
2
  export * from "./cif/index.js";
2
3
  export { BOND_TOLERANCE, covalentBondLimit, covalentRadius, } from "./covalentRadii.js";
3
4
  export { ASSEMBLY_OVERLAP, DISORDER_OVERLAP, chooseDisorder, disorderGroupOf, isDummy, keptSites, } from "./disorder.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crystal/core/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,OAAO,EACP,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAS1D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/crystal/core/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,cAAc,gBAAgB,CAAC;AAE/B,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,OAAO,EACP,SAAS,GACV,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAS1D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAO/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AACtB,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"molecules.d.ts","sourceRoot":"","sources":["../../../src/crystal/core/molecules.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAe,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAQpE,OAAO,KAAK,EAEV,gBAAgB,EAChB,uBAAuB,EAExB,MAAM,oBAAoB,CAAC;AAY5B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CA+DlB"}
1
+ {"version":3,"file":"molecules.d.ts","sourceRoot":"","sources":["../../../src/crystal/core/molecules.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAKvD,OAAO,KAAK,EAEV,gBAAgB,EAChB,uBAAuB,EAExB,MAAM,oBAAoB,CAAC;AAU5B;;;GAGG;AACH,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,gBAAgB,CAC9B,SAAS,EAAE,gBAAgB,EAC3B,OAAO,GAAE,uBAA4B,GACpC,gBAAgB,CAyDlB"}
@@ -1,12 +1,9 @@
1
+ import { crystalCellAtoms } from "./cellAtoms.js";
1
2
  import { keptPairs, writtenTwice } from "./cellBonds.js";
2
3
  import { bondGraph, walkComponents } from "./components.js";
3
4
  import { covalentBondLimit } from "./covalentRadii.js";
4
- import { chooseDisorder, isDummy } from "./disorder.js";
5
- import { expandSite } from "./expand.js";
6
5
  import { buildMolecule } from "./moleculeOf.js";
7
- import { structureOperations } from "./operations.js";
8
6
  import { findPeriodicBonds } from "./periodicBonds.js";
9
- import { createLattice } from "./symmetry/lattice.js";
10
7
  import { isIdentity } from "./symmetry/operation.js";
11
8
  import { representative, siteIndicesOf, symmetryClasses, } from "./symmetryClasses.js";
12
9
  /**
@@ -46,24 +43,17 @@ export const SAME_ATOM_DISTANCE = 0.5;
46
43
  */
47
44
  export function crystalMolecules(structure, options = {}) {
48
45
  const { bondLimit = covalentBondLimit, maxAtoms = 100_000 } = options;
49
- const operations = structureOperations(structure);
50
- const lattice = createLattice(structure.cell);
51
- const { sites } = structure;
52
- const expanded = expandSites(sites, operations, maxAtoms);
53
- if (expanded.count > maxAtoms) {
46
+ const cell = crystalCellAtoms(structure, { maxAtoms });
47
+ if (cell.tooLarge) {
54
48
  return {
55
49
  molecules: [],
56
50
  networks: [],
57
- cellAtoms: expanded.count,
51
+ cellAtoms: cell.count,
58
52
  tooLarge: true,
59
53
  };
60
54
  }
61
- const kept = chooseDisorder(sites, expanded.atoms, lattice);
62
- const atoms = [];
63
- for (const atom of expanded.atoms) {
64
- if (kept[atom.siteIndex] === 1)
65
- atoms.push(atom);
66
- }
55
+ const { lattice, operations, atoms } = cell;
56
+ const { sites } = structure;
67
57
  const pairs = findPeriodicBonds(atoms, lattice, bondLimit, {
68
58
  samePlace: SAME_ATOM_DISTANCE,
69
59
  });
@@ -106,30 +96,6 @@ export function crystalMolecules(structure, options = {}) {
106
96
  }
107
97
  return { molecules, networks, cellAtoms, tooLarge: false };
108
98
  }
109
- /**
110
- * Every atom of the cell the sites that are not dummies make, counted past the cap.
111
- * @param sites - The asymmetric unit.
112
- * @param operations - The full coset list.
113
- * @param maxAtoms - The most atoms kept.
114
- * @returns The atoms, and how many the cell holds.
115
- */
116
- function expandSites(sites, operations, maxAtoms) {
117
- const atoms = [];
118
- let count = 0;
119
- for (let index = 0; index < sites.length; index++) {
120
- const site = sites[index];
121
- if (isDummy(site))
122
- continue;
123
- const images = expandSite(site, index, operations);
124
- count += images.length;
125
- if (count > maxAtoms)
126
- continue;
127
- for (let image = 0; image < images.length; image++) {
128
- atoms.push(images[image]);
129
- }
130
- }
131
- return { atoms, count };
132
- }
133
99
  function identityIndexOf(operations) {
134
100
  for (let index = 0; index < operations.length; index++) {
135
101
  if (isIdentity(operations[index]))
@@ -1 +1 @@
1
- {"version":3,"file":"molecules.js","sourceRoot":"","sources":["../../../src/crystal/core/molecules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExD,OAAO,EAAE,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,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACvD,IAAI,UAAU,CAAC,UAAU,CAAC,KAAK,CAAwB,CAAC;YAAE,OAAO,KAAK,CAAC;IACzE,CAAC;IACD,OAAO,CAAC,CAAC,CAAC;AACZ,CAAC"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Where an element meets the cell it belongs to.
3
+ *
4
+ * A symmetry element is unbounded — an axis is a whole line, a plane a whole
5
+ * plane — so drawing one means choosing how much of it to show. A rod of some
6
+ * arbitrary length centred on whatever point the decomposition happened to
7
+ * report reads as a floating stick; the same axis cut off where it enters and
8
+ * leaves the box reads as a diagonal of the cell, which is what it is.
9
+ *
10
+ * Everything here works in fractional coordinates, where the cell is the unit
11
+ * cube however oblique it is in ångström, and hands the answer back in
12
+ * Cartesian ångström.
13
+ */
14
+ import type { Lattice } from '../../crystal/core/symmetry/lattice.ts';
15
+ import type { Point3 } from './types.ts';
16
+ /** The piece of a line that lies inside the cell. */
17
+ export interface CellSegment {
18
+ readonly start: Point3;
19
+ readonly end: Point3;
20
+ }
21
+ /**
22
+ * Where a line enters and leaves the cell.
23
+ * @param lattice - The cell it is cut against.
24
+ * @param point - A point of the line, Cartesian ångström.
25
+ * @param direction - Its direction, Cartesian; need not be normalised.
26
+ * @param cells - How many cells the box spans along each axis.
27
+ * @default 1
28
+ * @returns The two ends, or `null` when the line misses the box, and when the
29
+ * direction is too short to say which way the line runs.
30
+ */
31
+ export declare function clipLineToCell(lattice: Lattice, point: Point3, direction: Point3, cells?: number): CellSegment | null;
32
+ /**
33
+ * The polygon a plane cuts out of the cell.
34
+ *
35
+ * The corners come back in order around the plane, so a triangle fan over them
36
+ * is the face itself and a rod between each neighbouring pair is its rim.
37
+ * @param lattice - The cell it is cut against.
38
+ * @param point - A point of the plane, Cartesian ångström.
39
+ * @param normal - Its normal, Cartesian; need not be normalised.
40
+ * @param cells - How many cells the box spans along each axis.
41
+ * @default 1
42
+ * @returns The corners, Cartesian ångström, or an empty list when the plane
43
+ * misses the box or only touches an edge or a corner of it.
44
+ */
45
+ export declare function cellSection(lattice: Lattice, point: Point3, normal: Point3, cells?: number): Point3[];
46
+ //# sourceMappingURL=cellClip.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellClip.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/cellClip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wCAAwC,CAAC;AAQtE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AASzC,qDAAqD;AACrD,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,KAAK,SAAI,GACR,WAAW,GAAG,IAAI,CAyBpB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,WAAW,CACzB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,MAAM,EACd,KAAK,SAAI,GACR,MAAM,EAAE,CAiCV"}
@@ -0,0 +1,198 @@
1
+ /**
2
+ * Where an element meets the cell it belongs to.
3
+ *
4
+ * A symmetry element is unbounded — an axis is a whole line, a plane a whole
5
+ * plane — so drawing one means choosing how much of it to show. A rod of some
6
+ * arbitrary length centred on whatever point the decomposition happened to
7
+ * report reads as a floating stick; the same axis cut off where it enters and
8
+ * leaves the box reads as a diagonal of the cell, which is what it is.
9
+ *
10
+ * Everything here works in fractional coordinates, where the cell is the unit
11
+ * cube however oblique it is in ångström, and hands the answer back in
12
+ * Cartesian ångström.
13
+ */
14
+ import { planeFrame } from "./frame.js";
15
+ import { normalToFractional, toCartesian, toFractional, } from "./latticeBasis.js";
16
+ import { addVectors, dotProduct, scaleVector, subtractVectors, } from "./vec3.js";
17
+ /**
18
+ * Where a line enters and leaves the cell.
19
+ * @param lattice - The cell it is cut against.
20
+ * @param point - A point of the line, Cartesian ångström.
21
+ * @param direction - Its direction, Cartesian; need not be normalised.
22
+ * @param cells - How many cells the box spans along each axis.
23
+ * @default 1
24
+ * @returns The two ends, or `null` when the line misses the box, and when the
25
+ * direction is too short to say which way the line runs.
26
+ */
27
+ export function clipLineToCell(lattice, point, direction, cells = 1) {
28
+ const origin = toFractional(lattice, point);
29
+ const along = toFractional(lattice, direction);
30
+ let enter = Number.NEGATIVE_INFINITY;
31
+ let leave = Number.POSITIVE_INFINITY;
32
+ for (let axis = 0; axis < 3; axis++) {
33
+ const speed = along[axis] ?? 0;
34
+ const start = origin[axis] ?? 0;
35
+ if (Math.abs(speed) < PARALLEL) {
36
+ if (start < -SLACK || start > cells + SLACK)
37
+ return null;
38
+ continue;
39
+ }
40
+ const first = (0 - start) / speed;
41
+ const second = (cells - start) / speed;
42
+ enter = Math.max(enter, Math.min(first, second));
43
+ leave = Math.min(leave, Math.max(first, second));
44
+ }
45
+ // Every axis was parallel, so there is no line to cut: the ends would come
46
+ // back as `0 · ∞`, which is `NaN` in every coordinate and poisons the scene.
47
+ if (!Number.isFinite(enter) || !Number.isFinite(leave))
48
+ return null;
49
+ if (!(leave > enter))
50
+ return null;
51
+ return {
52
+ start: toCartesian(lattice, stepAlong(origin, along, enter)),
53
+ end: toCartesian(lattice, stepAlong(origin, along, leave)),
54
+ };
55
+ }
56
+ /**
57
+ * The polygon a plane cuts out of the cell.
58
+ *
59
+ * The corners come back in order around the plane, so a triangle fan over them
60
+ * is the face itself and a rod between each neighbouring pair is its rim.
61
+ * @param lattice - The cell it is cut against.
62
+ * @param point - A point of the plane, Cartesian ångström.
63
+ * @param normal - Its normal, Cartesian; need not be normalised.
64
+ * @param cells - How many cells the box spans along each axis.
65
+ * @default 1
66
+ * @returns The corners, Cartesian ångström, or an empty list when the plane
67
+ * misses the box or only touches an edge or a corner of it.
68
+ */
69
+ export function cellSection(lattice, point, normal, cells = 1) {
70
+ const origin = toFractional(lattice, point);
71
+ // A Cartesian normal n reads in fractional coordinates as Mᵀn, which is what
72
+ // keeps the plane in place in a cell that is not orthogonal.
73
+ const along = normalToFractional(lattice, normal);
74
+ const corners = cubeCorners(cells);
75
+ const heights = [];
76
+ for (const corner of corners) {
77
+ heights.push(dotProduct(along, subtractVectors(corner, origin)));
78
+ }
79
+ const hits = [];
80
+ for (let index = 0; index < corners.length; index++) {
81
+ const corner = corners[index];
82
+ if (corner !== undefined && Math.abs(heights[index] ?? 0) < FLAT) {
83
+ hits.push(corner);
84
+ }
85
+ }
86
+ for (const [from, to] of CUBE_EDGES) {
87
+ const low = heights[from] ?? 0;
88
+ const high = heights[to] ?? 0;
89
+ if (Math.abs(low) < FLAT || Math.abs(high) < FLAT)
90
+ continue;
91
+ if (low > 0 === high > 0)
92
+ continue;
93
+ const start = corners[from];
94
+ const end = corners[to];
95
+ if (start === undefined || end === undefined)
96
+ continue;
97
+ const fraction = low / (low - high);
98
+ hits.push(stepAlong(start, subtractVectors(end, start), fraction));
99
+ }
100
+ const points = [];
101
+ for (const hit of hits)
102
+ points.push(toCartesian(lattice, hit));
103
+ const section = dedupe(points);
104
+ if (section.length < 3)
105
+ return [];
106
+ return orderAroundPlane(section, normal);
107
+ }
108
+ function stepAlong(origin, direction, distance) {
109
+ return addVectors(origin, scaleVector(direction, distance));
110
+ }
111
+ /**
112
+ * The eight corners of the box, in the order {@link CUBE_EDGES} indexes.
113
+ * @param cells - How many cells the box spans along each axis.
114
+ * @returns The corners, in cell fractions.
115
+ */
116
+ function cubeCorners(cells) {
117
+ const corners = [];
118
+ for (let i = 0; i < 2; i++) {
119
+ for (let j = 0; j < 2; j++) {
120
+ for (let k = 0; k < 2; k++) {
121
+ corners.push([i * cells, j * cells, k * cells]);
122
+ }
123
+ }
124
+ }
125
+ return corners;
126
+ }
127
+ /** Corners that differ in exactly one coordinate are joined by an edge. */
128
+ const CUBE_EDGES = [
129
+ [0, 1],
130
+ [0, 2],
131
+ [0, 4],
132
+ [1, 3],
133
+ [1, 5],
134
+ [2, 3],
135
+ [2, 6],
136
+ [3, 7],
137
+ [4, 5],
138
+ [4, 6],
139
+ [5, 7],
140
+ [6, 7],
141
+ ];
142
+ /**
143
+ * The same corners, walked round the plane rather than found in cube order.
144
+ * @param points - The corners, Cartesian ångström.
145
+ * @param normal - The plane's normal, Cartesian.
146
+ * @returns The corners, in order around the plane.
147
+ */
148
+ function orderAroundPlane(points, normal) {
149
+ const { major, minor } = planeFrame(normal);
150
+ let centre = [0, 0, 0];
151
+ for (const point of points)
152
+ centre = addVectors(centre, point);
153
+ centre = scaleVector(centre, 1 / points.length);
154
+ const turned = [];
155
+ for (const point of points) {
156
+ const offset = subtractVectors(point, centre);
157
+ turned.push({
158
+ point,
159
+ angle: Math.atan2(dotProduct(offset, minor), dotProduct(offset, major)),
160
+ });
161
+ }
162
+ turned.sort((left, right) => left.angle - right.angle);
163
+ const ordered = [];
164
+ for (const entry of turned)
165
+ ordered.push(entry.point);
166
+ return ordered;
167
+ }
168
+ /**
169
+ * A corner the plane passes through is found once per edge that meets it.
170
+ * @param points - The corners found, Cartesian ångström.
171
+ * @returns Each corner once.
172
+ */
173
+ function dedupe(points) {
174
+ const kept = [];
175
+ for (const point of points) {
176
+ let seen = false;
177
+ for (const other of kept) {
178
+ if (Math.abs((point[0] ?? 0) - (other[0] ?? 0)) < SAME &&
179
+ Math.abs((point[1] ?? 0) - (other[1] ?? 0)) < SAME &&
180
+ Math.abs((point[2] ?? 0) - (other[2] ?? 0)) < SAME) {
181
+ seen = true;
182
+ break;
183
+ }
184
+ }
185
+ if (!seen)
186
+ kept.push(point);
187
+ }
188
+ return kept;
189
+ }
190
+ /** Below this, a line runs along a face rather than through it. */
191
+ const PARALLEL = 1e-9;
192
+ /** How far outside the box a parallel line may still count as inside it. */
193
+ const SLACK = 1e-9;
194
+ /** Below this, in cell fractions, a corner lies on the plane. */
195
+ const FLAT = 1e-9;
196
+ /** Below this, in ångström, two corners are the same corner. */
197
+ const SAME = 1e-6;
198
+ //# sourceMappingURL=cellClip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellClip.js","sourceRoot":"","sources":["../../../src/crystal3d/core/cellClip.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,WAAW,EACX,YAAY,GACb,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,UAAU,EACV,UAAU,EACV,WAAW,EACX,eAAe,GAChB,MAAM,WAAW,CAAC;AAQnB;;;;;;;;;GASG;AACH,MAAM,UAAU,cAAc,CAC5B,OAAgB,EAChB,KAAa,EACb,SAAiB,EACjB,KAAK,GAAG,CAAC;IAET,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC/C,IAAI,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACrC,IAAI,KAAK,GAAG,MAAM,CAAC,iBAAiB,CAAC;IACrC,KAAK,IAAI,IAAI,GAAG,CAAC,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC;QACpC,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChC,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,QAAQ,EAAE,CAAC;YAC/B,IAAI,KAAK,GAAG,CAAC,KAAK,IAAI,KAAK,GAAG,KAAK,GAAG,KAAK;gBAAE,OAAO,IAA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ElB,gEAAgE;AAChE,MAAM,IAAI,GAAG,IAAI,CAAC"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * The unit cell as lines in space: its three edge vectors, the twelve edges of
3
+ * one box, and the boxes of a supercell.
4
+ *
5
+ * The cell is drawn here rather than by molstar's own unit-cell shape, because
6
+ * the site hands molstar no space group at all — it has already applied its own
7
+ * operations — and because an n×n×n stack of boxes is not something that shape
8
+ * can draw.
9
+ */
10
+ import type { CellRepeat, Point3, UnitCell } from './types.ts';
11
+ import type { Vec3 } from './vec3.ts';
12
+ /** A segment of the drawn cell, Cartesian ångström. */
13
+ export interface CellEdge {
14
+ readonly start: Point3;
15
+ readonly end: Point3;
16
+ }
17
+ /**
18
+ * The Cartesian components of a, b and c.
19
+ *
20
+ * The convention is the PDB one — a along x, b in the xy plane — which is the
21
+ * one `src/symmetry/core` uses and the one every CIF consumer assumes.
22
+ * @param cell - The six cell parameters.
23
+ * @returns The three edge vectors, in ångström.
24
+ * @throws {RangeError} When the three angles describe no cell.
25
+ */
26
+ export declare function cellAxes(cell: UnitCell): [Vec3, Vec3, Vec3];
27
+ /**
28
+ * Where one fractional point of one cell of the stack sits.
29
+ * @param axes - The cell's edge vectors.
30
+ * @param fractional - The point, in cell fractions.
31
+ * @returns Its Cartesian position, ångström.
32
+ */
33
+ export declare function cellPoint(axes: readonly [Vec3, Vec3, Vec3], fractional: readonly [number, number, number]): Point3;
34
+ /**
35
+ * The lattice translations of an n×n×n stack, one per cell, in reading order.
36
+ * @param axes - The cell's edge vectors.
37
+ * @param repeat - Cells along a, b and c; anything below 1 counts as 1.
38
+ * @returns One translation per cell, the first of them zero.
39
+ */
40
+ export declare function latticeShifts(axes: readonly [Vec3, Vec3, Vec3], repeat: CellRepeat): Point3[];
41
+ /**
42
+ * Every edge of every cell of the stack.
43
+ * @param cell - The six cell parameters.
44
+ * @param repeat - Cells along a, b and c.
45
+ * @returns Twelve edges per cell.
46
+ * @throws {RangeError} When the three angles describe no cell.
47
+ */
48
+ export declare function cellEdges(cell: UnitCell, repeat?: CellRepeat): CellEdge[];
49
+ /**
50
+ * Where the a, b and c letters sit on the box at the origin.
51
+ * @param cell - The six cell parameters.
52
+ * @param reach - How far along each edge, as a fraction of it.
53
+ * @returns Three points, for a, b and c in that order.
54
+ * @throws {RangeError} When the three angles describe no cell.
55
+ */
56
+ export declare function cellAxisLabelPoints(cell: UnitCell, reach?: number): [Point3, Point3, Point3];
57
+ /**
58
+ * Each count, rounded down and never below one.
59
+ * @param repeat - Cells along a, b and c.
60
+ * @returns The counts, whole and at least one.
61
+ */
62
+ export declare function clampRepeat(repeat: CellRepeat): CellRepeat;
63
+ //# sourceMappingURL=cellGeometry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cellGeometry.d.ts","sourceRoot":"","sources":["../../../src/crystal3d/core/cellGeometry.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC/D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGtC,uDAAuD;AACvD,MAAM,WAAW,QAAQ;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,QAAQ,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAG3D;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EACjC,UAAU,EAAE,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,GAC5C,MAAM,CAQR;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EACjC,MAAM,EAAE,UAAU,GACjB,MAAM,EAAE,CAWV;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CACvB,IAAI,EAAE,QAAQ,EACd,MAAM,GAAE,UAAsB,GAC7B,QAAQ,EAAE,CAYZ;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,QAAQ,EACd,KAAK,SAAO,GACX,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAG1B;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,UAAU,CAM1D"}