@kitware/vtk.js 25.4.0 → 25.7.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.
- package/Common/Core/CellArray.d.ts +20 -8
- package/Common/Core/CellArray.js +25 -6
- package/Common/Core/DataArray.d.ts +159 -15
- package/Common/Core/DataArray.js +181 -26
- package/Common/Core/Math/index.js +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/Core/Points.d.ts +6 -5
- package/Common/Core/Points.js +8 -4
- package/Common/DataModel/AbstractPointLocator.d.ts +54 -0
- package/Common/DataModel/AbstractPointLocator.js +40 -0
- package/Common/DataModel/DataSetAttributes/FieldData.d.ts +33 -22
- package/Common/DataModel/DataSetAttributes/FieldData.js +91 -9
- package/Common/DataModel/DataSetAttributes.d.ts +44 -0
- package/Common/DataModel/DataSetAttributes.js +11 -0
- package/Common/DataModel/IncrementalOctreeNode.d.ts +282 -0
- package/Common/DataModel/IncrementalOctreeNode.js +621 -0
- package/Common/DataModel/IncrementalOctreePointLocator.d.ts +61 -0
- package/Common/DataModel/IncrementalOctreePointLocator.js +342 -0
- package/Common/DataModel/Line.js +1 -1
- package/Common/DataModel/Locator.d.ts +43 -0
- package/Common/DataModel/Locator.js +37 -0
- package/Common/DataModel/Plane.js +1 -1
- package/Common/DataModel/Polygon/Constants.js +12 -0
- package/Common/DataModel/Polygon.d.ts +38 -4
- package/Common/DataModel/Polygon.js +210 -6
- package/Common/DataModel/Quad/Constants.js +9 -0
- package/Common/DataModel/Quad.d.ts +91 -0
- package/Common/DataModel/Quad.js +235 -0
- package/Common/DataModel/Triangle.d.ts +106 -81
- package/Common/DataModel/Triangle.js +1 -1
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/Core/PolyDataNormals.js +1 -1
- package/Filters/General/ClipClosedSurface/Constants.js +10 -0
- package/Filters/General/ClipClosedSurface/ccsEdgeLocator.js +40 -0
- package/Filters/General/ClipClosedSurface.d.ts +95 -0
- package/Filters/General/ClipClosedSurface.js +970 -0
- package/Filters/General/ContourTriangulator/Constants.js +6 -0
- package/Filters/General/ContourTriangulator/helper.js +1951 -0
- package/Filters/General/ContourTriangulator.d.ts +122 -0
- package/Filters/General/ContourTriangulator.js +200 -0
- package/Filters/General/ImageMarchingCubes.js +1 -1
- package/Filters/General/MoleculeToRepresentation.js +1 -1
- package/Filters/General/OBBTree.js +1 -1
- package/Filters/General/TubeFilter.js +1 -1
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/Sources/PlaneSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/IO/Core/DataAccessHelper/HtmlDataAccessHelper.js +4 -8
- package/IO/Core/DataAccessHelper/HttpDataAccessHelper.js +6 -14
- package/IO/Core/DataAccessHelper/JSZipDataAccessHelper.js +60 -57
- package/IO/Core/ZipMultiDataSetReader.js +19 -29
- package/IO/Core/ZipMultiDataSetWriter.js +7 -23
- package/IO/Misc/SkyboxReader.js +67 -75
- package/IO/XML/XMLReader.js +2 -2
- package/IO/XML/XMLWriter.js +2 -2
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraAxisRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballPanManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleMPRSlice.js +1 -1
- package/Interaction/Style/InteractorStyleTrackballCamera.js +16 -0
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/Actor2D.d.ts +12 -6
- package/Rendering/Core/Camera.js +1 -1
- package/Rendering/Core/CellPicker.js +3 -2
- package/Rendering/Core/ColorTransferFunction/ColorMaps.d.ts +24 -0
- package/Rendering/Core/Light.js +1 -1
- package/Rendering/Core/Picker.js +1 -1
- package/Rendering/Core/Property2D.d.ts +1 -1
- package/Rendering/Core/VolumeProperty.d.ts +4 -4
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper.js +1 -1
- package/Rendering/OpenGL/RenderWindow/ContextProxy.js +65 -0
- package/Rendering/OpenGL/RenderWindow.js +3 -1
- package/Rendering/WebGPU/BufferManager.js +1 -1
- package/Rendering/WebGPU/ForwardPass.js +93 -15
- package/Rendering/WebGPU/OpaquePass.js +1 -1
- package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
- package/Rendering/WebGPU/RenderEncoder.js +9 -5
- package/Rendering/WebGPU/RenderWindow.js +15 -13
- package/Rendering/WebGPU/TextureView.js +15 -2
- package/Rendering/WebGPU/VolumePass.js +1 -1
- package/Widgets/Core/StateBuilder/orientationMixin.js +1 -1
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Manipulators/TrackballManipulator.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
- package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +1 -1
- package/index.d.ts +8 -0
- package/index.js +0 -2
- package/package.json +3 -4
- package/ThirdParty/index.js +0 -9
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
|
|
3
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
4
|
+
import macro from '../../macros.js';
|
|
5
|
+
import { g as vtkMath } from '../Core/Math/index.js';
|
|
6
|
+
import vtkBoundingBox from './BoundingBox.js';
|
|
7
|
+
import vtkIncrementalOctreeNode from './IncrementalOctreeNode.js';
|
|
8
|
+
import vtkAbstractPointLocator from './AbstractPointLocator.js';
|
|
9
|
+
import { VtkDataTypes } from '../Core/DataArray/Constants.js';
|
|
10
|
+
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
var vtkErrorMacro = macro.vtkErrorMacro;
|
|
15
|
+
|
|
16
|
+
function vtkIncrementalOctreePointLocator(publicAPI, model) {
|
|
17
|
+
// Set our className
|
|
18
|
+
model.classHierarchy.push('vtkIncrementalOctreePointLocator');
|
|
19
|
+
|
|
20
|
+
function getLeafContainer(node, pnt) {
|
|
21
|
+
return node.isLeaf() ? node : getLeafContainer(node.getChild(node.getChildIndex(pnt)), pnt);
|
|
22
|
+
} //------------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
publicAPI.freeSearchStructure = function () {
|
|
26
|
+
model.octreeRootNode = null;
|
|
27
|
+
model.numberOfNodes = 0;
|
|
28
|
+
model.locatorPoints = null;
|
|
29
|
+
}; //------------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
publicAPI.findClosestPointInLeafNode = function (leafNode, point) {
|
|
33
|
+
// NOTE: dist2 MUST be initiated with a very huge value below, but instead of
|
|
34
|
+
// model.octreeMaxDimSize * model.octreeMaxDimSize * 4.0, because the point
|
|
35
|
+
// under check may be outside the octree and hence the squared distance can
|
|
36
|
+
// be greater than the latter or other similar octree-based specific values.
|
|
37
|
+
var dist2 = Number.MAX_VALUE;
|
|
38
|
+
|
|
39
|
+
if (leafNode.getPointIdSet() == null) {
|
|
40
|
+
return [-1, dist2];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
var numPts = 0;
|
|
44
|
+
var tmpDst = 0.0;
|
|
45
|
+
var tmpPnt = [];
|
|
46
|
+
var tmpIdx = -1;
|
|
47
|
+
var pntIdx = -1;
|
|
48
|
+
var idList = leafNode.getPointIdSet();
|
|
49
|
+
numPts = idList.length;
|
|
50
|
+
|
|
51
|
+
for (var i = 0; i < numPts; i++) {
|
|
52
|
+
tmpIdx = idList[i];
|
|
53
|
+
model.locatorPoints.getPoint(tmpIdx, tmpPnt);
|
|
54
|
+
tmpDst = vtkMath.distance2BetweenPoints(tmpPnt, point);
|
|
55
|
+
|
|
56
|
+
if (tmpDst < dist2) {
|
|
57
|
+
dist2 = tmpDst;
|
|
58
|
+
pntIdx = tmpIdx;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (dist2 === 0.0) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
idList = null;
|
|
67
|
+
return [pntIdx, dist2];
|
|
68
|
+
}; //------------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
publicAPI.initPointInsertion = function (points, bounds) {
|
|
72
|
+
var _model$octreeRootNode;
|
|
73
|
+
var i = 0;
|
|
74
|
+
var bbIndex = 0;
|
|
75
|
+
|
|
76
|
+
if (points == null) {
|
|
77
|
+
vtkErrorMacro('a valid vtkPoints object required for point insertion');
|
|
78
|
+
return false;
|
|
79
|
+
} // destroy the existing octree, if any
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
publicAPI.freeSearchStructure();
|
|
83
|
+
model.locatorPoints = points; // obtain the threshold squared distance
|
|
84
|
+
|
|
85
|
+
model.insertTolerance2 = model.tolerance * model.tolerance; // Fix bounds
|
|
86
|
+
// (1) push out a little bit if the original volume is too flat --- a slab
|
|
87
|
+
// (2) pull back the x, y, and z's lower bounds a little bit such that
|
|
88
|
+
// points are clearly "inside" the spatial region. Point p is taken as
|
|
89
|
+
// "inside" range r = [r1, r2] if and only if r1 < p <= r2.
|
|
90
|
+
|
|
91
|
+
model.octreeMaxDimSize = 0.0;
|
|
92
|
+
|
|
93
|
+
var tmpBbox = _toConsumableArray(bounds);
|
|
94
|
+
|
|
95
|
+
var dimDiff = vtkBoundingBox.getLengths(bounds);
|
|
96
|
+
model.octreeMaxDimSize = Math.max.apply(Math, _toConsumableArray(dimDiff));
|
|
97
|
+
|
|
98
|
+
if (model.buildCubicOctree) {
|
|
99
|
+
// make the bounding box a cube and hence descendant octants cubes too
|
|
100
|
+
for (i = 0; i < 3; i++) {
|
|
101
|
+
if (dimDiff[i] !== model.octreeMaxDimSize) {
|
|
102
|
+
var delta = model.octreeMaxDimSize - dimDiff[i];
|
|
103
|
+
tmpBbox[2 * i] -= 0.5 * delta;
|
|
104
|
+
tmpBbox[2 * i + 1] += 0.5 * delta;
|
|
105
|
+
dimDiff[i] = model.octreeMaxDimSize;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
model.fudgeFactor = model.octreeMaxDimSize * 10e-6;
|
|
111
|
+
var minSideSize = model.octreeMaxDimSize * 10e-2;
|
|
112
|
+
|
|
113
|
+
for (i = 0; i < 3; i++) {
|
|
114
|
+
if (dimDiff[i] < minSideSize) {
|
|
115
|
+
// case (1) above
|
|
116
|
+
bbIndex = 2 * i;
|
|
117
|
+
var tempVal = tmpBbox[bbIndex];
|
|
118
|
+
tmpBbox[bbIndex] = tmpBbox[bbIndex + 1] - minSideSize;
|
|
119
|
+
tmpBbox[bbIndex + 1] = tempVal + minSideSize;
|
|
120
|
+
} else {
|
|
121
|
+
// case (2) above
|
|
122
|
+
tmpBbox[2 * i] -= model.fudgeFactor;
|
|
123
|
+
}
|
|
124
|
+
} // init the octree with an empty leaf node
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
model.octreeRootNode = vtkIncrementalOctreeNode.newInstance();
|
|
128
|
+
++model.numberOfNodes; // this call internally inits the middle (center) and data range, too
|
|
129
|
+
|
|
130
|
+
(_model$octreeRootNode = model.octreeRootNode).setBounds.apply(_model$octreeRootNode, _toConsumableArray(tmpBbox));
|
|
131
|
+
|
|
132
|
+
return true;
|
|
133
|
+
}; //------------------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
publicAPI.findDuplicateFloatTypePointInVisitedLeafNode = function (leafNode, point) {
|
|
137
|
+
var tmpPnt;
|
|
138
|
+
var tmpIdx = -1;
|
|
139
|
+
var pntIdx = -1; // float thePnt[3]; // TODO
|
|
140
|
+
// thePnt[0] = static_cast<float>(point[0]);
|
|
141
|
+
// thePnt[1] = static_cast<float>(point[1]);
|
|
142
|
+
// thePnt[2] = static_cast<float>(point[2]);
|
|
143
|
+
|
|
144
|
+
var idList = leafNode.getPointIdSet(); // float* pFloat = (static_cast<vtkFloatArray*>(model.locatorPoints.getData())).getPointer(0);
|
|
145
|
+
|
|
146
|
+
var values = model.locatorPoints.getData();
|
|
147
|
+
|
|
148
|
+
for (var i = 0; i < idList.length; i++) {
|
|
149
|
+
tmpIdx = idList[i]; // eslint-disable-next-line no-bitwise
|
|
150
|
+
|
|
151
|
+
tmpPnt = (tmpIdx << 1) + tmpIdx;
|
|
152
|
+
|
|
153
|
+
if (point[0] === values[tmpPnt] && point[1] === values[tmpPnt + 1] && point[2] === values[tmpPnt + 2]) {
|
|
154
|
+
pntIdx = tmpIdx;
|
|
155
|
+
break;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
return pntIdx;
|
|
160
|
+
}; //------------------------------------------------------------------------------
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
publicAPI.findDuplicateDoubleTypePointInVisitedLeafNode = function (leafNode, point) {
|
|
164
|
+
var tmpPnt;
|
|
165
|
+
var tmpIdx = -1;
|
|
166
|
+
var pntIdx = -1;
|
|
167
|
+
var idList = leafNode.getPointIdSet();
|
|
168
|
+
var values = model.locatorPoints.getData();
|
|
169
|
+
|
|
170
|
+
for (var i = 0; i < idList.length; i++) {
|
|
171
|
+
tmpIdx = idList[i]; // eslint-disable-next-line no-bitwise
|
|
172
|
+
|
|
173
|
+
tmpPnt = (tmpIdx << 1) + tmpIdx;
|
|
174
|
+
|
|
175
|
+
if (point[0] === values[tmpPnt] && point[1] === values[tmpPnt + 1] && point[2] === values[tmpPnt + 2]) {
|
|
176
|
+
pntIdx = tmpIdx;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return pntIdx;
|
|
182
|
+
}; //------------------------------------------------------------------------------
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
publicAPI.findDuplicatePointInLeafNode = function (leafNode, point) {
|
|
186
|
+
if (leafNode.getPointIdSet() == null) {
|
|
187
|
+
return -1;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return model.locatorPoints.getDataType() === VtkDataTypes.FLOAT ? publicAPI.findDuplicateFloatTypePointInVisitedLeafNode(leafNode, point) : publicAPI.findDuplicateDoubleTypePointInVisitedLeafNode(leafNode, point);
|
|
191
|
+
}; //------------------------------------------------------------------------------
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
publicAPI.insertPoint = function (ptId, x) {
|
|
195
|
+
var leafcontainer = getLeafContainer(model.octreeRootNode, x);
|
|
196
|
+
|
|
197
|
+
var _leafcontainer$insert = leafcontainer.insertPoint(model.locatorPoints, x, model.maxPointsPerLeaf, ptId, 1, model.numberOfNodes);
|
|
198
|
+
|
|
199
|
+
model.numberOfNodes = _leafcontainer$insert.numberOfNodes;
|
|
200
|
+
}; //------------------------------------------------------------------------------
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
publicAPI.insertUniquePoint = function (point) {
|
|
204
|
+
// TODO: We have a mix of let and const here.
|
|
205
|
+
// eslint-disable-next-line prefer-const
|
|
206
|
+
var _publicAPI$isInserted = publicAPI.isInsertedPoint(point),
|
|
207
|
+
pointIdx = _publicAPI$isInserted.pointIdx,
|
|
208
|
+
leafContainer = _publicAPI$isInserted.leafContainer;
|
|
209
|
+
|
|
210
|
+
if (pointIdx > -1) {
|
|
211
|
+
return {
|
|
212
|
+
success: false,
|
|
213
|
+
idx: pointIdx
|
|
214
|
+
};
|
|
215
|
+
} // TODO: pointIdx
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
var numberOfNodes; // eslint-disable-next-line prefer-const
|
|
219
|
+
|
|
220
|
+
var _leafContainer$insert = leafContainer.insertPoint(model.locatorPoints, point, model.maxPointsPerLeaf, pointIdx, 2, model.numberOfNodes);
|
|
221
|
+
|
|
222
|
+
numberOfNodes = _leafContainer$insert.numberOfNodes;
|
|
223
|
+
pointIdx = _leafContainer$insert.pointIdx;
|
|
224
|
+
model.numberOfNodes = numberOfNodes;
|
|
225
|
+
return {
|
|
226
|
+
success: true,
|
|
227
|
+
idx: pointIdx
|
|
228
|
+
};
|
|
229
|
+
}; //------------------------------------------------------------------------------
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
publicAPI.insertNextPoint = function (x) {
|
|
233
|
+
var leafContainer = getLeafContainer(model.octreeRootNode, x);
|
|
234
|
+
|
|
235
|
+
var _leafContainer$insert2 = leafContainer.insertPoint(model.locatorPoints, x, model.maxPointsPerLeaf, -1, 2, model.numberOfNodes),
|
|
236
|
+
numberOfNodes = _leafContainer$insert2.numberOfNodes,
|
|
237
|
+
pointIdx = _leafContainer$insert2.pointIdx;
|
|
238
|
+
|
|
239
|
+
model.numberOfNodes = numberOfNodes;
|
|
240
|
+
return pointIdx;
|
|
241
|
+
}; //------------------------------------------------------------------------------
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
publicAPI.isInsertedPointForZeroTolerance = function (x) {
|
|
245
|
+
// the target leaf node always exists there since the root node of the
|
|
246
|
+
// octree has been initialized to cover all possible points to be inserted
|
|
247
|
+
// and therefore we do not need to check it here
|
|
248
|
+
var leafContainer = getLeafContainer(model.octreeRootNode, x);
|
|
249
|
+
var pointIdx = publicAPI.findDuplicatePointInLeafNode(leafContainer, x);
|
|
250
|
+
return {
|
|
251
|
+
pointIdx: pointIdx,
|
|
252
|
+
leafContainer: leafContainer
|
|
253
|
+
};
|
|
254
|
+
}; //------------------------------------------------------------------------------
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
publicAPI.isInsertedPointForNonZeroTolerance = function (x) {
|
|
258
|
+
// minDist2 // min distance to ALL existing points
|
|
259
|
+
// elseDst2 // min distance to other nodes (inner boundaries)
|
|
260
|
+
var dist2Ext; // min distance to an EXTended set of nodes
|
|
261
|
+
|
|
262
|
+
var pntIdExt; // the target leaf node always exists there since the root node of the
|
|
263
|
+
// octree has been initialized to cover all possible points to be inserted
|
|
264
|
+
// and therefore we do not need to check it here
|
|
265
|
+
|
|
266
|
+
var leafContainer = getLeafContainer(model.octreeRootNode, x);
|
|
267
|
+
|
|
268
|
+
var _publicAPI$findCloses = publicAPI.findClosestPointInLeafNode(leafContainer, x),
|
|
269
|
+
_publicAPI$findCloses2 = _slicedToArray(_publicAPI$findCloses, 2),
|
|
270
|
+
pointIdx = _publicAPI$findCloses2[0],
|
|
271
|
+
minDist2 = _publicAPI$findCloses2[1];
|
|
272
|
+
|
|
273
|
+
if (minDist2 === 0.0) {
|
|
274
|
+
return {
|
|
275
|
+
pointIdx: pointIdx,
|
|
276
|
+
leafContainer: leafContainer
|
|
277
|
+
};
|
|
278
|
+
} // As no any 'duplicate' point exists in this leaf node, we need to expand
|
|
279
|
+
// the search scope to capture possible closer points in other nodes.
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
var elseDst2 = leafContainer.getDistance2ToInnerBoundary(x, model.octreeRootNode);
|
|
283
|
+
|
|
284
|
+
if (elseDst2 < model.insertTolerance2) {
|
|
285
|
+
// one or multiple closer points might exist in the neighboring nodes
|
|
286
|
+
// TODO: dist2Ext
|
|
287
|
+
pntIdExt = publicAPI.findClosestPointInSphereWithTolerance(x, model.insertTolerance2, leafContainer, dist2Ext);
|
|
288
|
+
|
|
289
|
+
if (dist2Ext < minDist2) {
|
|
290
|
+
minDist2 = dist2Ext;
|
|
291
|
+
pointIdx = pntIdExt;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
pointIdx = minDist2 <= model.insertTolerance2 ? pointIdx : -1;
|
|
296
|
+
return {
|
|
297
|
+
pointIdx: pointIdx,
|
|
298
|
+
leafContainer: leafContainer
|
|
299
|
+
};
|
|
300
|
+
}; //------------------------------------------------------------------------------
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
publicAPI.isInsertedPoint = function (x, leafContainer) {
|
|
304
|
+
return model.insertTolerance2 === 0.0 ? publicAPI.isInsertedPointForZeroTolerance(x, leafContainer) : publicAPI.isInsertedPointForNonZeroTolerance(x, leafContainer);
|
|
305
|
+
};
|
|
306
|
+
} // ----------------------------------------------------------------------------
|
|
307
|
+
// Object factory
|
|
308
|
+
// ----------------------------------------------------------------------------
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
function defaultValues(initialValues) {
|
|
312
|
+
return _objectSpread({
|
|
313
|
+
fudgeFactor: 0,
|
|
314
|
+
octreeMaxDimSize: 0,
|
|
315
|
+
buildCubicOctree: false,
|
|
316
|
+
maxPointsPerLeaf: 128,
|
|
317
|
+
insertTolerance2: 0.000001,
|
|
318
|
+
locatorPoints: null,
|
|
319
|
+
octreeRootNode: null,
|
|
320
|
+
numberOfNodes: 0
|
|
321
|
+
}, initialValues);
|
|
322
|
+
} // ----------------------------------------------------------------------------
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
function extend(publicAPI, model) {
|
|
326
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
327
|
+
vtkAbstractPointLocator.extend(publicAPI, model, defaultValues(initialValues)); // Make this a VTK object
|
|
328
|
+
|
|
329
|
+
macro.obj(publicAPI, model);
|
|
330
|
+
macro.setGet(publicAPI, model, ['fudgeFactor', 'octreeMaxDimSize', 'buildCubicOctree', 'maxPointsPerLeaf', 'insertTolerance2', 'locatorPoints', 'octreeRootNode', 'numberOfNodes']); // Object specific methods
|
|
331
|
+
|
|
332
|
+
vtkIncrementalOctreePointLocator(publicAPI, model);
|
|
333
|
+
} // ----------------------------------------------------------------------------
|
|
334
|
+
|
|
335
|
+
var newInstance = macro.newInstance(extend, 'vtkIncrementalOctreePointLocator'); // ----------------------------------------------------------------------------
|
|
336
|
+
|
|
337
|
+
var vtkIncrementalOctreePointLocator$1 = {
|
|
338
|
+
newInstance: newInstance,
|
|
339
|
+
extend: extend
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
export { vtkIncrementalOctreePointLocator$1 as default, extend, newInstance };
|
package/Common/DataModel/Line.js
CHANGED
|
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import Constants from './Line/Constants.js';
|
|
4
4
|
import vtkCell from './Cell.js';
|
|
5
|
-
import { d as dot, f as distance2BetweenPoints, s as subtract,
|
|
5
|
+
import { d as dot, f as distance2BetweenPoints, s as subtract, j as solveLinearSystem } from '../Core/Math/index.js';
|
|
6
6
|
|
|
7
7
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
8
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { vtkObject } from './../../interfaces';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
export interface ILocatorInitialValues {
|
|
7
|
+
dataSet?: number[];
|
|
8
|
+
maxLevel?: number;
|
|
9
|
+
level?: number;
|
|
10
|
+
automatic?: boolean;
|
|
11
|
+
tolerance?: number;
|
|
12
|
+
useExistingSearchStructure?: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface vtkLocator extends vtkObject {}
|
|
16
|
+
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
// Static API
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Method use to decorate a given object (publicAPI+model) with vtkLocator characteristics.
|
|
23
|
+
*
|
|
24
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
25
|
+
* @param model object on which data structure will be bounds (protected)
|
|
26
|
+
* @param {ILocatorInitialValues} [initialValues] (default: {})
|
|
27
|
+
*/
|
|
28
|
+
export function extend(
|
|
29
|
+
publicAPI: object,
|
|
30
|
+
model: object,
|
|
31
|
+
initialValues?: ILocatorInitialValues
|
|
32
|
+
): void;
|
|
33
|
+
|
|
34
|
+
// ----------------------------------------------------------------------------
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* vtkLocator
|
|
38
|
+
*/
|
|
39
|
+
export declare const vtkLocator: {
|
|
40
|
+
extend: typeof extend;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default vtkLocator;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import macro from '../../macros.js';
|
|
2
|
+
|
|
3
|
+
function vtkLocator(publicAPI, model) {
|
|
4
|
+
// Set our className
|
|
5
|
+
model.classHierarchy.push('vtkLocator');
|
|
6
|
+
} // ----------------------------------------------------------------------------
|
|
7
|
+
// Object factory
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var DEFAULT_VALUES = {
|
|
12
|
+
dataSet: null,
|
|
13
|
+
maxLevel: 8,
|
|
14
|
+
// TODO: clamp 0, Number.MAX_VALUE
|
|
15
|
+
level: 8,
|
|
16
|
+
automatic: false,
|
|
17
|
+
tolerance: 0.0,
|
|
18
|
+
// TODO: clamp 0.0, Number.MAX_VALUE
|
|
19
|
+
useExistingSearchStructure: false
|
|
20
|
+
}; // ----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
function extend(publicAPI, model) {
|
|
23
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
24
|
+
Object.assign(model, DEFAULT_VALUES, initialValues); // Make this a VTK object
|
|
25
|
+
|
|
26
|
+
macro.obj(publicAPI, model);
|
|
27
|
+
macro.get(publicAPI, model, ['level']);
|
|
28
|
+
macro.setGet(publicAPI, model, ['dataSet', 'maxLevel', 'automatic', 'tolerance', 'useExistingSearchStructure']); // Object specific methods
|
|
29
|
+
|
|
30
|
+
vtkLocator(publicAPI, model);
|
|
31
|
+
} // ----------------------------------------------------------------------------
|
|
32
|
+
|
|
33
|
+
var vtkLocator$1 = {
|
|
34
|
+
extend: extend
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export { vtkLocator$1 as default, extend };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
-
import { s as subtract, d as dot,
|
|
2
|
+
import { s as subtract, d as dot, k as cross, l as add } from '../Core/Math/index.js';
|
|
3
3
|
import macro from '../../macros.js';
|
|
4
4
|
|
|
5
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var EPSILON = 1e-6;
|
|
2
|
+
var FLOAT_EPSILON = 1.1920929e-7;
|
|
3
|
+
var TOLERANCE = 1e-8;
|
|
4
|
+
var PolygonWithPointIntersectionState = {
|
|
5
|
+
FAILURE: -1,
|
|
6
|
+
OUTSIDE: 0,
|
|
7
|
+
INSIDE: 1,
|
|
8
|
+
INTERSECTION: 2,
|
|
9
|
+
ON_LINE: 3
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { EPSILON, FLOAT_EPSILON, PolygonWithPointIntersectionState, TOLERANCE };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { vtkObject } from './../../interfaces'
|
|
2
|
-
import { Vector3 } from './../../types';
|
|
3
|
-
|
|
1
|
+
import { vtkObject } from './../../interfaces';
|
|
2
|
+
import { Bounds, TypedArray, Vector3 } from './../../types';
|
|
4
3
|
|
|
5
4
|
export interface IPolygonInitialValues {
|
|
6
5
|
firstPoint?: Vector3,
|
|
@@ -8,6 +7,17 @@ export interface IPolygonInitialValues {
|
|
|
8
7
|
tris?: Vector3[],
|
|
9
8
|
}
|
|
10
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Different states which pointInPolygon could return.
|
|
12
|
+
*/
|
|
13
|
+
export enum PolygonIntersectionState {
|
|
14
|
+
FAILURE,
|
|
15
|
+
OUTSIDE,
|
|
16
|
+
INSIDE,
|
|
17
|
+
INTERSECTION,
|
|
18
|
+
ON_LINE,
|
|
19
|
+
}
|
|
20
|
+
|
|
11
21
|
export interface vtkPolygon extends vtkObject {
|
|
12
22
|
|
|
13
23
|
/**
|
|
@@ -16,7 +26,7 @@ export interface vtkPolygon extends vtkObject {
|
|
|
16
26
|
getPointArray(): Vector3[];
|
|
17
27
|
|
|
18
28
|
/**
|
|
19
|
-
* Set the polygon's points
|
|
29
|
+
* Set the polygon's points.
|
|
20
30
|
* @param {Vector3[]} points The polygon's points.
|
|
21
31
|
*/
|
|
22
32
|
setPoints(points: Vector3[]): void;
|
|
@@ -28,8 +38,30 @@ export interface vtkPolygon extends vtkObject {
|
|
|
28
38
|
* defines one triangle.
|
|
29
39
|
*/
|
|
30
40
|
triangulate(): void;
|
|
41
|
+
|
|
31
42
|
}
|
|
32
43
|
|
|
44
|
+
/**
|
|
45
|
+
* Determine whether a point is inside a polygon. The function uses a winding
|
|
46
|
+
* number calculation generalized to the 3D plane one which the polygon
|
|
47
|
+
* resides. Returns 0 if point is not in the polygon; 1 if it is inside. Can
|
|
48
|
+
* also return -1 to indicate a degenerate polygon. This implementation is
|
|
49
|
+
* inspired by Dan Sunday's algorithm found in the book Practical Geometry
|
|
50
|
+
* Algorithms.
|
|
51
|
+
*
|
|
52
|
+
* @param {Vector3} point Point to check
|
|
53
|
+
* @param {Array<Number>|TypedArray} vertices Vertices of the polygon
|
|
54
|
+
* @param {Bounds} bounds Bounds of the vertices
|
|
55
|
+
* @param {Vector3} normal Normal vector of the polygon
|
|
56
|
+
* @returns {PolygonIntersectionState} Integer indicating the type of intersection
|
|
57
|
+
*/
|
|
58
|
+
export function pointInPolygon(
|
|
59
|
+
point: Vector3,
|
|
60
|
+
vertices: Array<number>|TypedArray,
|
|
61
|
+
bounds: Bounds,
|
|
62
|
+
normal: Vector3
|
|
63
|
+
): PolygonIntersectionState;
|
|
64
|
+
|
|
33
65
|
/**
|
|
34
66
|
* Method used to decorate a given object (publicAPI+model) with vtkPolygon characteristics.
|
|
35
67
|
*
|
|
@@ -55,5 +87,7 @@ export function newInstance(initialValues?: IPolygonInitialValues): vtkPolygon;
|
|
|
55
87
|
export declare const vtkPolygon: {
|
|
56
88
|
newInstance: typeof newInstance,
|
|
57
89
|
extend: typeof extend;
|
|
90
|
+
// static
|
|
91
|
+
|
|
58
92
|
};
|
|
59
93
|
export default vtkPolygon;
|