@kitware/vtk.js 23.4.3 → 23.4.4

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 (177) hide show
  1. package/Common/Core/Math/Constants.js +12 -0
  2. package/Common/Core/Math/index.js +1 -1
  3. package/Common/Core/Math.js +1 -1
  4. package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
  5. package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
  6. package/Common/DataModel/AbstractPointLocator.js +40 -0
  7. package/Common/DataModel/BoundingBox.d.ts +659 -0
  8. package/Common/DataModel/Collection.d.ts +118 -0
  9. package/Common/DataModel/Collection.js +113 -0
  10. package/Common/DataModel/DataSet/Constants.d.ts +27 -0
  11. package/Common/DataModel/EdgeLocator.d.ts +79 -0
  12. package/Common/DataModel/EdgeLocator.js +85 -0
  13. package/Common/DataModel/ITKHelper.d.ts +54 -0
  14. package/Common/DataModel/IncrementalOctreeNode.d.ts +297 -0
  15. package/Common/DataModel/IncrementalOctreeNode.js +640 -0
  16. package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
  17. package/Common/DataModel/IncrementalOctreePointLocator.js +398 -0
  18. package/Common/DataModel/Locator.d.ts +43 -0
  19. package/Common/DataModel/Locator.js +37 -0
  20. package/Common/DataModel/Plane.js +1 -1
  21. package/Common/DataModel/PolyData/Constants.d.ts +6 -0
  22. package/Common/DataModel/PolyLine.d.ts +63 -0
  23. package/Common/DataModel/PolyLine.js +77 -0
  24. package/Common/DataModel/Polygon/Constants.js +12 -0
  25. package/Common/DataModel/Polygon.js +1 -1
  26. package/Common/DataModel/Quad/Constants.js +9 -0
  27. package/Common/DataModel/Quad.d.ts +91 -0
  28. package/Common/DataModel/Quad.js +235 -0
  29. package/Common/DataModel/SelectionNode/Constants.d.ts +27 -0
  30. package/Common/DataModel/Spline1D/Constants.js +17 -0
  31. package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
  32. package/Common/Transform/Transform.js +51 -0
  33. package/Filters/Core/PolyDataNormals.js +124 -0
  34. package/Filters/General/ClipClosedSurface/Constants.js +10 -0
  35. package/Filters/General/ClipClosedSurface.d.ts +95 -0
  36. package/Filters/General/ClipClosedSurface.js +972 -0
  37. package/Filters/General/ContourTriangulator/Constants.js +6 -0
  38. package/Filters/General/ContourTriangulator/helper.js +1951 -0
  39. package/Filters/General/ContourTriangulator.d.ts +136 -0
  40. package/Filters/General/ContourTriangulator.js +202 -0
  41. package/Filters/General/ImageMarchingCubes.js +1 -1
  42. package/Filters/General/MoleculeToRepresentation.js +1 -1
  43. package/Filters/General/OBBTree/OBBNode.js +82 -0
  44. package/Filters/General/OBBTree/helper.js +92 -0
  45. package/Filters/General/OBBTree.js +1243 -0
  46. package/Filters/General/TubeFilter.js +1 -1
  47. package/Filters/Sources/LineSource.js +1 -1
  48. package/Filters/Sources/PlaneSource.js +1 -1
  49. package/Filters/Texture/TextureMapToPlane.js +1 -1
  50. package/Interaction/Manipulators/CompositeCameraManipulator.d.ts +68 -0
  51. package/Interaction/Manipulators/CompositeGestureManipulator.d.ts +168 -0
  52. package/Interaction/Manipulators/CompositeKeyboardManipulator.d.ts +48 -0
  53. package/Interaction/Manipulators/CompositeMouseManipulator.d.ts +149 -0
  54. package/Interaction/Manipulators/CompositeVRManipulator.d.ts +44 -0
  55. package/Interaction/Manipulators/GestureCameraManipulator.d.ts +34 -0
  56. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  57. package/Interaction/Manipulators/MouseBoxSelectorManipulator.d.ts +88 -0
  58. package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
  59. package/Interaction/Manipulators/MouseCameraTrackballMultiRotateManipulator.d.ts +32 -0
  60. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.d.ts +33 -0
  61. package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
  62. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.d.ts +33 -0
  63. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.d.ts +67 -0
  64. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  65. package/Interaction/Manipulators/MouseCameraTrackballZoomManipulator.d.ts +45 -0
  66. package/Interaction/Manipulators/MouseCameraTrackballZoomToMouseManipulator.d.ts +26 -0
  67. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  68. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  69. package/Interaction/Manipulators/MouseRangeManipulator.d.ts +53 -0
  70. package/Interaction/Style/InteractorStyleImage.d.ts +107 -0
  71. package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
  72. package/Interaction/Style/InteractorStyleManipulator.d.ts +348 -0
  73. package/Interaction/Style/InteractorStyleTrackballCamera.d.ts +170 -0
  74. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +1 -1
  75. package/Interaction/Widgets/LabelRepresentation.js +1 -1
  76. package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
  77. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +1 -1
  78. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +1 -1
  79. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +1 -1
  80. package/Proxy/Core/AbstractRepresentationProxy.d.ts +24 -0
  81. package/Proxy/Core/LookupTableProxy.d.ts +45 -0
  82. package/Proxy/Core/PiecewiseFunctionProxy.d.ts +62 -0
  83. package/Proxy/Core/ProxyManager.d.ts +115 -0
  84. package/Proxy/Core/SourceProxy.d.ts +22 -0
  85. package/Proxy/Core/View2DProxy.d.ts +7 -0
  86. package/Proxy/Core/View2DProxy.js +1 -1
  87. package/Proxy/Core/ViewProxy.d.ts +86 -0
  88. package/Proxy/Representations/SliceRepresentationProxy.d.ts +27 -0
  89. package/Proxy/Representations/VolumeRepresentationProxy.d.ts +44 -0
  90. package/README.md +2 -2
  91. package/Rendering/Core/AbstractImageMapper/helper.js +127 -0
  92. package/Rendering/Core/AbstractImageMapper.d.ts +82 -0
  93. package/Rendering/Core/AbstractImageMapper.js +44 -0
  94. package/Rendering/Core/Camera.js +1 -1
  95. package/Rendering/Core/CellPicker.js +1 -1
  96. package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
  97. package/Rendering/Core/ColorTransferFunction/Constants.d.ts +17 -0
  98. package/Rendering/Core/ColorTransferFunction.js +1 -1
  99. package/Rendering/Core/Coordinate/Constants.d.ts +14 -0
  100. package/Rendering/Core/Coordinate.js +1 -1
  101. package/Rendering/Core/Glyph3DMapper/Constants.d.ts +17 -0
  102. package/Rendering/Core/Glyph3DMapper.js +1 -1
  103. package/Rendering/Core/HardwareSelector.d.ts +84 -0
  104. package/Rendering/Core/ImageArrayMapper.d.ts +253 -0
  105. package/Rendering/Core/ImageArrayMapper.js +242 -0
  106. package/Rendering/Core/ImageMapper/Constants.d.ts +14 -0
  107. package/Rendering/Core/ImageMapper.js +1 -1
  108. package/Rendering/Core/ImageProperty/Constants.d.ts +9 -0
  109. package/Rendering/Core/ImageResliceMapper/Constants.d.ts +11 -0
  110. package/Rendering/Core/ImageResliceMapper/Constants.js +11 -0
  111. package/Rendering/Core/ImageResliceMapper.d.ts +245 -0
  112. package/Rendering/Core/ImageResliceMapper.js +70 -0
  113. package/Rendering/Core/InteractorObserver.d.ts +132 -0
  114. package/Rendering/Core/InteractorStyle/Constants.d.ts +16 -0
  115. package/Rendering/Core/InteractorStyle.d.ts +229 -0
  116. package/Rendering/Core/Light.js +1 -1
  117. package/Rendering/Core/Mapper/Constants.d.ts +26 -0
  118. package/Rendering/Core/Mapper.js +1 -1
  119. package/Rendering/Core/Picker.js +1 -1
  120. package/Rendering/Core/Prop/Constants.d.ts +9 -0
  121. package/Rendering/Core/Prop/Constants.js +9 -0
  122. package/Rendering/Core/Property/Constants.d.ts +24 -0
  123. package/Rendering/Core/Property2D/Constants.d.ts +9 -0
  124. package/Rendering/Core/RenderWindow.js +1 -1
  125. package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
  126. package/Rendering/Core/Renderer.js +1 -1
  127. package/Rendering/Core/VolumeMapper/Constants.d.ts +20 -0
  128. package/Rendering/Core/VolumeMapper.js +1 -1
  129. package/Rendering/Core/VolumeProperty/Constants.d.ts +16 -0
  130. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager/CameraSynchronizer.js +129 -0
  131. package/Rendering/Misc/SynchronizableRenderWindow/BehaviorManager.js +131 -0
  132. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.d.ts +80 -0
  133. package/Rendering/Misc/SynchronizableRenderWindow/ObjectManager.js +763 -0
  134. package/Rendering/OpenGL/HardwareSelector/Constants.d.ts +8 -0
  135. package/Rendering/OpenGL/HardwareSelector.d.ts +339 -0
  136. package/Rendering/OpenGL/ImageResliceMapper.js +996 -0
  137. package/Rendering/OpenGL/PolyDataMapper.js +1 -1
  138. package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
  139. package/Rendering/OpenGL/RenderWindow/Constants.d.ts +10 -0
  140. package/Rendering/OpenGL/RenderWindow/Constants.js +13 -0
  141. package/Rendering/OpenGL/RenderWindow/ContextProxy.js +70 -0
  142. package/Rendering/OpenGL/glsl/vtkImageResliceMapperFS.glsl.js +3 -0
  143. package/Rendering/OpenGL/glsl/vtkImageResliceMapperVS.glsl.js +3 -0
  144. package/Rendering/WebGPU/Actor2D.js +151 -0
  145. package/Rendering/WebGPU/BufferManager.js +1 -1
  146. package/Rendering/WebGPU/CellArrayMapper.js +853 -0
  147. package/Rendering/WebGPU/IndexBuffer.js +397 -0
  148. package/Rendering/WebGPU/PolyDataMapper2D.js +99 -0
  149. package/Rendering/WebGPU/SimpleMapper.js +290 -0
  150. package/Widgets/Core/AbstractWidget.d.ts +187 -0
  151. package/Widgets/Core/AbstractWidgetFactory.d.ts +131 -0
  152. package/Widgets/Core/StateBuilder/color3Mixin.js +24 -0
  153. package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
  154. package/Widgets/Core/StateBuilder.d.ts +29 -0
  155. package/Widgets/Core/WidgetManager/Constants.d.ts +27 -0
  156. package/Widgets/Core/WidgetManager.d.ts +231 -0
  157. package/Widgets/Core/WidgetState.d.ts +81 -0
  158. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  159. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  160. package/Widgets/Manipulators/LineManipulator.js +1 -1
  161. package/Widgets/Manipulators/TrackballManipulator.js +1 -1
  162. package/Widgets/Representations/GlyphRepresentation.js +325 -0
  163. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  164. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  165. package/Widgets/Representations/WidgetRepresentation.js +1 -1
  166. package/Widgets/Widgets3D/AngleWidget.js +1 -1
  167. package/Widgets/Widgets3D/InteractiveOrientationWidget.d.ts +40 -0
  168. package/Widgets/Widgets3D/LabelWidget/behavior.js +157 -0
  169. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  170. package/Widgets/Widgets3D/LabelWidget.js +78 -0
  171. package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
  172. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  173. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  174. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  175. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  176. package/index.d.ts +133 -74
  177. package/package.json +1 -1
