matterviz 0.3.0 → 0.3.2
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.
- package/dist/FilePicker.svelte +37 -20
- package/dist/Icon.svelte +2 -2
- package/dist/MillerIndexInput.svelte +60 -0
- package/dist/MillerIndexInput.svelte.d.ts +7 -0
- package/dist/app.css +38 -2
- package/dist/brillouin/BrillouinZone.svelte +20 -62
- package/dist/brillouin/BrillouinZone.svelte.d.ts +1 -1
- package/dist/brillouin/BrillouinZoneExportPane.svelte +12 -20
- package/dist/brillouin/BrillouinZoneScene.svelte +2 -2
- package/dist/brillouin/BrillouinZoneScene.svelte.d.ts +1 -1
- package/dist/chempot-diagram/ChemPotDiagram.svelte +192 -0
- package/dist/chempot-diagram/ChemPotDiagram.svelte.d.ts +13 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte +677 -0
- package/dist/chempot-diagram/ChemPotDiagram2D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte +2688 -0
- package/dist/chempot-diagram/ChemPotDiagram3D.svelte.d.ts +16 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte +8 -0
- package/dist/chempot-diagram/ChemPotScene3D.svelte.d.ts +7 -0
- package/dist/chempot-diagram/color.d.ts +10 -0
- package/dist/chempot-diagram/color.js +33 -0
- package/dist/chempot-diagram/compute.d.ts +38 -0
- package/dist/chempot-diagram/compute.js +650 -0
- package/dist/chempot-diagram/index.d.ts +5 -0
- package/dist/chempot-diagram/index.js +5 -0
- package/dist/chempot-diagram/pointer.d.ts +16 -0
- package/dist/chempot-diagram/pointer.js +40 -0
- package/dist/chempot-diagram/temperature.d.ts +15 -0
- package/dist/chempot-diagram/temperature.js +37 -0
- package/dist/chempot-diagram/types.d.ts +83 -0
- package/dist/chempot-diagram/types.js +27 -0
- package/dist/colors/index.d.ts +3 -1
- package/dist/colors/index.js +4 -0
- package/dist/composition/BarChart.svelte +13 -22
- package/dist/composition/BubbleChart.svelte +5 -3
- package/dist/composition/FormulaFilter.svelte +770 -90
- package/dist/composition/FormulaFilter.svelte.d.ts +37 -1
- package/dist/composition/PieChart.svelte +43 -18
- package/dist/composition/PieChart.svelte.d.ts +1 -1
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +2 -0
- package/dist/convex-hull/ConvexHull.svelte +14 -1
- package/dist/convex-hull/ConvexHull.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull2D.svelte +14 -45
- package/dist/convex-hull/ConvexHull2D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull3D.svelte +396 -134
- package/dist/convex-hull/ConvexHull3D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHull4D.svelte +93 -42
- package/dist/convex-hull/ConvexHull4D.svelte.d.ts +1 -1
- package/dist/convex-hull/ConvexHullControls.svelte +94 -31
- package/dist/convex-hull/ConvexHullControls.svelte.d.ts +4 -2
- package/dist/convex-hull/ConvexHullStats.svelte +697 -128
- package/dist/convex-hull/ConvexHullStats.svelte.d.ts +6 -1
- package/dist/convex-hull/ConvexHullTooltip.svelte +1 -0
- package/dist/convex-hull/GasPressureControls.svelte +72 -38
- package/dist/convex-hull/GasPressureControls.svelte.d.ts +2 -1
- package/dist/convex-hull/TemperatureSlider.svelte +46 -19
- package/dist/convex-hull/TemperatureSlider.svelte.d.ts +2 -1
- package/dist/convex-hull/demo-temperature.d.ts +6 -0
- package/dist/convex-hull/demo-temperature.js +36 -0
- package/dist/convex-hull/gas-thermodynamics.js +16 -5
- package/dist/convex-hull/helpers.d.ts +7 -1
- package/dist/convex-hull/helpers.js +45 -15
- package/dist/convex-hull/index.d.ts +15 -1
- package/dist/convex-hull/index.js +1 -0
- package/dist/convex-hull/thermodynamics.d.ts +8 -21
- package/dist/convex-hull/thermodynamics.js +106 -17
- package/dist/convex-hull/types.d.ts +7 -0
- package/dist/convex-hull/types.js +11 -0
- package/dist/coordination/CoordinationBarPlot.svelte +29 -46
- package/dist/element/BohrAtom.svelte +1 -1
- package/dist/element/data.js +2 -14
- package/dist/element/data.json.gz +0 -0
- package/dist/element/index.d.ts +1 -1
- package/dist/element/index.js +1 -0
- package/dist/element/types.d.ts +1 -0
- package/dist/fermi-surface/FermiSurface.svelte +21 -65
- package/dist/fermi-surface/FermiSurface.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceControls.svelte.d.ts +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte +1 -1
- package/dist/fermi-surface/FermiSurfaceScene.svelte.d.ts +1 -1
- package/dist/fermi-surface/compute.js +1 -21
- package/dist/fermi-surface/marching-cubes.d.ts +2 -13
- package/dist/fermi-surface/marching-cubes.js +2 -519
- package/dist/fermi-surface/parse.js +17 -23
- package/dist/heatmap-matrix/HeatmapMatrix.svelte +1273 -0
- package/dist/heatmap-matrix/HeatmapMatrix.svelte.d.ts +110 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte +171 -0
- package/dist/heatmap-matrix/HeatmapMatrixControls.svelte.d.ts +31 -0
- package/dist/heatmap-matrix/index.d.ts +53 -0
- package/dist/heatmap-matrix/index.js +100 -0
- package/dist/heatmap-matrix/shared.d.ts +2 -0
- package/dist/heatmap-matrix/shared.js +4 -0
- package/dist/icons.d.ts +119 -0
- package/dist/icons.js +119 -0
- package/dist/index.d.ts +6 -1
- package/dist/index.js +6 -1
- package/dist/io/export.js +15 -3
- package/dist/io/file-drop.d.ts +7 -0
- package/dist/io/file-drop.js +43 -0
- package/dist/io/index.d.ts +2 -2
- package/dist/io/index.js +2 -112
- package/dist/io/types.d.ts +1 -0
- package/dist/io/url-drop.d.ts +2 -0
- package/dist/io/url-drop.js +118 -0
- package/dist/isosurface/Isosurface.svelte +231 -0
- package/dist/isosurface/Isosurface.svelte.d.ts +8 -0
- package/dist/isosurface/IsosurfaceControls.svelte +273 -0
- package/dist/isosurface/IsosurfaceControls.svelte.d.ts +9 -0
- package/dist/isosurface/index.d.ts +5 -0
- package/dist/isosurface/index.js +6 -0
- package/dist/isosurface/parse.d.ts +6 -0
- package/dist/isosurface/parse.js +548 -0
- package/dist/isosurface/slice.d.ts +11 -0
- package/dist/isosurface/slice.js +145 -0
- package/dist/isosurface/types.d.ts +55 -0
- package/dist/isosurface/types.js +178 -0
- package/dist/labels.d.ts +2 -1
- package/dist/labels.js +1 -0
- package/dist/layout/InfoTag.svelte +62 -62
- package/dist/layout/SubpageGrid.svelte +74 -0
- package/dist/layout/SubpageGrid.svelte.d.ts +14 -0
- package/dist/layout/index.d.ts +1 -0
- package/dist/layout/index.js +1 -0
- package/dist/layout/json-tree/JsonNode.svelte +226 -53
- package/dist/layout/json-tree/JsonTree.svelte +425 -51
- package/dist/layout/json-tree/JsonTree.svelte.d.ts +1 -1
- package/dist/layout/json-tree/JsonValue.svelte +218 -97
- package/dist/layout/json-tree/types.d.ts +27 -2
- package/dist/layout/json-tree/utils.d.ts +14 -1
- package/dist/layout/json-tree/utils.js +254 -0
- package/dist/marching-cubes.d.ts +14 -0
- package/dist/marching-cubes.js +519 -0
- package/dist/math.d.ts +8 -0
- package/dist/math.js +374 -7
- package/dist/overlays/ContextMenu.svelte +3 -2
- package/dist/overlays/DraggablePane.svelte +163 -58
- package/dist/overlays/DraggablePane.svelte.d.ts +2 -0
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte +232 -77
- package/dist/phase-diagram/IsobaricBinaryPhaseDiagram.svelte.d.ts +6 -2
- package/dist/phase-diagram/PhaseDiagramControls.svelte +32 -11
- package/dist/phase-diagram/PhaseDiagramControls.svelte.d.ts +3 -2
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte +103 -0
- package/dist/phase-diagram/PhaseDiagramEditorPane.svelte.d.ts +15 -0
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte +102 -95
- package/dist/phase-diagram/PhaseDiagramExportPane.svelte.d.ts +7 -0
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte +100 -26
- package/dist/phase-diagram/PhaseDiagramTooltip.svelte.d.ts +6 -3
- package/dist/phase-diagram/index.d.ts +2 -0
- package/dist/phase-diagram/index.js +2 -0
- package/dist/phase-diagram/svg-to-diagram.d.ts +2 -0
- package/dist/phase-diagram/svg-to-diagram.js +865 -0
- package/dist/phase-diagram/types.d.ts +10 -0
- package/dist/phase-diagram/utils.d.ts +7 -4
- package/dist/phase-diagram/utils.js +149 -59
- package/dist/plot/AxisLabel.svelte +26 -0
- package/dist/plot/AxisLabel.svelte.d.ts +16 -0
- package/dist/plot/BarPlot.svelte +473 -228
- package/dist/plot/BarPlot.svelte.d.ts +3 -3
- package/dist/plot/BarPlotControls.svelte +3 -2
- package/dist/plot/BarPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ColorBar.svelte +54 -54
- package/dist/plot/ColorBar.svelte.d.ts +1 -1
- package/dist/plot/ElementScatter.svelte +4 -3
- package/dist/plot/FillArea.svelte +4 -1
- package/dist/plot/Histogram.svelte +320 -230
- package/dist/plot/Histogram.svelte.d.ts +2 -2
- package/dist/plot/HistogramControls.svelte +29 -10
- package/dist/plot/HistogramControls.svelte.d.ts +6 -2
- package/dist/plot/InteractiveAxisLabel.svelte.d.ts +2 -2
- package/dist/plot/PlotControls.svelte +109 -27
- package/dist/plot/PlotControls.svelte.d.ts +1 -1
- package/dist/plot/PlotLegend.svelte +1 -1
- package/dist/plot/PortalSelect.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte +2 -1
- package/dist/plot/ReferenceLine.svelte.d.ts +1 -0
- package/dist/plot/ReferencePlane.svelte +1 -3
- package/dist/plot/ScatterPlot.svelte +343 -209
- package/dist/plot/ScatterPlot.svelte.d.ts +3 -3
- package/dist/plot/ScatterPlot3D.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlot3DControls.svelte +203 -250
- package/dist/plot/ScatterPlot3DScene.svelte +4 -7
- package/dist/plot/ScatterPlot3DScene.svelte.d.ts +2 -2
- package/dist/plot/ScatterPlotControls.svelte +95 -55
- package/dist/plot/ScatterPlotControls.svelte.d.ts +1 -1
- package/dist/plot/ZeroLines.svelte +44 -0
- package/dist/plot/ZeroLines.svelte.d.ts +32 -0
- package/dist/plot/ZoomRect.svelte +21 -0
- package/dist/plot/ZoomRect.svelte.d.ts +8 -0
- package/dist/plot/axis-utils.d.ts +1 -1
- package/dist/plot/data-cleaning.js +1 -5
- package/dist/plot/index.d.ts +6 -2
- package/dist/plot/index.js +6 -2
- package/dist/plot/interactions.d.ts +8 -10
- package/dist/plot/interactions.js +10 -19
- package/dist/plot/layout.d.ts +7 -1
- package/dist/plot/layout.js +12 -4
- package/dist/plot/reference-line.d.ts +4 -21
- package/dist/plot/reference-line.js +7 -81
- package/dist/plot/types.d.ts +42 -17
- package/dist/plot/types.js +10 -0
- package/dist/plot/utils/label-placement.js +14 -11
- package/dist/plot/utils.d.ts +1 -0
- package/dist/plot/utils.js +14 -0
- package/dist/rdf/RdfPlot.svelte +55 -66
- package/dist/rdf/RdfPlot.svelte.d.ts +1 -1
- package/dist/rdf/index.d.ts +1 -1
- package/dist/rdf/index.js +1 -1
- package/dist/settings.d.ts +5 -0
- package/dist/settings.js +37 -3
- package/dist/spectral/Bands.svelte +515 -143
- package/dist/spectral/Bands.svelte.d.ts +22 -2
- package/dist/spectral/helpers.d.ts +23 -1
- package/dist/spectral/helpers.js +65 -9
- package/dist/spectral/types.d.ts +2 -0
- package/dist/structure/AtomLegend.svelte +31 -10
- package/dist/structure/AtomLegend.svelte.d.ts +1 -1
- package/dist/structure/CellSelect.svelte +92 -22
- package/dist/structure/Lattice.svelte +2 -0
- package/dist/structure/Structure.svelte +716 -173
- package/dist/structure/Structure.svelte.d.ts +7 -2
- package/dist/structure/StructureControls.svelte +26 -14
- package/dist/structure/StructureControls.svelte.d.ts +5 -1
- package/dist/structure/StructureInfoPane.svelte +7 -1
- package/dist/structure/StructureScene.svelte +386 -95
- package/dist/structure/StructureScene.svelte.d.ts +15 -4
- package/dist/structure/atom-properties.d.ts +6 -2
- package/dist/structure/atom-properties.js +38 -25
- package/dist/structure/export.js +10 -7
- package/dist/structure/ferrox-wasm-types.d.ts +3 -2
- package/dist/structure/ferrox-wasm-types.js +0 -3
- package/dist/structure/ferrox-wasm.d.ts +3 -2
- package/dist/structure/ferrox-wasm.js +1 -2
- package/dist/structure/index.d.ts +7 -0
- package/dist/structure/index.js +22 -0
- package/dist/structure/parse.js +19 -16
- package/dist/structure/partial-occupancy.d.ts +25 -0
- package/dist/structure/partial-occupancy.js +102 -0
- package/dist/structure/validation.js +6 -3
- package/dist/symmetry/SymmetryStats.svelte +18 -4
- package/dist/symmetry/WyckoffTable.svelte +18 -10
- package/dist/symmetry/index.d.ts +7 -4
- package/dist/symmetry/index.js +83 -18
- package/dist/table/HeatmapTable.svelte +468 -69
- package/dist/table/HeatmapTable.svelte.d.ts +13 -1
- package/dist/table/ToggleMenu.svelte +291 -44
- package/dist/table/ToggleMenu.svelte.d.ts +4 -1
- package/dist/table/index.d.ts +3 -0
- package/dist/tooltip/index.d.ts +1 -1
- package/dist/tooltip/index.js +1 -0
- package/dist/trajectory/Trajectory.svelte +147 -145
- package/dist/trajectory/TrajectoryExportPane.svelte +13 -9
- package/dist/trajectory/TrajectoryExportPane.svelte.d.ts +1 -1
- package/dist/trajectory/constants.d.ts +6 -0
- package/dist/trajectory/constants.js +7 -0
- package/dist/trajectory/extract.js +3 -5
- package/dist/trajectory/format-detect.d.ts +9 -0
- package/dist/trajectory/format-detect.js +76 -0
- package/dist/trajectory/frame-reader.d.ts +17 -0
- package/dist/trajectory/frame-reader.js +339 -0
- package/dist/trajectory/helpers.d.ts +15 -0
- package/dist/trajectory/helpers.js +187 -0
- package/dist/trajectory/index.d.ts +1 -0
- package/dist/trajectory/index.js +11 -4
- package/dist/trajectory/parse/ase.d.ts +2 -0
- package/dist/trajectory/parse/ase.js +76 -0
- package/dist/trajectory/parse/hdf5.d.ts +2 -0
- package/dist/trajectory/parse/hdf5.js +121 -0
- package/dist/trajectory/parse/index.d.ts +12 -0
- package/dist/trajectory/parse/index.js +304 -0
- package/dist/trajectory/parse/lammps.d.ts +5 -0
- package/dist/trajectory/parse/lammps.js +169 -0
- package/dist/trajectory/parse/vasp.d.ts +2 -0
- package/dist/trajectory/parse/vasp.js +65 -0
- package/dist/trajectory/parse/xyz.d.ts +2 -0
- package/dist/trajectory/parse/xyz.js +109 -0
- package/dist/trajectory/types.d.ts +11 -0
- package/dist/trajectory/types.js +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +4 -0
- package/dist/xrd/XrdPlot.svelte +6 -4
- package/dist/xrd/calc-xrd.js +0 -1
- package/package.json +33 -23
- package/readme.md +4 -4
- package/dist/trajectory/parse.d.ts +0 -42
- package/dist/trajectory/parse.js +0 -1267
- /package/dist/element/{data.json.d.ts → data.json.gz.d.ts} +0 -0
|
@@ -1,519 +1,2 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
// deno-fmt-ignore
|
|
4
|
-
const EDGE_TABLE = [0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c, 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00, 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c, 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90, 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c, 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30, 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac, 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0, 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c, 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60, 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc, 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0, 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c, 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950, 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc, 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0, 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc, 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0, 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c, 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650, 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc, 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0, 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c, 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460, 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac, 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0, 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c, 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230, 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c, 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190, 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c, 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0];
|
|
5
|
-
// Triangle table: for each cube configuration, list of edge triplets forming triangles
|
|
6
|
-
// -1 marks the end of the triangle list for that configuration
|
|
7
|
-
const TRI_TABLE = [
|
|
8
|
-
[],
|
|
9
|
-
[0, 8, 3],
|
|
10
|
-
[0, 1, 9],
|
|
11
|
-
[1, 8, 3, 9, 8, 1],
|
|
12
|
-
[1, 2, 10],
|
|
13
|
-
[0, 8, 3, 1, 2, 10],
|
|
14
|
-
[9, 2, 10, 0, 2, 9],
|
|
15
|
-
[2, 8, 3, 2, 10, 8, 10, 9, 8],
|
|
16
|
-
[3, 11, 2],
|
|
17
|
-
[0, 11, 2, 8, 11, 0],
|
|
18
|
-
[1, 9, 0, 2, 3, 11],
|
|
19
|
-
[1, 11, 2, 1, 9, 11, 9, 8, 11],
|
|
20
|
-
[3, 10, 1, 11, 10, 3],
|
|
21
|
-
[0, 10, 1, 0, 8, 10, 8, 11, 10],
|
|
22
|
-
[3, 9, 0, 3, 11, 9, 11, 10, 9],
|
|
23
|
-
[9, 8, 10, 10, 8, 11],
|
|
24
|
-
[4, 7, 8],
|
|
25
|
-
[4, 3, 0, 7, 3, 4],
|
|
26
|
-
[0, 1, 9, 8, 4, 7],
|
|
27
|
-
[4, 1, 9, 4, 7, 1, 7, 3, 1],
|
|
28
|
-
[1, 2, 10, 8, 4, 7],
|
|
29
|
-
[3, 4, 7, 3, 0, 4, 1, 2, 10],
|
|
30
|
-
[9, 2, 10, 9, 0, 2, 8, 4, 7],
|
|
31
|
-
[2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4],
|
|
32
|
-
[8, 4, 7, 3, 11, 2],
|
|
33
|
-
[11, 4, 7, 11, 2, 4, 2, 0, 4],
|
|
34
|
-
[9, 0, 1, 8, 4, 7, 2, 3, 11],
|
|
35
|
-
[4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1],
|
|
36
|
-
[3, 10, 1, 3, 11, 10, 7, 8, 4],
|
|
37
|
-
[1, 11, 10, 1, 4, 11, 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114
|
-
[3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10],
|
|
115
|
-
[6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1],
|
|
116
|
-
[9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3],
|
|
117
|
-
[8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1],
|
|
118
|
-
[3, 11, 6, 3, 6, 0, 0, 6, 4],
|
|
119
|
-
[6, 4, 8, 11, 6, 8],
|
|
120
|
-
[7, 10, 6, 7, 8, 10, 8, 9, 10],
|
|
121
|
-
[0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10],
|
|
122
|
-
[10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0],
|
|
123
|
-
[10, 6, 7, 10, 7, 1, 1, 7, 3],
|
|
124
|
-
[1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7],
|
|
125
|
-
[2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9],
|
|
126
|
-
[7, 8, 0, 7, 0, 6, 6, 0, 2],
|
|
127
|
-
[7, 3, 2, 6, 7, 2],
|
|
128
|
-
[2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7],
|
|
129
|
-
[2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7],
|
|
130
|
-
[1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11],
|
|
131
|
-
[11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1],
|
|
132
|
-
[8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6],
|
|
133
|
-
[0, 9, 1, 11, 6, 7],
|
|
134
|
-
[7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0],
|
|
135
|
-
[7, 11, 6],
|
|
136
|
-
[7, 6, 11],
|
|
137
|
-
[3, 0, 8, 11, 7, 6],
|
|
138
|
-
[0, 1, 9, 11, 7, 6],
|
|
139
|
-
[8, 1, 9, 8, 3, 1, 11, 7, 6],
|
|
140
|
-
[10, 1, 2, 6, 11, 7],
|
|
141
|
-
[1, 2, 10, 3, 0, 8, 6, 11, 7],
|
|
142
|
-
[2, 9, 0, 2, 10, 9, 6, 11, 7],
|
|
143
|
-
[6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8],
|
|
144
|
-
[7, 2, 3, 6, 2, 7],
|
|
145
|
-
[7, 0, 8, 7, 6, 0, 6, 2, 0],
|
|
146
|
-
[2, 7, 6, 2, 3, 7, 0, 1, 9],
|
|
147
|
-
[1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6],
|
|
148
|
-
[10, 7, 6, 10, 1, 7, 1, 3, 7],
|
|
149
|
-
[10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8],
|
|
150
|
-
[0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7],
|
|
151
|
-
[7, 6, 10, 7, 10, 8, 8, 10, 9],
|
|
152
|
-
[6, 8, 4, 11, 8, 6],
|
|
153
|
-
[3, 6, 11, 3, 0, 6, 0, 4, 6],
|
|
154
|
-
[8, 6, 11, 8, 4, 6, 9, 0, 1],
|
|
155
|
-
[9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6],
|
|
156
|
-
[6, 8, 4, 6, 11, 8, 2, 10, 1],
|
|
157
|
-
[1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6],
|
|
158
|
-
[4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9],
|
|
159
|
-
[10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3],
|
|
160
|
-
[8, 2, 3, 8, 4, 2, 4, 6, 2],
|
|
161
|
-
[0, 4, 2, 4, 6, 2],
|
|
162
|
-
[1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8],
|
|
163
|
-
[1, 9, 4, 1, 4, 2, 2, 4, 6],
|
|
164
|
-
[8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1],
|
|
165
|
-
[10, 1, 0, 10, 0, 6, 6, 0, 4],
|
|
166
|
-
[4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3],
|
|
167
|
-
[10, 9, 4, 6, 10, 4],
|
|
168
|
-
[4, 9, 5, 7, 6, 11],
|
|
169
|
-
[0, 8, 3, 4, 9, 5, 11, 7, 6],
|
|
170
|
-
[5, 0, 1, 5, 4, 0, 7, 6, 11],
|
|
171
|
-
[11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5],
|
|
172
|
-
[9, 5, 4, 10, 1, 2, 7, 6, 11],
|
|
173
|
-
[6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5],
|
|
174
|
-
[7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2],
|
|
175
|
-
[3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6],
|
|
176
|
-
[7, 2, 3, 7, 6, 2, 5, 4, 9],
|
|
177
|
-
[9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7],
|
|
178
|
-
[3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0],
|
|
179
|
-
[6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8],
|
|
180
|
-
[9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7],
|
|
181
|
-
[1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4],
|
|
182
|
-
[4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10],
|
|
183
|
-
[7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10],
|
|
184
|
-
[6, 9, 5, 6, 11, 9, 11, 8, 9],
|
|
185
|
-
[3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5],
|
|
186
|
-
[0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11],
|
|
187
|
-
[6, 11, 3, 6, 3, 5, 5, 3, 1],
|
|
188
|
-
[1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6],
|
|
189
|
-
[0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10],
|
|
190
|
-
[11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5],
|
|
191
|
-
[6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3],
|
|
192
|
-
[5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2],
|
|
193
|
-
[9, 5, 6, 9, 6, 0, 0, 6, 2],
|
|
194
|
-
[1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8],
|
|
195
|
-
[1, 5, 6, 2, 1, 6],
|
|
196
|
-
[1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6],
|
|
197
|
-
[10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0],
|
|
198
|
-
[0, 3, 8, 5, 6, 10],
|
|
199
|
-
[10, 5, 6],
|
|
200
|
-
[11, 5, 10, 7, 5, 11],
|
|
201
|
-
[11, 5, 10, 11, 7, 5, 8, 3, 0],
|
|
202
|
-
[5, 11, 7, 5, 10, 11, 1, 9, 0],
|
|
203
|
-
[10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1],
|
|
204
|
-
[11, 1, 2, 11, 7, 1, 7, 5, 1],
|
|
205
|
-
[0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11],
|
|
206
|
-
[9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7],
|
|
207
|
-
[7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2],
|
|
208
|
-
[2, 5, 10, 2, 3, 5, 3, 7, 5],
|
|
209
|
-
[8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5],
|
|
210
|
-
[9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2],
|
|
211
|
-
[9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2],
|
|
212
|
-
[1, 3, 5, 3, 7, 5],
|
|
213
|
-
[0, 8, 7, 0, 7, 1, 1, 7, 5],
|
|
214
|
-
[9, 0, 3, 9, 3, 5, 5, 3, 7],
|
|
215
|
-
[9, 8, 7, 5, 9, 7],
|
|
216
|
-
[5, 8, 4, 5, 10, 8, 10, 11, 8],
|
|
217
|
-
[5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0],
|
|
218
|
-
[0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5],
|
|
219
|
-
[10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4],
|
|
220
|
-
[2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8],
|
|
221
|
-
[0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11],
|
|
222
|
-
[0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5],
|
|
223
|
-
[9, 4, 5, 2, 11, 3],
|
|
224
|
-
[2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4],
|
|
225
|
-
[5, 10, 2, 5, 2, 4, 4, 2, 0],
|
|
226
|
-
[3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9],
|
|
227
|
-
[5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2],
|
|
228
|
-
[8, 4, 5, 8, 5, 3, 3, 5, 1],
|
|
229
|
-
[0, 4, 5, 1, 0, 5],
|
|
230
|
-
[8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5],
|
|
231
|
-
[9, 4, 5],
|
|
232
|
-
[4, 11, 7, 4, 9, 11, 9, 10, 11],
|
|
233
|
-
[0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11],
|
|
234
|
-
[1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11],
|
|
235
|
-
[3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4],
|
|
236
|
-
[4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2],
|
|
237
|
-
[9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3],
|
|
238
|
-
[11, 7, 4, 11, 4, 2, 2, 4, 0],
|
|
239
|
-
[11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4],
|
|
240
|
-
[2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9],
|
|
241
|
-
[9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7],
|
|
242
|
-
[3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10],
|
|
243
|
-
[1, 10, 2, 8, 7, 4],
|
|
244
|
-
[4, 9, 1, 4, 1, 7, 7, 1, 3],
|
|
245
|
-
[4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1],
|
|
246
|
-
[4, 0, 3, 7, 4, 3],
|
|
247
|
-
[4, 8, 7],
|
|
248
|
-
[9, 10, 8, 10, 11, 8],
|
|
249
|
-
[3, 0, 9, 3, 9, 11, 11, 9, 10],
|
|
250
|
-
[0, 1, 10, 0, 10, 8, 8, 10, 11],
|
|
251
|
-
[3, 1, 10, 11, 3, 10],
|
|
252
|
-
[1, 2, 11, 1, 11, 9, 9, 11, 8],
|
|
253
|
-
[3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9],
|
|
254
|
-
[0, 2, 11, 8, 0, 11],
|
|
255
|
-
[3, 2, 11],
|
|
256
|
-
[2, 3, 8, 2, 8, 10, 10, 8, 9],
|
|
257
|
-
[9, 10, 2, 0, 9, 2],
|
|
258
|
-
[2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8],
|
|
259
|
-
[1, 10, 2],
|
|
260
|
-
[1, 3, 8, 9, 1, 8],
|
|
261
|
-
[0, 9, 1],
|
|
262
|
-
[0, 3, 8],
|
|
263
|
-
[],
|
|
264
|
-
];
|
|
265
|
-
// Vertex positions for the 8 corners of a unit cube - flat arrays for speed
|
|
266
|
-
// Format: [x0,y0,z0, x1,y1,z1, ...] - access as CUBE_VERTS_X[i], etc.
|
|
267
|
-
const CUBE_VERTS_X = new Int8Array([0, 1, 1, 0, 0, 1, 1, 0]);
|
|
268
|
-
const CUBE_VERTS_Y = new Int8Array([0, 0, 1, 1, 0, 0, 1, 1]);
|
|
269
|
-
const CUBE_VERTS_Z = new Int8Array([0, 0, 0, 0, 1, 1, 1, 1]);
|
|
270
|
-
// Edge definitions: pairs of vertex indices for each of 12 edges
|
|
271
|
-
// Flattened for direct access: edge i has vertices EDGE_V1[i] and EDGE_V2[i]
|
|
272
|
-
const EDGE_V1 = new Uint8Array([0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3]);
|
|
273
|
-
const EDGE_V2 = new Uint8Array([1, 2, 3, 0, 5, 6, 7, 4, 4, 5, 6, 7]);
|
|
274
|
-
// Compute gradient (normal) at a grid point using central differences
|
|
275
|
-
function compute_gradient(grid, ix, iy, iz, nx, ny, nz, periodic) {
|
|
276
|
-
// Wrap for periodic, clamp for non-periodic boundaries
|
|
277
|
-
const wrap = (val, n) => ((val % n) + n) % n;
|
|
278
|
-
const clamp = (val, max) => Math.max(0, Math.min(val, max));
|
|
279
|
-
const [ix_w, iy_w, iz_w] = periodic
|
|
280
|
-
? [wrap(ix, nx), wrap(iy, ny), wrap(iz, nz)]
|
|
281
|
-
: [clamp(ix, nx - 1), clamp(iy, ny - 1), clamp(iz, nz - 1)];
|
|
282
|
-
const [ix_m, ix_p] = periodic
|
|
283
|
-
? [wrap(ix - 1, nx), wrap(ix + 1, nx)]
|
|
284
|
-
: [Math.max(0, ix - 1), Math.min(nx - 1, ix + 1)];
|
|
285
|
-
const [iy_m, iy_p] = periodic
|
|
286
|
-
? [wrap(iy - 1, ny), wrap(iy + 1, ny)]
|
|
287
|
-
: [Math.max(0, iy - 1), Math.min(ny - 1, iy + 1)];
|
|
288
|
-
const [iz_m, iz_p] = periodic
|
|
289
|
-
? [wrap(iz - 1, nz), wrap(iz + 1, nz)]
|
|
290
|
-
: [Math.max(0, iz - 1), Math.min(nz - 1, iz + 1)];
|
|
291
|
-
const dx = (grid[ix_p][iy_w][iz_w] - grid[ix_m][iy_w][iz_w]) * 0.5;
|
|
292
|
-
const dy = (grid[ix_w][iy_p][iz_w] - grid[ix_w][iy_m][iz_w]) * 0.5;
|
|
293
|
-
const dz = (grid[ix_w][iy_w][iz_p] - grid[ix_w][iy_w][iz_m]) * 0.5;
|
|
294
|
-
const len_sq = dx * dx + dy * dy + dz * dz;
|
|
295
|
-
if (len_sq < 1e-20)
|
|
296
|
-
return [0, 0, 1];
|
|
297
|
-
const inv_len = 1 / Math.sqrt(len_sq);
|
|
298
|
-
return [-dx * inv_len, -dy * inv_len, -dz * inv_len];
|
|
299
|
-
}
|
|
300
|
-
// Main marching cubes algorithm (optimized version)
|
|
301
|
-
export function marching_cubes(grid, iso_value, k_lattice, options = {}) {
|
|
302
|
-
const { periodic = true, interpolate = true, centered = true } = options;
|
|
303
|
-
// When centered=true, shift fractional coordinates by -0.5 so the grid is
|
|
304
|
-
// centered at the origin (Γ point). This is needed for proper BZ visualization.
|
|
305
|
-
const center_offset = centered ? 0.5 : 0;
|
|
306
|
-
const nx = grid.length;
|
|
307
|
-
const ny = grid[0]?.length || 0;
|
|
308
|
-
const nz = grid[0]?.[0]?.length || 0;
|
|
309
|
-
if (nx < 2 || ny < 2 || nz < 2) {
|
|
310
|
-
return { vertices: [], faces: [], normals: [] };
|
|
311
|
-
}
|
|
312
|
-
const vertices = [];
|
|
313
|
-
const faces = [];
|
|
314
|
-
const normals = [];
|
|
315
|
-
// Precompute grid dimension products for flattening and cache keys
|
|
316
|
-
const ny_nz = ny * nz;
|
|
317
|
-
const max_flat = nx * ny_nz; // for computing cache keys
|
|
318
|
-
// Use numeric cache key - safe for grids up to ~300³ (2^53 / 2 / max_flat)
|
|
319
|
-
// For much larger grids (>30M cells), consider switching to Map<string, number>
|
|
320
|
-
// with keys like `${flat1},${flat2}` or Map<bigint, number> to avoid
|
|
321
|
-
// Number.MAX_SAFE_INTEGER limits. The current approach is faster for typical grids.
|
|
322
|
-
if (max_flat > 30_000_000) {
|
|
323
|
-
console.warn(`Grid size ${nx}×${ny}×${nz} may cause cache key overflow`);
|
|
324
|
-
}
|
|
325
|
-
const vertex_cache = new Map();
|
|
326
|
-
// Safe modulo wrapping helper (handles negative values correctly)
|
|
327
|
-
const wrap = (val, size) => ((val % size) + size) % size;
|
|
328
|
-
// Precompute k_lattice values for faster coordinate transform
|
|
329
|
-
const [kx0, kx1, kx2] = k_lattice[0];
|
|
330
|
-
const [ky0, ky1, ky2] = k_lattice[1];
|
|
331
|
-
const [kz0, kz1, kz2] = k_lattice[2];
|
|
332
|
-
// Precompute inverse grid sizes
|
|
333
|
-
// Use (n-1) because n grid points span [0,1] with spacing 1/(n-1)
|
|
334
|
-
// Grid index 0 maps to 0, grid index (n-1) maps to 1
|
|
335
|
-
// This matches scikit-image's marching cubes coordinate convention
|
|
336
|
-
const inv_nx = 1 / (nx - 1);
|
|
337
|
-
const inv_ny = 1 / (ny - 1);
|
|
338
|
-
const inv_nz = 1 / (nz - 1);
|
|
339
|
-
// Get or create vertex on an edge (fully optimized with flat array lookups)
|
|
340
|
-
const get_vertex_on_edge = (ix, iy, iz, edge_idx, cube_values) => {
|
|
341
|
-
// Use flat arrays instead of destructuring
|
|
342
|
-
const v1_idx = EDGE_V1[edge_idx];
|
|
343
|
-
const v2_idx = EDGE_V2[edge_idx];
|
|
344
|
-
const ox1 = CUBE_VERTS_X[v1_idx];
|
|
345
|
-
const oy1 = CUBE_VERTS_Y[v1_idx];
|
|
346
|
-
const oz1 = CUBE_VERTS_Z[v1_idx];
|
|
347
|
-
const ox2 = CUBE_VERTS_X[v2_idx];
|
|
348
|
-
const oy2 = CUBE_VERTS_Y[v2_idx];
|
|
349
|
-
const oz2 = CUBE_VERTS_Z[v2_idx];
|
|
350
|
-
// Compute wrapped grid positions using safe modulo for periodic boundaries
|
|
351
|
-
const g1x = periodic ? wrap(ix + ox1, nx) : ix + ox1;
|
|
352
|
-
const g1y = periodic ? wrap(iy + oy1, ny) : iy + oy1;
|
|
353
|
-
const g1z = periodic ? wrap(iz + oz1, nz) : iz + oz1;
|
|
354
|
-
const g2x = periodic ? wrap(ix + ox2, nx) : ix + ox2;
|
|
355
|
-
const g2y = periodic ? wrap(iy + oy2, ny) : iy + oy2;
|
|
356
|
-
const g2z = periodic ? wrap(iz + oz2, nz) : iz + oz2;
|
|
357
|
-
// Create numeric cache key (sorted for consistency)
|
|
358
|
-
// Safe for grids up to ~300³ before exceeding Number.MAX_SAFE_INTEGER
|
|
359
|
-
const flat1 = g1x * ny_nz + g1y * nz + g1z;
|
|
360
|
-
const flat2 = g2x * ny_nz + g2y * nz + g2z;
|
|
361
|
-
const cache_key = flat1 < flat2 ? flat1 * max_flat + flat2 : flat2 * max_flat + flat1;
|
|
362
|
-
const cached = vertex_cache.get(cache_key);
|
|
363
|
-
if (cached !== undefined)
|
|
364
|
-
return cached;
|
|
365
|
-
// Compute vertex position
|
|
366
|
-
const v1 = cube_values[v1_idx];
|
|
367
|
-
const v2 = cube_values[v2_idx];
|
|
368
|
-
let fx, fy, fz;
|
|
369
|
-
if (interpolate) {
|
|
370
|
-
const f1x = (ix + ox1) * inv_nx - center_offset;
|
|
371
|
-
const f1y = (iy + oy1) * inv_ny - center_offset;
|
|
372
|
-
const f1z = (iz + oz1) * inv_nz - center_offset;
|
|
373
|
-
const f2x = (ix + ox2) * inv_nx - center_offset;
|
|
374
|
-
const f2y = (iy + oy2) * inv_ny - center_offset;
|
|
375
|
-
const f2z = (iz + oz2) * inv_nz - center_offset;
|
|
376
|
-
const dv = v2 - v1;
|
|
377
|
-
if (Math.abs(dv) < 1e-10) {
|
|
378
|
-
fx = f1x;
|
|
379
|
-
fy = f1y;
|
|
380
|
-
fz = f1z;
|
|
381
|
-
}
|
|
382
|
-
else {
|
|
383
|
-
const t = (iso_value - v1) / dv;
|
|
384
|
-
fx = f1x + t * (f2x - f1x);
|
|
385
|
-
fy = f1y + t * (f2y - f1y);
|
|
386
|
-
fz = f1z + t * (f2z - f1z);
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
fx = (ix + (ox1 + ox2) * 0.5) * inv_nx - center_offset;
|
|
391
|
-
fy = (iy + (oy1 + oy2) * 0.5) * inv_ny - center_offset;
|
|
392
|
-
fz = (iz + (oz1 + oz2) * 0.5) * inv_nz - center_offset;
|
|
393
|
-
}
|
|
394
|
-
// Transform to Cartesian (inlined)
|
|
395
|
-
const vert_idx = vertices.length;
|
|
396
|
-
vertices.push([
|
|
397
|
-
fx * kx0 + fy * ky0 + fz * kz0,
|
|
398
|
-
fx * kx1 + fy * ky1 + fz * kz1,
|
|
399
|
-
fx * kx2 + fy * ky2 + fz * kz2,
|
|
400
|
-
]);
|
|
401
|
-
// Compute normal (simplified - skip gradient interpolation for speed)
|
|
402
|
-
const norm = compute_gradient(grid, ix + ox1, iy + oy1, iz + oz1, nx, ny, nz, periodic);
|
|
403
|
-
normals.push(norm);
|
|
404
|
-
vertex_cache.set(cache_key, vert_idx);
|
|
405
|
-
return vert_idx;
|
|
406
|
-
};
|
|
407
|
-
// Iterate over all cubes in the grid
|
|
408
|
-
const max_x = periodic ? nx : nx - 1;
|
|
409
|
-
const max_y = periodic ? ny : ny - 1;
|
|
410
|
-
const max_z = periodic ? nz : nz - 1;
|
|
411
|
-
// Preallocate cube_values array (reuse across iterations)
|
|
412
|
-
const cube_values = new Array(8);
|
|
413
|
-
for (let ix = 0; ix < max_x; ix++) {
|
|
414
|
-
const ix_row = grid[ix];
|
|
415
|
-
const ix1_row = grid[(ix + 1) % nx];
|
|
416
|
-
for (let iy = 0; iy < max_y; iy++) {
|
|
417
|
-
const iy_col = ix_row[iy];
|
|
418
|
-
const iy1_col = ix_row[(iy + 1) % ny];
|
|
419
|
-
const ix1_iy_col = ix1_row[iy];
|
|
420
|
-
const ix1_iy1_col = ix1_row[(iy + 1) % ny];
|
|
421
|
-
for (let iz = 0; iz < max_z; iz++) {
|
|
422
|
-
const iz1 = (iz + 1) % nz;
|
|
423
|
-
// Get corner values (inlined for speed)
|
|
424
|
-
cube_values[0] = iy_col[iz];
|
|
425
|
-
cube_values[1] = ix1_iy_col[iz];
|
|
426
|
-
cube_values[2] = ix1_iy1_col[iz];
|
|
427
|
-
cube_values[3] = iy1_col[iz];
|
|
428
|
-
cube_values[4] = iy_col[iz1];
|
|
429
|
-
cube_values[5] = ix1_iy_col[iz1];
|
|
430
|
-
cube_values[6] = ix1_iy1_col[iz1];
|
|
431
|
-
cube_values[7] = iy1_col[iz1];
|
|
432
|
-
// Compute cube index (unrolled for speed)
|
|
433
|
-
let cube_index = 0;
|
|
434
|
-
if (cube_values[0] < iso_value)
|
|
435
|
-
cube_index |= 1;
|
|
436
|
-
if (cube_values[1] < iso_value)
|
|
437
|
-
cube_index |= 2;
|
|
438
|
-
if (cube_values[2] < iso_value)
|
|
439
|
-
cube_index |= 4;
|
|
440
|
-
if (cube_values[3] < iso_value)
|
|
441
|
-
cube_index |= 8;
|
|
442
|
-
if (cube_values[4] < iso_value)
|
|
443
|
-
cube_index |= 16;
|
|
444
|
-
if (cube_values[5] < iso_value)
|
|
445
|
-
cube_index |= 32;
|
|
446
|
-
if (cube_values[6] < iso_value)
|
|
447
|
-
cube_index |= 64;
|
|
448
|
-
if (cube_values[7] < iso_value)
|
|
449
|
-
cube_index |= 128;
|
|
450
|
-
// Skip if cube is entirely inside or outside
|
|
451
|
-
if (EDGE_TABLE[cube_index] === 0)
|
|
452
|
-
continue;
|
|
453
|
-
// Get triangles for this cube configuration
|
|
454
|
-
const tri_list = TRI_TABLE[cube_index];
|
|
455
|
-
const tri_len = tri_list.length;
|
|
456
|
-
// Create triangles
|
|
457
|
-
for (let tri_idx = 0; tri_idx < tri_len; tri_idx += 3) {
|
|
458
|
-
const v0 = get_vertex_on_edge(ix, iy, iz, tri_list[tri_idx], cube_values);
|
|
459
|
-
const v1 = get_vertex_on_edge(ix, iy, iz, tri_list[tri_idx + 1], cube_values);
|
|
460
|
-
const v2 = get_vertex_on_edge(ix, iy, iz, tri_list[tri_idx + 2], cube_values);
|
|
461
|
-
// Skip degenerate triangles
|
|
462
|
-
if (v0 !== v1 && v1 !== v2 && v0 !== v2) {
|
|
463
|
-
faces.push([v0, v1, v2]);
|
|
464
|
-
}
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
return { vertices, faces, normals };
|
|
470
|
-
}
|
|
471
|
-
// Compute per-vertex normals from faces using area-weighted averaging
|
|
472
|
-
// Uses fan triangulation for N-gon faces (quads, etc.)
|
|
473
|
-
export function compute_vertex_normals(vertices, faces) {
|
|
474
|
-
const normals = vertices.map(() => [0, 0, 0]);
|
|
475
|
-
for (const face of faces) {
|
|
476
|
-
// Validate face has at least 3 indices and all are within bounds
|
|
477
|
-
if (face.length < 3)
|
|
478
|
-
continue;
|
|
479
|
-
if (face.some((idx) => idx < 0 || idx >= vertices.length))
|
|
480
|
-
continue;
|
|
481
|
-
// Fan triangulation: for N vertices, process N-2 triangles (0,1,2), (0,2,3), ...
|
|
482
|
-
const v0 = vertices[face[0]];
|
|
483
|
-
for (let fan_idx = 1; fan_idx < face.length - 1; fan_idx++) {
|
|
484
|
-
const idx1 = face[fan_idx];
|
|
485
|
-
const idx2 = face[fan_idx + 1];
|
|
486
|
-
const v1 = vertices[idx1];
|
|
487
|
-
const v2 = vertices[idx2];
|
|
488
|
-
// Edge vectors
|
|
489
|
-
const e1 = [v1[0] - v0[0], v1[1] - v0[1], v1[2] - v0[2]];
|
|
490
|
-
const e2 = [v2[0] - v0[0], v2[1] - v0[1], v2[2] - v0[2]];
|
|
491
|
-
// Cross product (face normal * 2 * area)
|
|
492
|
-
const normal = [
|
|
493
|
-
e1[1] * e2[2] - e1[2] * e2[1],
|
|
494
|
-
e1[2] * e2[0] - e1[0] * e2[2],
|
|
495
|
-
e1[0] * e2[1] - e1[1] * e2[0],
|
|
496
|
-
];
|
|
497
|
-
// Add to the 3 vertices of this triangle
|
|
498
|
-
normals[face[0]][0] += normal[0];
|
|
499
|
-
normals[face[0]][1] += normal[1];
|
|
500
|
-
normals[face[0]][2] += normal[2];
|
|
501
|
-
normals[idx1][0] += normal[0];
|
|
502
|
-
normals[idx1][1] += normal[1];
|
|
503
|
-
normals[idx1][2] += normal[2];
|
|
504
|
-
normals[idx2][0] += normal[0];
|
|
505
|
-
normals[idx2][1] += normal[1];
|
|
506
|
-
normals[idx2][2] += normal[2];
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
// Normalize all normals
|
|
510
|
-
for (const normal of normals) {
|
|
511
|
-
const len = Math.sqrt(normal[0] ** 2 + normal[1] ** 2 + normal[2] ** 2);
|
|
512
|
-
if (len > 0) {
|
|
513
|
-
normal[0] /= len;
|
|
514
|
-
normal[1] /= len;
|
|
515
|
-
normal[2] /= len;
|
|
516
|
-
}
|
|
517
|
-
}
|
|
518
|
-
return normals;
|
|
519
|
-
}
|
|
1
|
+
// Re-export from shared location for backward compatibility
|
|
2
|
+
export { compute_vertex_normals, marching_cubes } from '../marching-cubes';
|
|
@@ -1,24 +1,15 @@
|
|
|
1
1
|
import * as constants from './constants';
|
|
2
2
|
import { compute_vertex_normals } from './marching-cubes';
|
|
3
|
+
function parse_number_tokens(line) {
|
|
4
|
+
return line.split(/\s+/).filter(Boolean);
|
|
5
|
+
}
|
|
3
6
|
// Parse whitespace-separated floats from a line (optimized with unary +)
|
|
4
7
|
function parse_floats(line) {
|
|
5
|
-
|
|
6
|
-
const result = [];
|
|
7
|
-
for (let idx = 0; idx < parts.length; idx++) {
|
|
8
|
-
if (parts[idx])
|
|
9
|
-
result.push(+parts[idx]);
|
|
10
|
-
}
|
|
11
|
-
return result;
|
|
8
|
+
return parse_number_tokens(line).map((part) => +part);
|
|
12
9
|
}
|
|
13
10
|
// Parse whitespace-separated integers from a line
|
|
14
11
|
function parse_ints(line) {
|
|
15
|
-
|
|
16
|
-
const result = [];
|
|
17
|
-
for (let idx = 0; idx < parts.length; idx++) {
|
|
18
|
-
if (parts[idx])
|
|
19
|
-
result.push(parseInt(parts[idx], 10));
|
|
20
|
-
}
|
|
21
|
-
return result;
|
|
12
|
+
return parse_number_tokens(line).map((part) => parseInt(part, 10));
|
|
22
13
|
}
|
|
23
14
|
// Parse BXSF (Band-XSF) format used by XCrySDen, Quantum ESPRESSO, etc.
|
|
24
15
|
// Format specification: http://www.xcrysden.org/doc/XSF.html
|
|
@@ -231,18 +222,21 @@ function parse_frmsf(content) {
|
|
|
231
222
|
function is_valid_isosurface(obj) {
|
|
232
223
|
if (!obj || typeof obj !== `object`)
|
|
233
224
|
return false;
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
225
|
+
const isosurface_obj = obj;
|
|
226
|
+
const vertices = isosurface_obj.vertices;
|
|
227
|
+
const faces = isosurface_obj.faces;
|
|
228
|
+
const normals = isosurface_obj.normals;
|
|
229
|
+
const band_index = isosurface_obj.band_index;
|
|
230
|
+
const spin = isosurface_obj.spin;
|
|
231
|
+
if (!Array.isArray(vertices) || vertices.length === 0)
|
|
237
232
|
return false;
|
|
238
|
-
if (!Array.isArray(
|
|
233
|
+
if (!Array.isArray(faces))
|
|
239
234
|
return false;
|
|
240
|
-
if (!Array.isArray(
|
|
235
|
+
if (!Array.isArray(normals))
|
|
241
236
|
return false;
|
|
242
|
-
|
|
243
|
-
if (typeof iso.band_index !== `number`)
|
|
237
|
+
if (typeof band_index !== `number` || !Number.isFinite(band_index))
|
|
244
238
|
return false;
|
|
245
|
-
if (
|
|
239
|
+
if (spin !== null && spin !== `up` && spin !== `down`)
|
|
246
240
|
return false;
|
|
247
241
|
return true;
|
|
248
242
|
}
|
|
@@ -389,7 +383,7 @@ function parse_ifermi_surface(data) {
|
|
|
389
383
|
e1[2] * e2[0] - e1[0] * e2[2],
|
|
390
384
|
e1[0] * e2[1] - e1[1] * e2[0],
|
|
391
385
|
];
|
|
392
|
-
area += 0.5 * Math.
|
|
386
|
+
area += 0.5 * Math.hypot(cross[0], cross[1], cross[2]);
|
|
393
387
|
}
|
|
394
388
|
}
|
|
395
389
|
isosurfaces.push({
|