@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
|
@@ -1,15 +1,219 @@
|
|
|
1
|
+
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
1
2
|
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
3
|
import macro from '../../macros.js';
|
|
3
|
-
import {
|
|
4
|
+
import { d as dot, s as subtract, k as cross, l as add, m as normalize, f as distance2BetweenPoints, n as norm } from '../Core/Math/index.js';
|
|
4
5
|
import vtkLine from './Line.js';
|
|
5
6
|
import vtkPlane from './Plane.js';
|
|
6
7
|
import vtkPriorityQueue from '../Core/PriorityQueue.js';
|
|
8
|
+
import vtkBoundingBox from './BoundingBox.js';
|
|
7
9
|
import { IntersectionState } from './Line/Constants.js';
|
|
10
|
+
import { PolygonWithPointIntersectionState, FLOAT_EPSILON, TOLERANCE, EPSILON } from './Polygon/Constants.js';
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
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; }
|
|
13
|
+
|
|
14
|
+
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; }
|
|
15
|
+
// Global methods
|
|
10
16
|
// ----------------------------------------------------------------------------
|
|
17
|
+
// Given the line (p0,p1), determine if the given point is located to the left
|
|
18
|
+
// of, on, or to the right of a line (with the function returning >0, ==0, or
|
|
19
|
+
// <0 respectively). The points are assumed 3D points, but projected into
|
|
20
|
+
// one of x-y-z planes; hence the indices axis0 and axis1 specify which plane
|
|
21
|
+
// the computation is to be performed on.
|
|
22
|
+
|
|
23
|
+
function pointLocation(axis0, axis1, p0, p1, point) {
|
|
24
|
+
return (p1[axis0] - p0[axis0]) * (point[axis1] - p0[axis1]) - (point[axis0] - p0[axis0]) * (p1[axis1] - p0[axis1]);
|
|
25
|
+
} //------------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
function pointInPolygon(point, vertices, bounds, normal) {
|
|
29
|
+
// Do a quick bounds check to throw out trivial cases.
|
|
30
|
+
// winding plane.
|
|
31
|
+
if (point[0] < bounds[0] || point[0] > bounds[1] || point[1] < bounds[2] || point[1] > bounds[3] || point[2] < bounds[4] || point[2] > bounds[5]) {
|
|
32
|
+
return PolygonWithPointIntersectionState.OUTSIDE;
|
|
33
|
+
} // Check that the normal is non-zero.
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
if (normalize(normal) <= FLOAT_EPSILON) {
|
|
37
|
+
return PolygonWithPointIntersectionState.FAILURE;
|
|
38
|
+
} // Assess whether the point lies on the boundary of the polygon. Points on
|
|
39
|
+
// the boundary are considered inside the polygon. Need to define a small
|
|
40
|
+
// tolerance relative to the bounding box diagonal length of the polygon.
|
|
41
|
+
|
|
11
42
|
|
|
12
|
-
var
|
|
43
|
+
var tol2 = TOLERANCE * ((bounds[1] - bounds[0]) * (bounds[1] - bounds[0]) + (bounds[3] - bounds[2]) * (bounds[3] - bounds[2]) + (bounds[5] - bounds[4]) * (bounds[5] - bounds[4]));
|
|
44
|
+
tol2 *= tol2;
|
|
45
|
+
tol2 = tol2 === 0.0 ? FLOAT_EPSILON : tol2;
|
|
46
|
+
var p0 = [];
|
|
47
|
+
var p1 = [];
|
|
48
|
+
|
|
49
|
+
for (var i = 0; i < vertices.length;) {
|
|
50
|
+
// Check coincidence to polygon vertices
|
|
51
|
+
p0[0] = vertices[i++];
|
|
52
|
+
p0[1] = vertices[i++];
|
|
53
|
+
p0[2] = vertices[i++];
|
|
54
|
+
|
|
55
|
+
if (distance2BetweenPoints(point, p0) <= tol2) {
|
|
56
|
+
return PolygonWithPointIntersectionState.INSIDE;
|
|
57
|
+
} // Check coincidence to polygon edges
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
var _vtkLine$distanceToLi = vtkLine.distanceToLine(point, p0, p1),
|
|
61
|
+
distance = _vtkLine$distanceToLi.distance,
|
|
62
|
+
t = _vtkLine$distanceToLi.t;
|
|
63
|
+
|
|
64
|
+
if (distance <= tol2 && t > 0.0 && t < 1.0) {
|
|
65
|
+
return PolygonWithPointIntersectionState.INSIDE;
|
|
66
|
+
}
|
|
67
|
+
} // If here, begin computation of the winding number. This method works for
|
|
68
|
+
// points/polygons arbitrarily oriented in 3D space. Hence a projection
|
|
69
|
+
// onto one of the x-y-z coordinate planes using the maximum normal
|
|
70
|
+
// component. The computation will be performed in the (axis0, axis1) plane.
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
var axis0;
|
|
74
|
+
var axis1;
|
|
75
|
+
|
|
76
|
+
if (Math.abs(normal[0]) > Math.abs(normal[1])) {
|
|
77
|
+
if (Math.abs(normal[0]) > Math.abs(normal[2])) {
|
|
78
|
+
axis0 = 1;
|
|
79
|
+
axis1 = 2;
|
|
80
|
+
} else {
|
|
81
|
+
axis0 = 0;
|
|
82
|
+
axis1 = 1;
|
|
83
|
+
}
|
|
84
|
+
} else if (Math.abs(normal[1]) > Math.abs(normal[2])) {
|
|
85
|
+
axis0 = 0;
|
|
86
|
+
axis1 = 2;
|
|
87
|
+
} else {
|
|
88
|
+
axis0 = 0;
|
|
89
|
+
axis1 = 1;
|
|
90
|
+
} // Compute the winding number wn. If after processing all polygon edges
|
|
91
|
+
// wn == 0, then the point is outside. Otherwise, the point is inside the
|
|
92
|
+
// polygon. Process all polygon edges determining if there are ascending or
|
|
93
|
+
// descending crossings of the line axis1=constant.
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
var wn = 0;
|
|
97
|
+
|
|
98
|
+
for (var _i = 0; _i < vertices.length;) {
|
|
99
|
+
p0[0] = vertices[_i++];
|
|
100
|
+
p0[1] = vertices[_i++];
|
|
101
|
+
p0[2] = vertices[_i++];
|
|
102
|
+
|
|
103
|
+
if (_i < vertices.length) {
|
|
104
|
+
p1[0] = vertices[_i];
|
|
105
|
+
p1[1] = vertices[_i + 1];
|
|
106
|
+
p1[2] = vertices[_i + 2];
|
|
107
|
+
} else {
|
|
108
|
+
p1[0] = vertices[0];
|
|
109
|
+
p1[1] = vertices[1];
|
|
110
|
+
p1[2] = vertices[2];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (p0[axis1] <= point[axis1]) {
|
|
114
|
+
if (p1[axis1] > point[axis1]) {
|
|
115
|
+
// if an upward crossing
|
|
116
|
+
if (pointLocation(axis0, axis1, p0, p1, point) > 0) {
|
|
117
|
+
// if x left of edge
|
|
118
|
+
++wn; // a valid up intersect, increment the winding number
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
} else if (p1[axis1] <= point[axis1]) {
|
|
122
|
+
// if a downward crossing
|
|
123
|
+
if (pointLocation(axis0, axis1, p0, p1, point) < 0) {
|
|
124
|
+
// if x right of edge
|
|
125
|
+
--wn; // a valid down intersect, decrement the winding number
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} // Over all polygon edges
|
|
129
|
+
// A winding number == 0 is outside the polygon
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
return wn === 0 ? PolygonWithPointIntersectionState.OUTSIDE : PolygonWithPointIntersectionState.INSIDE;
|
|
133
|
+
} // ---------------------------------------------------
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Simple utility method for computing polygon bounds.
|
|
137
|
+
* Returns the sum of the squares of the dimensions.
|
|
138
|
+
* Requires a poly with at least one point.
|
|
139
|
+
*
|
|
140
|
+
* @param {Array<Number>|TypedArray<Number>} poly
|
|
141
|
+
* @param {vtkPoints} points
|
|
142
|
+
* @param {Bound} bounds
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
function getBounds(poly, points, bounds) {
|
|
147
|
+
var n = poly.length;
|
|
148
|
+
var p = [];
|
|
149
|
+
points.getPoint(poly[0], p);
|
|
150
|
+
bounds[0] = p[0];
|
|
151
|
+
bounds[1] = p[0];
|
|
152
|
+
bounds[2] = p[1];
|
|
153
|
+
bounds[3] = p[1];
|
|
154
|
+
bounds[4] = p[2];
|
|
155
|
+
bounds[5] = p[2];
|
|
156
|
+
|
|
157
|
+
for (var j = 1; j < n; j++) {
|
|
158
|
+
points.getPoint(poly[j], p);
|
|
159
|
+
vtkBoundingBox.addPoint(bounds, p);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
var length = vtkBoundingBox.getLength(bounds);
|
|
163
|
+
return dot(length, length);
|
|
164
|
+
} // ---------------------------------------------------
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* Compute the normal of a polygon and return its norm.
|
|
168
|
+
*
|
|
169
|
+
* TBD: This does the same thing as vtkPolygon.computeNormal,
|
|
170
|
+
* but in a more generic way. Maybe we can keep the public
|
|
171
|
+
* static method somehow and have the private method use it instead.
|
|
172
|
+
*
|
|
173
|
+
* @param {Array<Number>|TypedArray<Number>} poly
|
|
174
|
+
* @param {vtkPoints} points
|
|
175
|
+
* @param {Vector3} normal
|
|
176
|
+
* @returns {Number}
|
|
177
|
+
*/
|
|
178
|
+
|
|
179
|
+
function getNormal(poly, points, normal) {
|
|
180
|
+
normal.length = 3;
|
|
181
|
+
normal[0] = 0.0;
|
|
182
|
+
normal[1] = 0.0;
|
|
183
|
+
normal[2] = 0.0;
|
|
184
|
+
var p0 = [];
|
|
185
|
+
var p1 = [];
|
|
186
|
+
var p2 = [];
|
|
187
|
+
var v1 = [];
|
|
188
|
+
var v2 = [];
|
|
189
|
+
points.getPoint(poly[0], p0);
|
|
190
|
+
points.getPoint(poly[1], p1);
|
|
191
|
+
|
|
192
|
+
for (var j = 2; j < poly.length; j++) {
|
|
193
|
+
points.getPoint(poly[j], p2);
|
|
194
|
+
subtract(p2, p1, v1);
|
|
195
|
+
subtract(p0, p1, v2);
|
|
196
|
+
var n = [0, 0, 0];
|
|
197
|
+
cross(v1, v2, n);
|
|
198
|
+
add(normal, n, normal);
|
|
199
|
+
var _ref = [p2, p1];
|
|
200
|
+
p1 = _ref[0];
|
|
201
|
+
p2 = _ref[1];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
return normalize(normal);
|
|
205
|
+
} // ----------------------------------------------------------------------------
|
|
206
|
+
// Static API
|
|
207
|
+
// ----------------------------------------------------------------------------
|
|
208
|
+
|
|
209
|
+
var STATIC = {
|
|
210
|
+
PolygonWithPointIntersectionState: PolygonWithPointIntersectionState,
|
|
211
|
+
pointInPolygon: pointInPolygon,
|
|
212
|
+
getBounds: getBounds,
|
|
213
|
+
getNormal: getNormal
|
|
214
|
+
}; // ----------------------------------------------------------------------------
|
|
215
|
+
// vtkPolygon methods
|
|
216
|
+
// ----------------------------------------------------------------------------
|
|
13
217
|
|
|
14
218
|
function vtkPolygon(publicAPI, model) {
|
|
15
219
|
// Set our classname
|
|
@@ -216,9 +420,9 @@ function extend(publicAPI, model) {
|
|
|
216
420
|
|
|
217
421
|
var newInstance = macro.newInstance(extend, 'vtkPolygon'); // ----------------------------------------------------------------------------
|
|
218
422
|
|
|
219
|
-
var vtkPolygon$1 = {
|
|
423
|
+
var vtkPolygon$1 = _objectSpread({
|
|
220
424
|
newInstance: newInstance,
|
|
221
425
|
extend: extend
|
|
222
|
-
};
|
|
426
|
+
}, STATIC);
|
|
223
427
|
|
|
224
|
-
export { vtkPolygon$1 as default, extend, newInstance };
|
|
428
|
+
export { vtkPolygon$1 as default, extend, getBounds, getNormal, newInstance };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Vector3, Vector4 } from './../../types';
|
|
2
|
+
import vtkCell, { ICellInitialValues } from './Cell';
|
|
3
|
+
import { IIntersectWithLine } from './Triangle';
|
|
4
|
+
|
|
5
|
+
export interface IQuadInitialValues extends ICellInitialValues {}
|
|
6
|
+
|
|
7
|
+
export interface vtkQuad extends vtkCell {
|
|
8
|
+
getCellType(): number;
|
|
9
|
+
/**
|
|
10
|
+
* Get the topological dimensional of the cell (0, 1, 2 or 3).
|
|
11
|
+
*/
|
|
12
|
+
getCellDimension(): number;
|
|
13
|
+
getNumberOfEdges(): number;
|
|
14
|
+
getNumberOfFaces(): number;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Compute the intersection point of the intersection between quad and
|
|
18
|
+
* line defined by p1 and p2. tol Tolerance use for the position evaluation
|
|
19
|
+
* x is the point which intersect triangle (computed in function) pcoords
|
|
20
|
+
* parametric coordinates (computed in function) A javascript object is
|
|
21
|
+
* returned :
|
|
22
|
+
*
|
|
23
|
+
* ```js
|
|
24
|
+
* {
|
|
25
|
+
* evaluation: define if the triangle has been intersected or not
|
|
26
|
+
* subId: always set to 0
|
|
27
|
+
* t: parametric coordinate along the line.
|
|
28
|
+
* betweenPoints: Define if the intersection is between input points
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @param {Vector3} p1 The first point coordinate.
|
|
33
|
+
* @param {Vector3} p2 The second point coordinate.
|
|
34
|
+
* @param {Number} tol The tolerance to use.
|
|
35
|
+
* @param {Vector3} x The point which intersect triangle.
|
|
36
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
37
|
+
*/
|
|
38
|
+
intersectWithLine(
|
|
39
|
+
p1: Vector3,
|
|
40
|
+
p2: Vector3,
|
|
41
|
+
tol: number,
|
|
42
|
+
x: Vector3,
|
|
43
|
+
pcoords: Vector3
|
|
44
|
+
): IIntersectWithLine;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Determine global coordinate (x]) from subId and parametric coordinates.
|
|
48
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
49
|
+
* @param {Vector3} x The x point coordinate.
|
|
50
|
+
* @param {Number[]} weights The number of weights.
|
|
51
|
+
*/
|
|
52
|
+
evaluateLocation(pcoords: Vector3, x: Vector3, weights: number[]): void;
|
|
53
|
+
|
|
54
|
+
/*
|
|
55
|
+
* Compute iso-parametric interpolation functions
|
|
56
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
57
|
+
* @param {Vector4} sf out weights.
|
|
58
|
+
*/
|
|
59
|
+
interpolationFunctions(pcoords: Vector3, sf: Vector4);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Method used to decorate a given object (publicAPI+model) with vtkQuad characteristics.
|
|
64
|
+
*
|
|
65
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
66
|
+
* @param model object on which data structure will be bounds (protected)
|
|
67
|
+
* @param {IQuadInitialValues} [initialValues] (default: {})
|
|
68
|
+
*/
|
|
69
|
+
export function extend(
|
|
70
|
+
publicAPI: object,
|
|
71
|
+
model: object,
|
|
72
|
+
initialValues?: IQuadInitialValues
|
|
73
|
+
): void;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Method used to create a new instance of vtkQuad.
|
|
77
|
+
* @param {IQuadInitialValues} [initialValues] for pre-setting some of its content
|
|
78
|
+
*/
|
|
79
|
+
export function newInstance(initialValues?: IQuadInitialValues): vtkQuad;
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* vtkQuad is a cell which represents a quadrilateral. It may contain static
|
|
83
|
+
* methods to make some computations directly link to quads.
|
|
84
|
+
*
|
|
85
|
+
* @see vtkCell
|
|
86
|
+
*/
|
|
87
|
+
export declare const vtkQuad: {
|
|
88
|
+
newInstance: typeof newInstance;
|
|
89
|
+
extend: typeof extend;
|
|
90
|
+
};
|
|
91
|
+
export default vtkQuad;
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
+
import macro from '../../macros.js';
|
|
3
|
+
import vtkCell from './Cell.js';
|
|
4
|
+
import { f as distance2BetweenPoints } from '../Core/Math/index.js';
|
|
5
|
+
import { CellType } from './CellTypes/Constants.js';
|
|
6
|
+
import vtkTriangle from './Triangle.js';
|
|
7
|
+
import vtkPoints from '../Core/Points.js';
|
|
8
|
+
|
|
9
|
+
function intersectionStruct() {
|
|
10
|
+
return {
|
|
11
|
+
intersected: false,
|
|
12
|
+
subId: -1,
|
|
13
|
+
x: [0.0, 0.0, 0.0],
|
|
14
|
+
pCoords: [0.0, 0.0, 0.0],
|
|
15
|
+
t: -1
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function vtkQuad(publicAPI, model) {
|
|
20
|
+
// Set our className
|
|
21
|
+
model.classHierarchy.push('vtkQuad');
|
|
22
|
+
|
|
23
|
+
publicAPI.getCellDimension = function () {
|
|
24
|
+
return 2;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
publicAPI.getCellType = function () {
|
|
28
|
+
return CellType.VTK_QUAD;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
publicAPI.getNumberOfEdges = function () {
|
|
32
|
+
return 4;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
publicAPI.getNumberOfFaces = function () {
|
|
36
|
+
return 0;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
publicAPI.intersectWithLine = function (p1, p2, tol, x, pcoords) {
|
|
40
|
+
var _points, _points2, _points3, _points4, _points5, _points6, _points7, _points8, _points9, _points10, _points11, _points12;
|
|
41
|
+
|
|
42
|
+
var outObj = {
|
|
43
|
+
subId: 0,
|
|
44
|
+
t: Number.MAX_VALUE,
|
|
45
|
+
intersect: 0,
|
|
46
|
+
betweenPoints: false
|
|
47
|
+
};
|
|
48
|
+
var diagonalCase;
|
|
49
|
+
var point0 = model.points.getPoint(0, []);
|
|
50
|
+
var point1 = model.points.getPoint(1, []);
|
|
51
|
+
var point2 = model.points.getPoint(2, []);
|
|
52
|
+
var point3 = model.points.getPoint(3, []);
|
|
53
|
+
var d1 = distance2BetweenPoints(point0, point2);
|
|
54
|
+
var d2 = distance2BetweenPoints(point1, point3);
|
|
55
|
+
/* Figure out how to uniquely tessellate the quad. Watch out for
|
|
56
|
+
* equivalent triangulations (i.e., the triangulation is equivalent
|
|
57
|
+
* no matter where the diagonal). In this case use the point ids as
|
|
58
|
+
* a tie breaker to ensure unique triangulation across the quad.
|
|
59
|
+
*/
|
|
60
|
+
// rare case; discriminate based on point id
|
|
61
|
+
|
|
62
|
+
if (d1 === d2) {
|
|
63
|
+
// find the maximum id
|
|
64
|
+
var id;
|
|
65
|
+
var maxId = 0;
|
|
66
|
+
var maxIdx = 0;
|
|
67
|
+
|
|
68
|
+
for (var i = 0; i < 4; i++) {
|
|
69
|
+
id = model.pointsIds[i];
|
|
70
|
+
|
|
71
|
+
if (id > maxId) {
|
|
72
|
+
maxId = id;
|
|
73
|
+
maxIdx = i;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (maxIdx === 0 || maxIdx === 2) {
|
|
78
|
+
diagonalCase = 0;
|
|
79
|
+
} else {
|
|
80
|
+
diagonalCase = 1;
|
|
81
|
+
}
|
|
82
|
+
} else if (d1 < d2) {
|
|
83
|
+
diagonalCase = 0;
|
|
84
|
+
} else {
|
|
85
|
+
diagonalCase = 1;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
var points = null;
|
|
89
|
+
|
|
90
|
+
if (!model.triangle) {
|
|
91
|
+
model.triangle = vtkTriangle.newInstance();
|
|
92
|
+
points = vtkPoints.newInstance();
|
|
93
|
+
points.setNumberOfPoints(3);
|
|
94
|
+
model.triangle.initialize(points);
|
|
95
|
+
} else {
|
|
96
|
+
points = model.triangle.getPoints();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
var firstIntersect;
|
|
100
|
+
var firstIntersectTmpObj = intersectionStruct();
|
|
101
|
+
var secondIntersect;
|
|
102
|
+
var secondIntersectTmpObj = intersectionStruct();
|
|
103
|
+
var useFirstIntersection;
|
|
104
|
+
var useSecondIntersection;
|
|
105
|
+
|
|
106
|
+
switch (diagonalCase) {
|
|
107
|
+
case 0:
|
|
108
|
+
(_points = points).setPoint.apply(_points, [0].concat(_toConsumableArray(point0)));
|
|
109
|
+
|
|
110
|
+
(_points2 = points).setPoint.apply(_points2, [1].concat(_toConsumableArray(point1)));
|
|
111
|
+
|
|
112
|
+
(_points3 = points).setPoint.apply(_points3, [2].concat(_toConsumableArray(point2)));
|
|
113
|
+
|
|
114
|
+
firstIntersect = model.triangle.intersectWithLine(p1, p2, tol, firstIntersectTmpObj.x, firstIntersectTmpObj.pCoords);
|
|
115
|
+
|
|
116
|
+
(_points4 = points).setPoint.apply(_points4, [0].concat(_toConsumableArray(point2)));
|
|
117
|
+
|
|
118
|
+
(_points5 = points).setPoint.apply(_points5, [1].concat(_toConsumableArray(point3)));
|
|
119
|
+
|
|
120
|
+
(_points6 = points).setPoint.apply(_points6, [2].concat(_toConsumableArray(point0)));
|
|
121
|
+
|
|
122
|
+
secondIntersect = model.triangle.intersectWithLine(p1, p2, tol, secondIntersectTmpObj.x, secondIntersectTmpObj.pCoords);
|
|
123
|
+
useFirstIntersection = firstIntersect.intersect && secondIntersect.intersect ? firstIntersect.t <= secondIntersect.t : firstIntersect.intersect;
|
|
124
|
+
useSecondIntersection = firstIntersect.intersect && secondIntersect.intersect ? secondIntersect.t < firstIntersect.t : secondIntersect.intersect;
|
|
125
|
+
|
|
126
|
+
if (useFirstIntersection) {
|
|
127
|
+
outObj = firstIntersect;
|
|
128
|
+
x[0] = firstIntersectTmpObj.x[0];
|
|
129
|
+
x[1] = firstIntersectTmpObj.x[1];
|
|
130
|
+
x[2] = firstIntersectTmpObj.x[2];
|
|
131
|
+
pcoords[0] = firstIntersectTmpObj.pCoords[0] + firstIntersectTmpObj.pCoords[1];
|
|
132
|
+
pcoords[1] = firstIntersectTmpObj.pCoords[1];
|
|
133
|
+
pcoords[2] = firstIntersectTmpObj.pCoords[2];
|
|
134
|
+
} else if (useSecondIntersection) {
|
|
135
|
+
outObj = secondIntersect;
|
|
136
|
+
x[0] = secondIntersectTmpObj.x[0];
|
|
137
|
+
x[1] = secondIntersectTmpObj.x[1];
|
|
138
|
+
x[2] = secondIntersectTmpObj.x[2];
|
|
139
|
+
pcoords[0] = 1.0 - (secondIntersectTmpObj.pCoords[0] + secondIntersectTmpObj.pCoords[1]);
|
|
140
|
+
pcoords[1] = 1 - secondIntersectTmpObj.pCoords[1];
|
|
141
|
+
pcoords[2] = secondIntersectTmpObj.pCoords[2];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 1:
|
|
147
|
+
(_points7 = points).setPoint.apply(_points7, [0].concat(_toConsumableArray(point0)));
|
|
148
|
+
|
|
149
|
+
(_points8 = points).setPoint.apply(_points8, [1].concat(_toConsumableArray(point1)));
|
|
150
|
+
|
|
151
|
+
(_points9 = points).setPoint.apply(_points9, [2].concat(_toConsumableArray(point3)));
|
|
152
|
+
|
|
153
|
+
firstIntersect = model.triangle.intersectWithLine(p1, p2, tol, firstIntersectTmpObj.x, firstIntersectTmpObj.pCoords);
|
|
154
|
+
|
|
155
|
+
(_points10 = points).setPoint.apply(_points10, [0].concat(_toConsumableArray(point2)));
|
|
156
|
+
|
|
157
|
+
(_points11 = points).setPoint.apply(_points11, [1].concat(_toConsumableArray(point3)));
|
|
158
|
+
|
|
159
|
+
(_points12 = points).setPoint.apply(_points12, [2].concat(_toConsumableArray(point1)));
|
|
160
|
+
|
|
161
|
+
secondIntersect = model.triangle.intersectWithLine(p1, p2, tol, secondIntersectTmpObj.x, secondIntersectTmpObj.pCoords);
|
|
162
|
+
useFirstIntersection = firstIntersect.intersect && secondIntersect.intersect ? firstIntersect.t <= secondIntersect.t : firstIntersect.intersect;
|
|
163
|
+
useSecondIntersection = firstIntersect.intersect && secondIntersect.intersect ? secondIntersect.t < firstIntersect.t : secondIntersect.intersect;
|
|
164
|
+
|
|
165
|
+
if (useFirstIntersection) {
|
|
166
|
+
outObj = firstIntersect;
|
|
167
|
+
x[0] = firstIntersectTmpObj.x[0];
|
|
168
|
+
x[1] = firstIntersectTmpObj.x[1];
|
|
169
|
+
x[2] = firstIntersectTmpObj.x[2];
|
|
170
|
+
pcoords[0] = firstIntersectTmpObj.pCoords[0];
|
|
171
|
+
pcoords[1] = firstIntersectTmpObj.pCoords[1];
|
|
172
|
+
pcoords[2] = firstIntersectTmpObj.pCoords[2];
|
|
173
|
+
} else if (useSecondIntersection) {
|
|
174
|
+
outObj = secondIntersect;
|
|
175
|
+
x[0] = secondIntersectTmpObj.x[0];
|
|
176
|
+
x[1] = secondIntersectTmpObj.x[1];
|
|
177
|
+
x[2] = secondIntersectTmpObj.x[2];
|
|
178
|
+
pcoords[0] = 1 - secondIntersectTmpObj.pCoords[0];
|
|
179
|
+
pcoords[1] = 1 - secondIntersectTmpObj.pCoords[1];
|
|
180
|
+
pcoords[2] = secondIntersectTmpObj.pCoords[2];
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return outObj;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
publicAPI.interpolationFunctions = function (pcoords, weights) {
|
|
190
|
+
var rm = 1 - pcoords[0];
|
|
191
|
+
var sm = 1 - pcoords[1];
|
|
192
|
+
weights[0] = rm * sm;
|
|
193
|
+
weights[1] = pcoords[0] * sm;
|
|
194
|
+
weights[2] = pcoords[0] * pcoords[1];
|
|
195
|
+
weights[3] = rm * pcoords[1];
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
publicAPI.evaluateLocation = function (pcoords, x, weights) {
|
|
199
|
+
var point = []; // Calculate the weights
|
|
200
|
+
|
|
201
|
+
publicAPI.interpolationFunctions(pcoords, weights);
|
|
202
|
+
x[0] = 0.0;
|
|
203
|
+
x[1] = 0.0;
|
|
204
|
+
x[2] = 0.0;
|
|
205
|
+
|
|
206
|
+
for (var i = 0; i < 4; i++) {
|
|
207
|
+
model.points.getPoint(i, point);
|
|
208
|
+
|
|
209
|
+
for (var j = 0; j < 3; j++) {
|
|
210
|
+
x[j] += point[j] * weights[i];
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
};
|
|
214
|
+
} // ----------------------------------------------------------------------------
|
|
215
|
+
// Object factory
|
|
216
|
+
// ----------------------------------------------------------------------------
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
|
|
220
|
+
|
|
221
|
+
function extend(publicAPI, model) {
|
|
222
|
+
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
223
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
224
|
+
vtkCell.extend(publicAPI, model, initialValues);
|
|
225
|
+
vtkQuad(publicAPI, model);
|
|
226
|
+
} // ----------------------------------------------------------------------------
|
|
227
|
+
|
|
228
|
+
var newInstance = macro.newInstance(extend, 'vtkQuad'); // ----------------------------------------------------------------------------
|
|
229
|
+
|
|
230
|
+
var vtkQuad$1 = {
|
|
231
|
+
newInstance: newInstance,
|
|
232
|
+
extend: extend
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
export { vtkQuad$1 as default, extend, newInstance };
|