@kitware/vtk.js 23.4.0 → 24.0.0-beta.1
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/BREAKING_CHANGES.md +33 -0
- package/Common/Core/DataArray.js +4 -0
- package/Common/Core/Math/index.js +2 -2
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/BoundingBox.js +3 -8
- package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
- package/Common/DataModel/ITKHelper.js +2 -346
- package/Common/DataModel/ImageData.d.ts +23 -6
- package/Common/DataModel/ImageData.js +8 -1
- package/Common/DataModel/PolyData.d.ts +8 -1
- package/Common/DataModel/PolyData.js +5 -3
- package/Common/DataModel/Triangle.js +217 -2
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1249 -0
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/General.js +2 -0
- package/Filters/Sources/CircleSource.js +1 -1
- package/Filters/Sources/PointSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.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/InteractorStyleImage.js +3 -3
- package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
- package/Interaction/Style/InteractorStyleManipulator.js +42 -28
- package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
- package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
- package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Interaction/Widgets.js +1 -35
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/InteractorObserver.js +11 -10
- package/Rendering/Core/InteractorStyle.js +9 -4
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Prop.js +6 -4
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +24 -17
- package/Rendering/Core/Renderer.js +24 -19
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/Viewport.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/OpenGL/Actor.js +2 -2
- package/Rendering/OpenGL/Actor2D.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +6 -5
- package/Rendering/OpenGL/Camera.js +3 -3
- package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
- package/Rendering/OpenGL/Framebuffer.js +13 -12
- package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
- package/Rendering/OpenGL/HardwareSelector.js +35 -25
- package/Rendering/OpenGL/ImageMapper.js +51 -45
- package/Rendering/OpenGL/ImageSlice.js +2 -2
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
- package/Rendering/OpenGL/PolyDataMapper.js +14 -11
- package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
- package/Rendering/OpenGL/Renderer.js +11 -7
- package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
- package/Rendering/OpenGL/ScalarBarActor.js +2 -2
- package/Rendering/OpenGL/ShaderCache.js +7 -5
- package/Rendering/OpenGL/Skybox.js +11 -9
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +2 -2
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
- package/Rendering/OpenGL/Texture.js +44 -31
- package/Rendering/OpenGL/VertexArrayObject.js +7 -7
- package/Rendering/OpenGL/Volume.js +3 -2
- package/Rendering/OpenGL/VolumeMapper.js +30 -26
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +8 -7
- package/Rendering/WebGPU/Renderer.js +18 -10
- package/Widgets/Core/AbstractWidget.js +5 -4
- package/Widgets/Core/AbstractWidgetFactory.js +2 -1
- package/Widgets/Core/WidgetManager.js +66 -49
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +1 -1
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
- package/Widgets/SVG/SVGRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/EllipseWidget.js +0 -1
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
- package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +79 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/LineWidget.js +0 -1
- package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
- package/Widgets/Widgets3D/RectangleWidget.js +0 -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 +18 -11
- package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
- package/index.d.ts +3 -4
- package/interfaces.d.ts +11 -0
- package/macros.d.ts +26 -1
- package/macros.js +51 -19
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/Interaction/Widgets/AbstractWidget.js +0 -104
- package/Interaction/Widgets/DistanceRepresentation.js +0 -116
- package/Interaction/Widgets/DistanceWidget.js +0 -77
- package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
- package/Interaction/Widgets/HandleRepresentation.js +0 -100
- package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
- package/Interaction/Widgets/HandleWidget.js +0 -194
- package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
- package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
- package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
- package/Interaction/Widgets/LabelRepresentation.js +0 -325
- package/Interaction/Widgets/LabelWidget.js +0 -65
- package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
- package/Interaction/Widgets/LineRepresentation.js +0 -498
- package/Interaction/Widgets/LineWidget/Constants.js +0 -11
- package/Interaction/Widgets/LineWidget.js +0 -296
- package/Interaction/Widgets/PointPlacer.js +0 -51
- package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
- package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
- package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
- package/Interaction/Widgets/WidgetRepresentation.js +0 -121
- package/Widgets/Representations/SphereContextRepresentation.js +0 -131
- package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
- package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
- package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
- package/Widgets/Widgets3D/SphereWidget.js +0 -62
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
2
|
import macro from '../../macros.js';
|
|
3
3
|
import vtkCell from './Cell.js';
|
|
4
|
-
import {
|
|
4
|
+
import { d as dot, j as cross, l as normalize, m as multiplyAccumulate, f as distance2BetweenPoints, o as determinant2x2 } from '../Core/Math/index.js';
|
|
5
5
|
import vtkLine from './Line.js';
|
|
6
6
|
import vtkPlane from './Plane.js';
|
|
7
7
|
|
|
@@ -33,6 +33,220 @@ function computeNormal(v1, v2, v3, n) {
|
|
|
33
33
|
n[1] /= length;
|
|
34
34
|
n[2] /= length;
|
|
35
35
|
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function intersectWithTriangle(p1, q1, r1, p2, q2, r2) {
|
|
39
|
+
var tolerance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1e-6;
|
|
40
|
+
var coplanar = false;
|
|
41
|
+
var pt1 = [];
|
|
42
|
+
var pt2 = [];
|
|
43
|
+
var surfaceId = [];
|
|
44
|
+
var n1 = [];
|
|
45
|
+
var n2 = []; // Compute supporting plane normals.
|
|
46
|
+
|
|
47
|
+
computeNormal(p1, q1, r1, n1);
|
|
48
|
+
computeNormal(p2, q2, r2, n2);
|
|
49
|
+
var s1 = -dot(n1, p1);
|
|
50
|
+
var s2 = -dot(n2, p2); // Compute signed distances of points p1, q1, r1 from supporting
|
|
51
|
+
// plane of second triangle.
|
|
52
|
+
|
|
53
|
+
var dist1 = [dot(n2, p1) + s2, dot(n2, q1) + s2, dot(n2, r1) + s2]; // If signs of all points are the same, all the points lie on the
|
|
54
|
+
// same side of the supporting plane, and we can exit early.
|
|
55
|
+
|
|
56
|
+
if (dist1[0] * dist1[1] > tolerance && dist1[0] * dist1[2] > tolerance) {
|
|
57
|
+
// vtkDebugMacro(<<"Same side supporting plane 1!");
|
|
58
|
+
return {
|
|
59
|
+
intersect: false,
|
|
60
|
+
coplanar: coplanar,
|
|
61
|
+
pt1: pt1,
|
|
62
|
+
pt2: pt2,
|
|
63
|
+
surfaceId: surfaceId
|
|
64
|
+
};
|
|
65
|
+
} // Do the same for p2, q2, r2 and supporting plane of first
|
|
66
|
+
// triangle.
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
var dist2 = [dot(n1, p2) + s1, dot(n1, q2) + s1, dot(n1, r2) + s1]; // If signs of all points are the same, all the points lie on the
|
|
70
|
+
// same side of the supporting plane, and we can exit early.
|
|
71
|
+
|
|
72
|
+
if (dist2[0] * dist2[1] > tolerance && dist2[0] * dist2[2] > tolerance) {
|
|
73
|
+
// vtkDebugMacro(<<"Same side supporting plane 2!");
|
|
74
|
+
return {
|
|
75
|
+
intersect: false,
|
|
76
|
+
coplanar: coplanar,
|
|
77
|
+
pt1: pt1,
|
|
78
|
+
pt2: pt2,
|
|
79
|
+
surfaceId: surfaceId
|
|
80
|
+
};
|
|
81
|
+
} // Check for coplanarity of the supporting planes.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
if (Math.abs(n1[0] - n2[0]) < 1e-9 && Math.abs(n1[1] - n2[1]) < 1e-9 && Math.abs(n1[2] - n2[2]) < 1e-9 && Math.abs(s1 - s2) < 1e-9) {
|
|
85
|
+
coplanar = true; // vtkDebugMacro(<<"Coplanar!");
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
intersect: false,
|
|
89
|
+
coplanar: coplanar,
|
|
90
|
+
pt1: pt1,
|
|
91
|
+
pt2: pt2,
|
|
92
|
+
surfaceId: surfaceId
|
|
93
|
+
};
|
|
94
|
+
} // There are more efficient ways to find the intersection line (if
|
|
95
|
+
// it exists), but this is clear enough.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
var pts1 = [p1, q1, r1];
|
|
99
|
+
var pts2 = [p2, q2, r2]; // Find line of intersection (L = p + t*v) between two planes.
|
|
100
|
+
|
|
101
|
+
var n1n2 = dot(n1, n2);
|
|
102
|
+
var a = (s1 - s2 * n1n2) / (n1n2 * n1n2 - 1.0);
|
|
103
|
+
var b = (s2 - s1 * n1n2) / (n1n2 * n1n2 - 1.0);
|
|
104
|
+
var p = [a * n1[0] + b * n2[0], a * n1[1] + b * n2[1], a * n1[2] + b * n2[2]];
|
|
105
|
+
var v = cross(n1, n2, []);
|
|
106
|
+
normalize(v);
|
|
107
|
+
var index1 = 0;
|
|
108
|
+
var index2 = 0;
|
|
109
|
+
var t1 = [];
|
|
110
|
+
var t2 = [];
|
|
111
|
+
var ts1 = 50;
|
|
112
|
+
var ts2 = 50;
|
|
113
|
+
|
|
114
|
+
for (var i = 0; i < 3; i++) {
|
|
115
|
+
var id1 = i;
|
|
116
|
+
var id2 = (i + 1) % 3; // Find t coordinate on line of intersection between two planes.
|
|
117
|
+
|
|
118
|
+
var val1 = vtkPlane.intersectWithLine(pts1[id1], pts1[id2], p2, n2);
|
|
119
|
+
|
|
120
|
+
if (val1.intersection && val1.t > 0 - tolerance && val1.t < 1 + tolerance) {
|
|
121
|
+
if (val1.t < 1 + tolerance && val1.t > 1 - tolerance) {
|
|
122
|
+
ts1 = index1;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
t1[index1++] = dot(val1.x, v) - dot(p, v);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
var val2 = vtkPlane.intersectWithLine(pts2[id1], pts2[id2], p1, n1);
|
|
129
|
+
|
|
130
|
+
if (val2.intersection && val2.t > 0 - tolerance && val2.t < 1 + tolerance) {
|
|
131
|
+
if (val2.t < 1 + tolerance && val2.t > 1 - tolerance) {
|
|
132
|
+
ts2 = index2;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
t2[index2++] = dot(val2.x, v) - dot(p, v);
|
|
136
|
+
}
|
|
137
|
+
} // If the value of the index is greater than 2, the intersecting point
|
|
138
|
+
// actually is intersected by all three edges. In this case, set the two
|
|
139
|
+
// edges to the two edges where the intersecting point is not the end point
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
if (index1 > 2) {
|
|
143
|
+
index1--; // swap
|
|
144
|
+
|
|
145
|
+
var t12 = t1[2];
|
|
146
|
+
t1[2] = t1[ts1];
|
|
147
|
+
t1[ts1] = t12;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (index2 > 2) {
|
|
151
|
+
index2--;
|
|
152
|
+
var t22 = t2[2];
|
|
153
|
+
t2[2] = t2[ts2];
|
|
154
|
+
t2[ts2] = t22;
|
|
155
|
+
} // Check if only one edge or all edges intersect the supporting
|
|
156
|
+
// planes intersection.
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
if (index1 !== 2 || index2 !== 2) {
|
|
160
|
+
// vtkDebugMacro(<<"Only one edge intersecting!");
|
|
161
|
+
return {
|
|
162
|
+
intersect: false,
|
|
163
|
+
coplanar: coplanar,
|
|
164
|
+
pt1: pt1,
|
|
165
|
+
pt2: pt2,
|
|
166
|
+
surfaceId: surfaceId
|
|
167
|
+
};
|
|
168
|
+
} // Check for NaNs
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
if (Number.isNaN(t1[0]) || Number.isNaN(t1[1]) || Number.isNaN(t2[0]) || Number.isNaN(t2[1])) {
|
|
172
|
+
// vtkWarningMacro(<<"NaNs!");
|
|
173
|
+
return {
|
|
174
|
+
intersect: false,
|
|
175
|
+
coplanar: coplanar,
|
|
176
|
+
pt1: pt1,
|
|
177
|
+
pt2: pt2,
|
|
178
|
+
surfaceId: surfaceId
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (t1[0] > t1[1]) {
|
|
183
|
+
// swap
|
|
184
|
+
var t11 = t1[1];
|
|
185
|
+
t1[1] = t1[0];
|
|
186
|
+
t1[0] = t11;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (t2[0] > t2[1]) {
|
|
190
|
+
// swap
|
|
191
|
+
var t21 = t2[1];
|
|
192
|
+
t2[1] = t2[0];
|
|
193
|
+
t2[0] = t21;
|
|
194
|
+
} // Handle the different interval configuration cases.
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
var tt1;
|
|
198
|
+
var tt2;
|
|
199
|
+
|
|
200
|
+
if (t1[1] < t2[0] || t2[1] < t1[0]) {
|
|
201
|
+
// vtkDebugMacro(<<"No Overlap!");
|
|
202
|
+
return {
|
|
203
|
+
intersect: false,
|
|
204
|
+
coplanar: coplanar,
|
|
205
|
+
pt1: pt1,
|
|
206
|
+
pt2: pt2,
|
|
207
|
+
surfaceId: surfaceId
|
|
208
|
+
}; // No overlap
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
if (t1[0] < t2[0]) {
|
|
212
|
+
if (t1[1] < t2[1]) {
|
|
213
|
+
// First point on surface 2, second point on surface 1
|
|
214
|
+
surfaceId[0] = 2;
|
|
215
|
+
surfaceId[1] = 1;
|
|
216
|
+
tt1 = t2[0];
|
|
217
|
+
tt2 = t1[1];
|
|
218
|
+
} else {
|
|
219
|
+
// Both points belong to lines on surface 2
|
|
220
|
+
surfaceId[0] = 2;
|
|
221
|
+
surfaceId[1] = 2;
|
|
222
|
+
tt1 = t2[0];
|
|
223
|
+
tt2 = t2[1];
|
|
224
|
+
}
|
|
225
|
+
} // t1[0] >= t2[0]
|
|
226
|
+
else if (t1[1] < t2[1]) {
|
|
227
|
+
// Both points belong to lines on surface 1
|
|
228
|
+
surfaceId[0] = 1;
|
|
229
|
+
surfaceId[1] = 1;
|
|
230
|
+
tt1 = t1[0];
|
|
231
|
+
tt2 = t1[1];
|
|
232
|
+
} else {
|
|
233
|
+
// First point on surface 1, second point on surface 2
|
|
234
|
+
surfaceId[0] = 1;
|
|
235
|
+
surfaceId[1] = 2;
|
|
236
|
+
tt1 = t1[0];
|
|
237
|
+
tt2 = t2[1];
|
|
238
|
+
} // Create actual intersection points.
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
multiplyAccumulate(p, v, tt1, pt1);
|
|
242
|
+
multiplyAccumulate(p, v, tt2, pt2);
|
|
243
|
+
return {
|
|
244
|
+
intersect: true,
|
|
245
|
+
coplanar: coplanar,
|
|
246
|
+
pt1: pt1,
|
|
247
|
+
pt2: pt2,
|
|
248
|
+
surfaceId: surfaceId
|
|
249
|
+
};
|
|
36
250
|
} // ----------------------------------------------------------------------------
|
|
37
251
|
// Static API
|
|
38
252
|
// ----------------------------------------------------------------------------
|
|
@@ -40,7 +254,8 @@ function computeNormal(v1, v2, v3, n) {
|
|
|
40
254
|
|
|
41
255
|
var STATIC = {
|
|
42
256
|
computeNormalDirection: computeNormalDirection,
|
|
43
|
-
computeNormal: computeNormal
|
|
257
|
+
computeNormal: computeNormal,
|
|
258
|
+
intersectWithTriangle: intersectWithTriangle
|
|
44
259
|
}; // ----------------------------------------------------------------------------
|
|
45
260
|
// vtkTriangle methods
|
|
46
261
|
// ----------------------------------------------------------------------------
|
|
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
|
2
2
|
import { mat4, mat3 } from 'gl-matrix';
|
|
3
3
|
import Constants from './LandmarkTransform/Constants.js';
|
|
4
4
|
import macro from '../../macros.js';
|
|
5
|
-
import {
|
|
5
|
+
import { p as jacobiN, q as perpendiculars } 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,82 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
2
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
3
|
+
import macro from '../../../macros.js';
|
|
4
|
+
|
|
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; }
|
|
6
|
+
|
|
7
|
+
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; }
|
|
8
|
+
// vtkOBBNode methods
|
|
9
|
+
// ----------------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
function vtkOBBNode(publicAPI, model) {
|
|
12
|
+
// Set our classname
|
|
13
|
+
model.classHierarchy.push('vtkOBBNode');
|
|
14
|
+
/**
|
|
15
|
+
* Copy a vtkOBBNode into an other one
|
|
16
|
+
* @param {vtkOBBNode} nodeSource
|
|
17
|
+
* @param {vtkOBBNode} nodeTarget
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
publicAPI.deepCopy = function (nodeSource) {
|
|
21
|
+
publicAPI.setCorner(nodeSource.getCorner());
|
|
22
|
+
var axes = nodeSource.getAxes();
|
|
23
|
+
publicAPI.setAxes([_toConsumableArray(axes[0]), _toConsumableArray(axes[1]), _toConsumableArray(axes[2])]);
|
|
24
|
+
publicAPI.setCells(_toConsumableArray(nodeSource.getCells()));
|
|
25
|
+
|
|
26
|
+
if (nodeSource.getKids()) {
|
|
27
|
+
var kids0 = vtkOBBNode.newInstance();
|
|
28
|
+
kids0.setParent(publicAPI);
|
|
29
|
+
var kids1 = vtkOBBNode.newInstance();
|
|
30
|
+
kids1.setParent(publicAPI);
|
|
31
|
+
kids0.deepCopy(nodeSource.getKids()[0]);
|
|
32
|
+
kids1.deepCopy(nodeSource.getKids()[1], kids1);
|
|
33
|
+
publicAPI.setKids(kids0, kids1);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
publicAPI.getAxis = function (axis) {
|
|
38
|
+
return model.axes[axis];
|
|
39
|
+
};
|
|
40
|
+
} // ----------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
function defaultValues(initialValues) {
|
|
44
|
+
return _objectSpread({
|
|
45
|
+
corner: [0, 0, 0],
|
|
46
|
+
// center point of this node
|
|
47
|
+
axes: [[0, 0, 0], [0, 0, 0], [0, 0, 0]],
|
|
48
|
+
// the axes defining the OBB - ordered from long->short
|
|
49
|
+
cells: []
|
|
50
|
+
}, initialValues);
|
|
51
|
+
} // ----------------------------------------------------------------------------
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
function extend(publicAPI, model) {
|
|
55
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
56
|
+
Object.assign(model, defaultValues(initialValues));
|
|
57
|
+
model.corner = [0, 0, 0];
|
|
58
|
+
model.axes = [[0, 0, 0], [0, 0, 0], [0, 0, 0]];
|
|
59
|
+
model.parent = null; // parent node; null if root
|
|
60
|
+
|
|
61
|
+
model.kids = null; // two children of this node; nullptr if leaf
|
|
62
|
+
|
|
63
|
+
model.cells = []; // list of cells in node
|
|
64
|
+
// Build VTK API
|
|
65
|
+
|
|
66
|
+
macro.setGet(publicAPI, model, ['parent', 'cells', 'kids']); // macro.setGetArray(publicAPI, model, ['kids'], 2);
|
|
67
|
+
|
|
68
|
+
macro.setGetArray(publicAPI, model, ['corner', 'axes'], 3); // Make this a VTK object
|
|
69
|
+
|
|
70
|
+
macro.obj(publicAPI, model); // Object specific methods
|
|
71
|
+
|
|
72
|
+
vtkOBBNode(publicAPI, model);
|
|
73
|
+
} // ----------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
var newInstance = macro.newInstance(extend, 'vtkOBBNode'); // ----------------------------------------------------------------------------
|
|
76
|
+
|
|
77
|
+
var vtkOBBNode$1 = {
|
|
78
|
+
newInstance: newInstance,
|
|
79
|
+
extend: extend
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export { vtkOBBNode$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CellType } from '../../../Common/DataModel/CellTypes/Constants.js';
|
|
2
|
+
import vtkOBJReader from '../../../IO/Misc/OBJReader.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Get the correct point ID from a cell id
|
|
6
|
+
* @param {Array} cellPtsIds
|
|
7
|
+
* @param {CellType} type
|
|
8
|
+
* @param {Number} idx
|
|
9
|
+
* @returns {Object} Contains three point's id of cells as 'ptId0', 'ptId1', 'ptId2'
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
function getCellTriangles(cellPtsIds, type, idx) {
|
|
13
|
+
var ptId0 = -1;
|
|
14
|
+
var ptId1 = -1;
|
|
15
|
+
var ptId2 = -1;
|
|
16
|
+
var cellListLength = cellPtsIds.length;
|
|
17
|
+
|
|
18
|
+
switch (type) {
|
|
19
|
+
case CellType.VTK_TRIANGLE:
|
|
20
|
+
case CellType.VTK_POLYGON:
|
|
21
|
+
case CellType.VTK_QUAD:
|
|
22
|
+
{
|
|
23
|
+
if (idx > cellListLength) break;
|
|
24
|
+
ptId0 = cellPtsIds[0];
|
|
25
|
+
ptId1 = cellPtsIds[idx + 1];
|
|
26
|
+
ptId2 = cellPtsIds[idx + 2];
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
case CellType.VTK_TRIANGLE_STRIP:
|
|
31
|
+
{
|
|
32
|
+
// eslint-disable-next-line no-bitwise
|
|
33
|
+
var idx1 = idx + 1 + (idx & 1); // eslint-disable-next-line no-bitwise
|
|
34
|
+
|
|
35
|
+
var idx2 = idx + 2 - (idx & 1);
|
|
36
|
+
if (idx1 > cellListLength || idx2 > cellListLength) break;
|
|
37
|
+
ptId0 = cellPtsIds[idx];
|
|
38
|
+
ptId1 = cellPtsIds[idx1];
|
|
39
|
+
ptId2 = cellPtsIds[idx2];
|
|
40
|
+
break;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
default:
|
|
44
|
+
ptId0 = -1;
|
|
45
|
+
ptId1 = -1;
|
|
46
|
+
ptId2 = -1;
|
|
47
|
+
break;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return {
|
|
51
|
+
ptId0: ptId0,
|
|
52
|
+
ptId1: ptId1,
|
|
53
|
+
ptId2: ptId2
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Concatenate second typed array to the first typed array.
|
|
58
|
+
* @param {TypedArray} first
|
|
59
|
+
* @param {TypedArray} second Must be of the same type as first
|
|
60
|
+
* @return {TypedArray}
|
|
61
|
+
*/
|
|
62
|
+
|
|
63
|
+
function pushArray(first, second) {
|
|
64
|
+
var firstLength = first.length;
|
|
65
|
+
var result = new first.constructor(firstLength + second.length);
|
|
66
|
+
result.set(first);
|
|
67
|
+
result.set(second, firstLength);
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Load an obj with point's colors
|
|
72
|
+
*
|
|
73
|
+
* @param {string} url path to the OBJ file
|
|
74
|
+
* @return Promise
|
|
75
|
+
* ---> success : Return vtkPolyData
|
|
76
|
+
* ---> failed : Error message
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
function loadOBJ(url) {
|
|
80
|
+
return new Promise(function (resolve, reject) {
|
|
81
|
+
var reader = vtkOBJReader.newInstance();
|
|
82
|
+
reader.setUrl(url).then(function () {
|
|
83
|
+
var data = reader.getOutputData();
|
|
84
|
+
resolve(data);
|
|
85
|
+
}, function () {
|
|
86
|
+
// eslint-disable-next-line prefer-promise-reject-errors
|
|
87
|
+
reject('Error when loading ', url);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export { getCellTriangles, loadOBJ, pushArray };
|