@@ -0,0 +1,640 @@
1
+ import macro from '../../macros.js';
2
+ import { e as distance2BetweenPoints } from '../Core/Math/index.js';
3
+
4
+ var vtkErrorMacro = macro.vtkErrorMacro;
5
+ var OCTREENODE_INSERTPOINT = [function (points, pointIdx, coords) {
6
+ return pointIdx;
7
+ }, function (points, pointIdx, coords) {
8
+ points.setTuple(pointIdx, coords);
9
+ return pointIdx;
10
+ }, function (points, pointIdx, coords) {
11
+ return points.insertNextTuple(coords);
12
+ }]; // Given the index (0 ~ 7) of a child node, the spatial bounding axis (0 ~ 2
13
+ // for x, y, and z), and the value (0 ~ 1 for min and max) to access, this LUT
14
+ // allows for rapid assignment of its spatial bounding box --- MinBounds[3]
15
+ // and MaxBounds[3], with each specific value or entry of this LUT pointing to
16
+ // MinBounds[3] for 0, center point for 1, or MaxBounds[3] for 2.
17
+
18
+ var OCTREE_CHILD_BOUNDS_LUT = [[[0, 1], [0, 1], [0, 1]], [[1, 2], [0, 1], [0, 1]], [[0, 1], [1, 2], [0, 1]], [[1, 2], [1, 2], [0, 1]], [[0, 1], [0, 1], [1, 2]], [[1, 2], [0, 1], [1, 2]], [[0, 1], [1, 2], [1, 2]], [[1, 2], [1, 2], [1, 2]]];
19
+
20
+ function vtkIncrementalOctreeNode(publicAPI, model) {
21
+ // Set our className
22
+ model.classHierarchy.push('vtkIncrementalOctreeNode'); //------------------------------------------------------------------------------
23
+
24
+ publicAPI.createPointIdSet = function (initSize, growSize) {
25
+ if (model.pointIdSet == null) {
26
+ model.pointIdSet = []; // TODO: use initSize and growSize.
27
+ // model.pointIdSet.allocate(initSize, growSize);
28
+ }
29
+ }; //------------------------------------------------------------------------------
30
+
31
+
32
+ publicAPI.setBounds = function (x1, x2, y1, y2, z1, z2) {
33
+ if (model.minBounds == null) model.minBounds = [];
34
+ if (model.maxBounds == null) model.maxBounds = [];
35
+ if (model.minDataBounds == null) model.minDataBounds = [];
36
+ if (model.maxDataBounds == null) model.maxDataBounds = [];
37
+ model.minBounds[0] = x1;
38
+ model.maxBounds[0] = x2;
39
+ model.minBounds[1] = y1;
40
+ model.maxBounds[1] = y2;
41
+ model.minBounds[2] = z1;
42
+ model.maxBounds[2] = z2;
43
+ model.minDataBounds[0] = x2;
44
+ model.maxDataBounds[0] = x1;
45
+ model.minDataBounds[1] = y2;
46
+ model.maxDataBounds[1] = y1;
47
+ model.minDataBounds[2] = z2;
48
+ model.maxDataBounds[2] = z1;
49
+ }; //------------------------------------------------------------------------------
50
+
51
+
52
+ publicAPI.getBounds = function (bounds) {
53
+ bounds[0] = model.minBounds[0];
54
+ bounds[1] = model.maxBounds[0];
55
+ bounds[2] = model.minBounds[1];
56
+ bounds[3] = model.maxBounds[1];
57
+ bounds[4] = model.minBounds[2];
58
+ bounds[5] = model.maxBounds[2];
59
+ };
60
+
61
+ publicAPI.getChildIndex = function (point) {
62
+ return Number(point[0] > model.children[0].getMaxBoundsByReference()[0]) + ( // eslint-disable-next-line no-bitwise
63
+ Number(point[1] > model.children[0].getMaxBoundsByReference()[1]) << 1) + ( // eslint-disable-next-line no-bitwise
64
+ Number(point[2] > model.children[0].getMaxBoundsByReference()[2]) << 2);
65
+ };
66
+
67
+ publicAPI.containsPoint = function (pnt) {
68
+ return model.minBounds[0] < pnt[0] && pnt[0] <= model.maxBounds[0] && model.minBounds[1] < pnt[1] && pnt[1] <= model.maxBounds[1] && model.minBounds[2] < pnt[2] && pnt[2] <= model.maxBounds[2] ? 1 : 0;
69
+ };
70
+
71
+ publicAPI.containsPointByData = function (pnt) {
72
+ return model.minDataBounds[0] <= pnt[0] && pnt[0] <= model.maxDataBounds[0] && model.minDataBounds[1] <= pnt[1] && pnt[1] <= model.maxDataBounds[1] && model.minDataBounds[2] <= pnt[2] && pnt[2] <= model.maxDataBounds[2] ? 1 : 0;
73
+ }; //------------------------------------------------------------------------------
74
+
75
+
76
+ publicAPI.updateCounterAndDataBounds = function (point, nHits, updateData) {
77
+ model.numberOfPoints += nHits;
78
+ if (!updateData) return false;
79
+ var updated = false;
80
+
81
+ if (point[0] < model.minDataBounds[0]) {
82
+ updated = true;
83
+ model.minDataBounds[0] = point[0];
84
+ }
85
+
86
+ if (point[0] > model.maxDataBounds[0]) {
87
+ updated = true;
88
+ model.maxDataBounds[0] = point[0];
89
+ }
90
+
91
+ if (point[1] < model.minDataBounds[1]) {
92
+ updated = true;
93
+ model.minDataBounds[1] = point[1];
94
+ }
95
+
96
+ if (point[1] > model.maxDataBounds[1]) {
97
+ updated = true;
98
+ model.maxDataBounds[1] = point[1];
99
+ }
100
+
101
+ if (point[2] < model.minDataBounds[2]) {
102
+ updated = true;
103
+ model.minDataBounds[2] = point[2];
104
+ }
105
+
106
+ if (point[2] > model.maxDataBounds[2]) {
107
+ updated = true;
108
+ model.maxDataBounds[2] = point[2];
109
+ }
110
+
111
+ return updated;
112
+ }; //------------------------------------------------------------------------------
113
+
114
+
115
+ publicAPI.updateCounterAndDataBoundsRecursively = function (point, nHits, updateData, endNode) {
116
+ var updated = publicAPI.updateCounterAndDataBounds(point, nHits, updateData);
117
+ return model.parent === endNode ? updated : model.parent.updateCounterAndDataBoundsRecursively(point, nHits, updated, endNode);
118
+ }; //------------------------------------------------------------------------------
119
+
120
+
121
+ publicAPI.containsDuplicatePointsOnly = function (point) {
122
+ return model.minDataBounds[0] === point[0] && point[0] === model.maxDataBounds[0] && model.minDataBounds[1] === point[1] && point[1] === model.maxDataBounds[1] && model.minDataBounds[2] === point[2] && point[2] === model.maxDataBounds[2];
123
+ }; //------------------------------------------------------------------------------
124
+
125
+
126
+ publicAPI.isLeaf = function () {
127
+ return model.children == null;
128
+ }; //------------------------------------------------------------------------------
129
+
130
+
131
+ publicAPI.getChild = function (i) {
132
+ return model.children[i];
133
+ }; //------------------------------------------------------------------------------
134
+
135
+ /* eslint-disable no-use-before-define */
136
+
137
+
138
+ publicAPI.separateExactlyDuplicatePointsFromNewInsertion = function (points, pntIds, newPnt, pntIdx, maxPts, ptMode) {
139
+ // the number of points already maintained in this leaf node
140
+ // >= maxPts AND all of them are exactly duplicate with one another
141
+ // BUT the new point is not a duplicate of them any more
142
+ var pointIdx = pntIdx;
143
+ var i;
144
+ var dupPnt = [0.0, 0.0, 0.0];
145
+ var octMin = [0.0, 0.0, 0.0];
146
+ var octMid = [0.0, 0.0, 0.0];
147
+ var octMax = [0.0, 0.0, 0.0];
148
+ var boxPtr = [null, null, null];
149
+ var ocNode = null;
150
+ var duplic = publicAPI;
151
+ var single = publicAPI; // the coordinate of the duplicate points: note pntIds == model.pointIdSet
152
+
153
+ points.getPoint(pntIds[0], dupPnt);
154
+
155
+ while (duplic === single) {
156
+ // as long as separation has not been achieved
157
+ // update the current (in recursion) node and access the bounding box info
158
+ ocNode = duplic;
159
+ octMid[0] = (ocNode.minBounds[0] + ocNode.maxBounds[0]) * 0.5;
160
+ octMid[1] = (ocNode.minBounds[1] + ocNode.maxBounds[1]) * 0.5;
161
+ octMid[2] = (ocNode.minBounds[2] + ocNode.maxBounds[2]) * 0.5;
162
+ boxPtr[0] = ocNode.minBounds;
163
+ boxPtr[1] = octMid;
164
+ boxPtr[2] = ocNode.maxBounds; // create eight child nodes
165
+ // FIXME: May be too slow to use vtk newInstance()
166
+
167
+ ocNode.children = [newInstance(), newInstance(), newInstance(), newInstance(), newInstance(), newInstance(), newInstance(), newInstance()];
168
+
169
+ for (i = 0; i < 8; i++) {
170
+ // x-bound: axis 0
171
+ octMin[0] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][0][0]][0];
172
+ octMax[0] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][0][1]][0]; // y-bound: axis 1
173
+
174
+ octMin[1] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][1][0]][1];
175
+ octMax[1] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][1][1]][1]; // z-bound: axis 2
176
+
177
+ octMin[2] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][2][0]][2];
178
+ octMax[2] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][2][1]][2];
179
+ ocNode.children[i] = newInstance();
180
+ ocNode.children[i].setParent(ocNode);
181
+ ocNode.children[i].setBounds(octMin[0], octMax[0], octMin[1], octMax[1], octMin[2], octMax[2]);
182
+ } // determine the leaf node of the duplicate points & that of the new point
183
+
184
+
185
+ duplic = ocNode.children[ocNode.getChildIndex(dupPnt)];
186
+ single = ocNode.children[ocNode.getChildIndex(newPnt)];
187
+ } // Now the duplicate points have been separated from the new point //
188
+ // create a vtkIdList object for the new point
189
+ // update the counter and the data bounding box until the root node
190
+ // (including the root node)
191
+
192
+
193
+ pointIdx = OCTREENODE_INSERTPOINT[ptMode](points, pointIdx, newPnt); // eslint-disable-next-line no-bitwise
194
+
195
+ single.createPointIdSet(maxPts >> 2, maxPts >> 1);
196
+ single.getPointIdSet().push(pointIdx);
197
+ single.updateCounterAndDataBoundsRecursively(newPnt, 1, 1, null); // We just need to reference pntIds while un-registering it from 'this'.
198
+ // This avoids deep-copying point ids from pntIds to duplic's PointIdSet.
199
+ // update the counter and the data bounding box, but until 'this' node
200
+ // (excluding 'this' node)
201
+
202
+ duplic.setPointIdSet(pntIds);
203
+ duplic.updateCounterAndDataBoundsRecursively(dupPnt, pntIds.length, 1, publicAPI);
204
+ return pointIdx;
205
+ };
206
+ /* eslint-enable no-use-before-define */
207
+ //------------------------------------------------------------------------------
208
+
209
+
210
+ publicAPI.createChildNodes = function (points, pntIds, newPnt, pntIdx, maxPts, ptMode, numberOfNodes) {
211
+ // There are two scenarios for which this function is invoked.
212
+ //
213
+ // (1) the number of points already maintained in this leaf node
214
+ // == maxPts AND not all of them are exactly duplicate
215
+ // AND the new point is not a duplicate of them all
216
+ // (2) the number of points already maintained in this leaf node
217
+ // >= maxPts AND all of them are exactly duplicate with one another
218
+ // BUT the new point is not a duplicate of them any more
219
+ // address case (2) first if necessary
220
+ var nbNodes = numberOfNodes;
221
+ var pointIdx = pntIdx;
222
+ var sample = [];
223
+ points.getPoint(pntIds[0], sample);
224
+
225
+ if (publicAPI.containsDuplicatePointsOnly(sample)) {
226
+ pointIdx = publicAPI.separateExactlyDuplicatePointsFromNewInsertion(points, pntIds, newPnt, pointIdx, maxPts, ptMode);
227
+ return {
228
+ success: false,
229
+ nbNodes: nbNodes,
230
+ pointIdx: pointIdx
231
+ };
232
+ } // then address case (1) below
233
+
234
+
235
+ var i;
236
+ var target;
237
+ var dvidId = -1; // index of the sub-dividing octant, if any
238
+
239
+ var fullId = -1; // index of the full octant, if any
240
+
241
+ var numIds = [0, 0, 0, 0, 0, 0, 0, 0];
242
+ var octMin = [];
243
+ var octMax = [];
244
+ var tempPt = [];
245
+ var tempId;
246
+ var octMid = [(model.minBounds[0] + model.maxBounds[0]) * 0.5, (model.minBounds[1] + model.maxBounds[1]) * 0.5, (model.minBounds[2] + model.maxBounds[2]) * 0.5];
247
+ var boxPtr = [model.minBounds, octMid, model.maxBounds]; // create eight child nodes
248
+
249
+ model.children = [];
250
+
251
+ for (i = 0; i < 8; i++) {
252
+ // x-bound: axis 0
253
+ octMin[0] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][0][0]][0];
254
+ octMax[0] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][0][1]][0]; // y-bound: axis 1
255
+
256
+ octMin[1] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][1][0]][1];
257
+ octMax[1] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][1][1]][1]; // z-bound: axis 2
258
+
259
+ octMin[2] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][2][0]][2];
260
+ octMax[2] = boxPtr[OCTREE_CHILD_BOUNDS_LUT[i][2][1]][2]; // This call internally sets the cener and default data bounding box, too.
261
+ // eslint-disable-next-line no-use-before-define
262
+
263
+ model.children[i] = newInstance(); // model.children[i].iD = nbNodes++;
264
+
265
+ model.children[i].setParent(publicAPI);
266
+ model.children[i].setBounds(octMin[0], octMax[0], octMin[1], octMax[1], octMin[2], octMax[2]); // allocate a list of point-indices (size = 2^n) for index registration
267
+ // eslint-disable-next-line no-bitwise
268
+
269
+ model.children[i].createPointIdSet(maxPts >> 2, maxPts >> 1);
270
+ }
271
+
272
+ boxPtr[0] = null;
273
+ boxPtr[1] = null;
274
+ boxPtr[2] = null; // distribute the available point-indices to the eight child nodes
275
+
276
+ for (i = 0; i < maxPts; i++) {
277
+ tempId = pntIds[i];
278
+ points.getPoint(tempId, tempPt);
279
+ target = publicAPI.getChildIndex(tempPt);
280
+ model.children[target].getPointIdSet().push(tempId);
281
+ model.children[target].updateCounterAndDataBounds(tempPt);
282
+ numIds[target]++;
283
+ } // locate the full child, just if any
284
+
285
+
286
+ for (i = 0; i < 8; i++) {
287
+ if (numIds[i] === maxPts) {
288
+ fullId = i;
289
+ break;
290
+ }
291
+ }
292
+
293
+ target = publicAPI.getChildIndex(newPnt);
294
+
295
+ if (fullId === target) {
296
+ // The fact is that we are going to insert the new point to an already
297
+ // full octant (child node). Thus we need to further divide this child
298
+ // to avoid the overflow problem.
299
+ var _model$children$targe = model.children[target].createChildNodes(points, pntIds, newPnt, pointIdx, maxPts, ptMode, nbNodes);
300
+
301
+ nbNodes = _model$children$targe.numberOfNodes;
302
+ pointIdx = _model$children$targe.pointIdx;
303
+ dvidId = fullId;
304
+ } else {
305
+ // the initial division is a success
306
+ pointIdx = OCTREENODE_INSERTPOINT[ptMode](points, pointIdx, newPnt);
307
+ model.children[target].getPointIdSet().push(pointIdx);
308
+ model.children[target].updateCounterAndDataBoundsRecursively(newPnt, 1, 1, null); // NOTE: The counter below might reach the threshold, though we delay the
309
+ // sub-division of this child node until the next point insertion occurs.
310
+
311
+ numIds[target]++;
312
+ } // Now it is time to reclaim those un-used vtkIdList objects, of which each
313
+ // either is empty or still needs to be deleted due to further division of
314
+ // the child node. This post-deallocation of the un-used vtkIdList objects
315
+ // (of some child nodes) is based on the assumption that retrieving the
316
+ // 'maxPts' points from vtkPoints and the associated 'maxPts' point-indices
317
+ // from vtkIdList is more expensive than reclaiming at most 8 vtkIdList
318
+ // objects at hand.
319
+
320
+
321
+ for (i = 0; i < 8; i++) {
322
+ if (numIds[i] === 0 || i === dvidId) {
323
+ model.children[i].getPointIdSet().length = 0;
324
+ }
325
+ } // notify vtkIncrementalOctreeNode::InsertPoint() to destroy pntIds
326
+
327
+
328
+ return {
329
+ success: true,
330
+ numberOfNodes: nbNodes,
331
+ pointIdx: pointIdx
332
+ };
333
+ }; //------------------------------------------------------------------------------
334
+
335
+
336
+ publicAPI.insertPoint = function (points, newPnt, maxPts, pntId, ptMode, numberOfNodes) {
337
+ var nbNodes = 0;
338
+ var pointIdx = pntId;
339
+
340
+ if (model.pointIdSet) {
341
+ // there has been at least one point index
342
+ if (model.pointIdSet.length < maxPts || publicAPI.containsDuplicatePointsOnly(newPnt)) {
343
+ // this leaf node is not full or
344
+ // this leaf node is full, but of all exactly duplicate points
345
+ // and the point under check is another duplicate of these points
346
+ pointIdx = OCTREENODE_INSERTPOINT[ptMode](points, pointIdx, newPnt);
347
+ model.pointIdSet.push(pointIdx);
348
+ publicAPI.updateCounterAndDataBoundsRecursively(newPnt, 1, 1, null);
349
+ } else {
350
+ // overflow: divide this node and delete the list of point-indices.
351
+ // Note that the number of exactly duplicate points might be greater
352
+ // than or equal to maxPts.
353
+ var _publicAPI$createChil = publicAPI.createChildNodes(points, model.pointIdSet, newPnt, pointIdx, maxPts, ptMode, numberOfNodes);
354
+
355
+ nbNodes = _publicAPI$createChil.numberOfNodes;
356
+ pointIdx = _publicAPI$createChil.pointIdx;
357
+ model.pointIdSet = null;
358
+ }
359
+ } else {
360
+ // There has been no any point index registered in this leaf node
361
+ pointIdx = OCTREENODE_INSERTPOINT[ptMode](points, pointIdx, newPnt);
362
+ model.pointIdSet = [];
363
+ model.pointIdSet.push(pointIdx);
364
+ publicAPI.updateCounterAndDataBoundsRecursively(newPnt, 1, 1, null);
365
+ }
366
+
367
+ return {
368
+ numberOfNodes: numberOfNodes + nbNodes,
369
+ pointIdx: pointIdx
370
+ };
371
+ }; //------------------------------------------------------------------------------
372
+
373
+
374
+ publicAPI.getDistance2ToBoundary = function (point, closest, innerOnly, rootNode, checkData) {
375
+ // It is mandatory that GetMinDataBounds() and GetMaxDataBounds() be used.
376
+ // Direct access to MinDataBounds and MaxDataBounds might incur problems.
377
+ var thisMin = null;
378
+ var thisMax = null;
379
+ var rootMin = null;
380
+ var rootMax = null; // TODO: Check
381
+ // let minDist = VTK_DOUBLE_MAX;
382
+
383
+ var minDist = Number.MAX_VALUE; // minimum distance to the boundaries
384
+
385
+ if (checkData) {
386
+ thisMin = publicAPI.getMinDataBounds();
387
+ thisMax = publicAPI.getMaxDataBounds();
388
+ rootMin = rootNode.getMinDataBounds();
389
+ rootMax = rootNode.getMaxDataBounds();
390
+ } else {
391
+ thisMin = model.minBounds;
392
+ thisMax = model.maxBounds;
393
+ rootMin = rootNode.getMinBounds();
394
+ rootMax = rootNode.getMaxBounds();
395
+ }
396
+
397
+ var minFace = 0; // index of the face with min distance to the point
398
+
399
+ var beXless = Number(point[0] < thisMin[0]);
400
+ var beXmore = Number(point[0] > thisMax[0]);
401
+ var beYless = Number(point[1] < thisMin[1]);
402
+ var beYmore = Number(point[1] > thisMax[1]);
403
+ var beZless = Number(point[2] < thisMin[2]);
404
+ var beZmore = Number(point[2] > thisMax[2]);
405
+ var withinX = Number(!beXless && !beXmore);
406
+ var withinY = Number(!beYless && !beYmore);
407
+ var withinZ = Number(!beZless && !beZmore); // eslint-disable-next-line no-bitwise
408
+
409
+ var xyzFlag = (withinZ << 2) + (withinY << 1) + withinX;
410
+
411
+ switch (xyzFlag) {
412
+ case 0:
413
+ {
414
+ // withinZ = 0; withinY = 0; withinX = 0
415
+ // closest to a corner
416
+ closest[0] = beXless ? thisMin[0] : thisMax[0];
417
+ closest[1] = beYless ? thisMin[1] : thisMax[1];
418
+ closest[2] = beZless ? thisMin[2] : thisMax[2];
419
+ minDist = distance2BetweenPoints(point, closest);
420
+ break;
421
+ }
422
+
423
+ case 1:
424
+ {
425
+ // withinZ = 0; withinY = 0; withinX = 1
426
+ // closest to an x-aligned edge
427
+ closest[0] = point[0];
428
+ closest[1] = beYless ? thisMin[1] : thisMax[1];
429
+ closest[2] = beZless ? thisMin[2] : thisMax[2];
430
+ minDist = distance2BetweenPoints(point, closest);
431
+ break;
432
+ }
433
+
434
+ case 2:
435
+ {
436
+ // withinZ = 0; withinY = 1; withinX = 0
437
+ // closest to a y-aligned edge
438
+ closest[0] = beXless ? thisMin[0] : thisMax[0];
439
+ closest[1] = point[1];
440
+ closest[2] = beZless ? thisMin[2] : thisMax[2];
441
+ minDist = distance2BetweenPoints(point, closest);
442
+ break;
443
+ }
444
+
445
+ case 3:
446
+ {
447
+ // withinZ = 0; withinY = 1; withinX = 1
448
+ // closest to a z-face
449
+ if (beZless) {
450
+ minDist = thisMin[2] - point[2];
451
+ closest[2] = thisMin[2];
452
+ } else {
453
+ minDist = point[2] - thisMax[2];
454
+ closest[2] = thisMax[2];
455
+ }
456
+
457
+ minDist *= minDist;
458
+ closest[0] = point[0];
459
+ closest[1] = point[1];
460
+ break;
461
+ }
462
+
463
+ case 4:
464
+ {
465
+ // withinZ = 1; withinY = 0; withinX = 0
466
+ // cloest to a z-aligned edge
467
+ closest[0] = beXless ? thisMin[0] : thisMax[0];
468
+ closest[1] = beYless ? thisMin[1] : thisMax[1];
469
+ closest[2] = point[2];
470
+ minDist = distance2BetweenPoints(point, closest);
471
+ break;
472
+ }
473
+
474
+ case 5:
475
+ {
476
+ // withinZ = 1; withinY = 0; withinX = 1
477
+ // closest to a y-face
478
+ if (beYless) {
479
+ minDist = thisMin[1] - point[1];
480
+ closest[1] = thisMin[1];
481
+ } else {
482
+ minDist = point[1] - thisMax[1];
483
+ closest[1] = thisMax[1];
484
+ }
485
+
486
+ minDist *= minDist;
487
+ closest[0] = point[0];
488
+ closest[2] = point[2];
489
+ break;
490
+ }
491
+
492
+ case 6:
493
+ {
494
+ // withinZ = 1; withinY = 1; withinX = 0
495
+ // closest to an x-face
496
+ if (beXless) {
497
+ minDist = thisMin[0] - point[0];
498
+ closest[0] = thisMin[0];
499
+ } else {
500
+ minDist = point[0] - thisMax[0];
501
+ closest[0] = thisMax[0];
502
+ }
503
+
504
+ minDist *= minDist;
505
+ closest[1] = point[1];
506
+ closest[2] = point[2];
507
+ break;
508
+ }
509
+
510
+ case 7:
511
+ {
512
+ // withinZ = 1; withinY = 1; withinZ = 1
513
+ // point is inside the box
514
+ if (innerOnly) {
515
+ // check only inner boundaries
516
+ var faceDst;
517
+ faceDst = point[0] - thisMin[0]; // x-min face
518
+
519
+ if (thisMin[0] !== rootMin[0] && faceDst < minDist) {
520
+ minFace = 0;
521
+ minDist = faceDst;
522
+ }
523
+
524
+ faceDst = thisMax[0] - point[0]; // x-max face
525
+
526
+ if (thisMax[0] !== rootMax[0] && faceDst < minDist) {
527
+ minFace = 1;
528
+ minDist = faceDst;
529
+ }
530
+
531
+ faceDst = point[1] - thisMin[1]; // y-min face
532
+
533
+ if (thisMin[1] !== rootMin[1] && faceDst < minDist) {
534
+ minFace = 2;
535
+ minDist = faceDst;
536
+ }
537
+
538
+ faceDst = thisMax[1] - point[1]; // y-max face
539
+
540
+ if (thisMax[1] !== rootMax[1] && faceDst < minDist) {
541
+ minFace = 3;
542
+ minDist = faceDst;
543
+ }
544
+
545
+ faceDst = point[2] - thisMin[2]; // z-min face
546
+
547
+ if (thisMin[2] !== rootMin[2] && faceDst < minDist) {
548
+ minFace = 4;
549
+ minDist = faceDst;
550
+ }
551
+
552
+ faceDst = thisMax[2] - point[2]; // z-max face
553
+
554
+ if (thisMax[2] !== rootMax[2] && faceDst < minDist) {
555
+ minFace = 5;
556
+ minDist = faceDst;
557
+ }
558
+ } else {
559
+ // check all boundaries
560
+ var tmpDist = [point[0] - thisMin[0], thisMax[0] - point[0], point[1] - thisMin[1], thisMax[1] - point[1], point[2] - thisMin[2], thisMax[2] - point[2]];
561
+
562
+ for (var i = 0; i < 6; i++) {
563
+ if (tmpDist[i] < minDist) {
564
+ minFace = i;
565
+ minDist = tmpDist[i];
566
+ }
567
+ }
568
+ } // no square operation if no any inner boundary
569
+
570
+
571
+ if (minDist !== Number.MAX_VALUE) {
572
+ minDist *= minDist;
573
+ }
574
+
575
+ closest[0] = point[0];
576
+ closest[1] = point[1];
577
+ closest[2] = point[2]; // minFace: the quad with the min distance to the point
578
+ // 0: x-min face ===> xyzIndx = 0: x and minFace & 1 = 0: thisMin
579
+ // 1: x-max face ===> xyzIndx = 0: x and minFace & 1 = 1: thisMax
580
+ // 2: y-min face ===> xyzIndx = 1: y and minFace & 1 = 0: thisMin
581
+ // 3: y-max face ===> xyzIndx = 1: y and minFace & 1 = 1: thisMax
582
+ // 4: z-min face ===> xyzIndx = 2: z and minFace & 1 = 0: thisMin
583
+ // 5: z-max face ===> xyzIndx = 2: z and minFace & 1 = 1: thisMax
584
+
585
+ var pMinMax = [thisMin, thisMax]; // eslint-disable-next-line no-bitwise
586
+
587
+ var xyzIndx = minFace >> 1; // eslint-disable-next-line no-bitwise
588
+
589
+ closest[xyzIndx] = pMinMax[minFace & 1][xyzIndx];
590
+ break;
591
+ }
592
+
593
+ default:
594
+ vtkErrorMacro('unexpected case in getDistance2ToBoundary');
595
+ }
596
+
597
+ return minDist;
598
+ }; //------------------------------------------------------------------------------
599
+
600
+
601
+ publicAPI.getDistance2ToInnerBoundary = function (point, rootNode) {
602
+ var dummy = [];
603
+ return publicAPI.getDistance2ToBoundary(point, dummy, 0, rootNode, 0);
604
+ };
605
+ } // ----------------------------------------------------------------------------
606
+ // Object factory
607
+ // ----------------------------------------------------------------------------
608
+
609
+
610
+ var DEFAULT_VALUES = {
611
+ pointIdSet: null,
612
+ minBounds: null,
613
+ maxBounds: null,
614
+ minDataBounds: null,
615
+ maxDataBounds: null,
616
+ parent: null,
617
+ children: null
618
+ }; // ----------------------------------------------------------------------------
619
+
620
+ function extend(publicAPI, model) {
621
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
622
+ Object.assign(model, DEFAULT_VALUES, initialValues); // Make this a VTK object
623
+
624
+ macro.obj(publicAPI, model);
625
+ macro.setGetArray(publicAPI, model, ['minBounds', 'maxBounds', 'minDataBounds', 'maxDataBounds'], 6);
626
+ macro.get(publicAPI, model, ['pointIdSet', 'numberOfPoints']); // TODO: No get?
627
+
628
+ macro.set(publicAPI, model, ['parent']); // Object specific methods
629
+
630
+ vtkIncrementalOctreeNode(publicAPI, model);
631
+ } // ----------------------------------------------------------------------------
632
+
633
+ var newInstance = macro.newInstance(extend, 'vtkIncrementalOctreeNode'); // ----------------------------------------------------------------------------
634
+
635
+ var vtkIncrementalOctreeNode$1 = {
636
+ newInstance: newInstance,
637
+ extend: extend
638
+ };
639
+
640
+ export { vtkIncrementalOctreeNode$1 as default, extend, newInstance };
@@ -0,0 +1,61 @@
1
+ import { vtkObject } from './../../interfaces';
2
+ import vtkPoints from './../Core/Points';
3
+ import vtkIncrementalOctreeNode from './IncrementalOctreeNode';
4
+ import { IAbstractPointLocatorInitialValues } from './AbstractPointLocator';
5
+
6
+ /**
7
+ *
8
+ */
9
+ export interface IIncrementalOctreePointLocatorInitialValues
10
+ extends IAbstractPointLocatorInitialValues {
11
+ fudgeFactor: number;
12
+ octreeMaxDimSize: number;
13
+ buildCubicOctree: boolean;
14
+ maxPointsPerLeaf: number;
15
+ insertTolerance2: number;
16
+ locatorPoints: vtkPoints;
17
+ octreeRootNode: vtkIncrementalOctreeNode;
18
+ numberOfNodes: number;
19
+ }
20
+
21
+ type vtkIncrementalOctreePointLocatorBase = vtkObject;
22
+
23
+ export interface vtkIncrementalOctreePointLocator
24
+ extends vtkIncrementalOctreePointLocatorBase {}
25
+
26
+ // ----------------------------------------------------------------------------
27
+ // Static API
28
+ // ----------------------------------------------------------------------------
29
+
30
+ /**
31
+ * Method use to decorate a given object (publicAPI+model) with vtkIncrementalOctreePointLocator characteristics.
32
+ *
33
+ * @param publicAPI object on which methods will be bounds (public)
34
+ * @param model object on which data structure will be bounds (protected)
35
+ * @param {object} [initialValues] (default: {})
36
+ */
37
+ export function extend(
38
+ publicAPI: object,
39
+ model: object,
40
+ initialValues?: IIncrementalOctreePointLocatorInitialValues
41
+ ): void;
42
+
43
+ // ----------------------------------------------------------------------------
44
+
45
+ /**
46
+ * Method use to create a new instance of vtkIncrementalOctreePointLocator
47
+ * @param {IIncrementalOctreePointLocatorInitialValues} [initialValues] for pre-setting some of its content
48
+ */
49
+ export function newInstance(
50
+ initialValues?: IIncrementalOctreePointLocatorInitialValues
51
+ ): vtkIncrementalOctreePointLocator;
52
+
53
+ /**
54
+ * vtkIncrementalOctreePointLocator
55
+ */
56
+ export declare const vtkIncrementalOctreePointLocator: {
57
+ newInstance: typeof newInstance;
58
+ extend: typeof extend;
59
+ };
60
+
61
+ export default vtkIncrementalOctreePointLocator;