@kitware/vtk.js 34.5.0 → 34.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 +3 -0
- package/Common/Core/CellArray.js +12 -1
- package/Common/Core/DataArray.d.ts +15 -0
- package/Common/Core/DataArray.js +8 -4
- package/Common/Core/Math/index.js +12 -1
- package/Common/Core/Math.d.ts +24 -18
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/Triangle.d.ts +68 -19
- package/Common/DataModel/Triangle.js +136 -2
- package/Common/DataModel/TriangleStrip.d.ts +180 -0
- package/Common/DataModel/TriangleStrip.js +396 -0
- package/Common/DataModel.js +3 -1
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Common/Transform/Transform.d.ts +112 -1
- package/Common/Transform/Transform.js +301 -2
- package/Filters/Core/Cutter.js +42 -0
- package/Filters/General/OBBTree.js +1 -1
- package/Filters/General/TransformPolyDataFilter.d.ts +75 -0
- package/Filters/General/TransformPolyDataFilter.js +194 -0
- 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/IO/Geometry/DracoReader.js +1 -1
- package/IO/Geometry/GLTFImporter/Animations.js +1 -1
- package/IO/Geometry/GLTFImporter/Reader.js +2 -2
- package/IO/Image/HDRReader/Utils.js +1 -1
- package/IO/Image/HDRReader.js +1 -1
- package/IO/Misc/OBJWriter.d.ts +103 -0
- package/IO/Misc/OBJWriter.js +235 -0
- package/IO/Misc.js +2 -0
- 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/InteractorStyleManipulator.js +75 -2
- package/Interaction/Style/InteractorStyleTrackballCamera.js +1 -1
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/AbstractImageMapper.js +1 -1
- package/Rendering/Core/AbstractMapper3D.js +1 -1
- package/Rendering/Core/Camera.d.ts +3 -3
- package/Rendering/Core/Camera.js +33 -3
- package/Rendering/Core/ColorTransferFunction/CssFilters.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/ImageArrayMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +3 -3
- package/Rendering/Core/Renderer.js +1 -1
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/TextActor.js +1 -1
- package/Rendering/Core/VectorText/Utils.js +1 -1
- package/Rendering/Core/VolumeProperty.js +1 -1
- package/Rendering/OpenGL/PolyDataMapper2D.js +1 -1
- package/Rendering/OpenGL/Texture.js +1 -1
- package/Rendering/OpenGL/VolumeMapper.js +21 -19
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget.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/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { CellType, Vector3 } from './../../types';
|
|
2
|
+
import vtkCellArray from './../Core/CellArray';
|
|
3
|
+
import vtkPoints from './../Core/Points';
|
|
4
|
+
import vtkCell, { ICellInitialValues } from './Cell';
|
|
5
|
+
import vtkLine from './Line';
|
|
6
|
+
import vtkTriangle from './Triangle';
|
|
7
|
+
|
|
8
|
+
export interface ITriangleStripInitialValues extends ICellInitialValues {
|
|
9
|
+
line?: vtkLine;
|
|
10
|
+
triangle?: vtkTriangle;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface vtkTriangleStrip extends vtkCell {
|
|
14
|
+
/**
|
|
15
|
+
* Get the cell boundary of the triangle strip.
|
|
16
|
+
* @param {Number} subId The sub-id of the cell.
|
|
17
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
18
|
+
* @param {Vector3[]} pts The points of the cell.
|
|
19
|
+
*/
|
|
20
|
+
cellBoundary(subId: number, pcoords: Vector3, pts: Vector3[]): boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Derivatives of the triangle strip.
|
|
24
|
+
* @param {Number} subId - The sub-id of the triangle.
|
|
25
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
26
|
+
* @param {Number[]} values - The values at the points.
|
|
27
|
+
* @param {Number} dim - The dimension.
|
|
28
|
+
* @param {Number[]} derivs - The derivatives.
|
|
29
|
+
*/
|
|
30
|
+
derivatives(
|
|
31
|
+
subId: number,
|
|
32
|
+
pcoords: Vector3,
|
|
33
|
+
values: number[],
|
|
34
|
+
dim: number,
|
|
35
|
+
derivs: number[]
|
|
36
|
+
): void;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Evaluate the location of a point in the triangle strip.
|
|
40
|
+
* @param {Vector3} pcoords The parametric coordinates of the point.
|
|
41
|
+
* @param {Vector3} closestPoint The closest point on the triangle strip.
|
|
42
|
+
* @param {Number[]} weights The interpolation weights.
|
|
43
|
+
*/
|
|
44
|
+
evaluateLocation(
|
|
45
|
+
pcoords: Vector3,
|
|
46
|
+
closestPoint: Vector3,
|
|
47
|
+
weights: number[]
|
|
48
|
+
): number;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Evaluate the position of a point in the triangle strip.
|
|
52
|
+
* @param {Vector3} x The point to evaluate.
|
|
53
|
+
* @param {Vector3} closestPoint The closest point on the triangle strip.
|
|
54
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
55
|
+
* @param {Number[]} dist2 The squared distance from the point to the triangle strip.
|
|
56
|
+
* @param {Number[]} weights The interpolation weights.
|
|
57
|
+
*/
|
|
58
|
+
evaluatePosition(
|
|
59
|
+
x: Vector3,
|
|
60
|
+
closestPoint: Vector3,
|
|
61
|
+
pcoords: Vector3,
|
|
62
|
+
dist2: number[],
|
|
63
|
+
weights: number[]
|
|
64
|
+
): number;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Get the cell type.
|
|
68
|
+
*/
|
|
69
|
+
getCellType(): CellType;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get the topological dimensional of the cell (0, 1, 2 or 3).
|
|
73
|
+
*/
|
|
74
|
+
getCellDimension(): number;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Get the edge of the triangle strip.
|
|
78
|
+
* @param {Number} edgeId The edge ID to retrieve.
|
|
79
|
+
* @returns {vtkLine} The edge corresponding to the edge ID.
|
|
80
|
+
*/
|
|
81
|
+
getEdge(edgeId: number): vtkLine;
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Get the number of edges in the triangle strip.
|
|
85
|
+
*/
|
|
86
|
+
getNumberOfEdges(): number;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Get the number of faces in the triangle strip.
|
|
90
|
+
*/
|
|
91
|
+
getNumberOfFaces(): number;
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Get the parametric center of the triangle strip.
|
|
95
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
96
|
+
* @returns {Number} The parametric center.
|
|
97
|
+
*/
|
|
98
|
+
getParametricCenter(pcoords: Vector3): number;
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Get the point array of the triangle strip.
|
|
102
|
+
* @returns {Number[]} The point array.
|
|
103
|
+
*/
|
|
104
|
+
getPointArray(): number[];
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Initialize the triangle strip with points and point IDs.
|
|
108
|
+
* @param {vtkPoints} points The points of the triangle strip.
|
|
109
|
+
* @param {Number[]} pointsIds The point IDs of the triangle strip.
|
|
110
|
+
*/
|
|
111
|
+
initialize(points: vtkPoints, pointsIds: number[]): void;
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Intersects a line with the triangle strip.
|
|
115
|
+
* @param {Vector3} p1 Start point of the line
|
|
116
|
+
* @param {Vector3} p2 End point of the line
|
|
117
|
+
* @param {Number} tol Tolerance for intersection
|
|
118
|
+
* @param {Vector3} x Intersection point
|
|
119
|
+
* @param {Vector3} pcoords Parametric coordinates of the intersection
|
|
120
|
+
* @returns {Boolean} True if the line intersects the triangle strip
|
|
121
|
+
*/
|
|
122
|
+
intersectWithLine(
|
|
123
|
+
p1: Vector3,
|
|
124
|
+
p2: Vector3,
|
|
125
|
+
tol: number,
|
|
126
|
+
x: Vector3,
|
|
127
|
+
pcoords: Vector3
|
|
128
|
+
): boolean;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Triangulate the triangle strip.
|
|
132
|
+
* @returns {Boolean} True if the triangulation is successful.
|
|
133
|
+
*/
|
|
134
|
+
triangulate(): boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Method used to decorate a given object (publicAPI+model) with vtkTriangle characteristics.
|
|
139
|
+
*
|
|
140
|
+
* @param publicAPI object on which methods will be bounds (public)
|
|
141
|
+
* @param model object on which data structure will be bounds (protected)
|
|
142
|
+
* @param {ITriangleStripInitialValues} [initialValues] (default: {})
|
|
143
|
+
*/
|
|
144
|
+
export function extend(
|
|
145
|
+
publicAPI: object,
|
|
146
|
+
model: object,
|
|
147
|
+
initialValues?: ITriangleStripInitialValues
|
|
148
|
+
): void;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Method used to create a new instance of vtkTriangle.
|
|
152
|
+
* @param {ITriangleStripInitialValues} [initialValues] for pre-setting some of its content
|
|
153
|
+
*/
|
|
154
|
+
export function newInstance(
|
|
155
|
+
initialValues?: ITriangleStripInitialValues
|
|
156
|
+
): vtkTriangleStrip;
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Decomposes a triangle strip into individual triangles.
|
|
160
|
+
* @param {vtkPoints} pts Points of the triangle strip
|
|
161
|
+
* @param {vtkCellArray} polys Cell array to store the resulting triangles
|
|
162
|
+
*/
|
|
163
|
+
export function decomposeStrip(pts: vtkPoints, polys: vtkCellArray): void;
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* vtkTriangleStrip is a concrete implementation of vtkCell to represent a 2D
|
|
167
|
+
* triangle strip. A triangle strip is a compact representation of triangles
|
|
168
|
+
* connected edge to edge in strip fashion. The connectivity of a triangle strip
|
|
169
|
+
* is three points defining an initial triangle, then for each additional
|
|
170
|
+
* triangle, a single point that, combined with the previous two points, defines
|
|
171
|
+
* the next triangle.
|
|
172
|
+
*
|
|
173
|
+
* @see vtkCell
|
|
174
|
+
*/
|
|
175
|
+
export declare const vtkTriangleStrip: {
|
|
176
|
+
newInstance: typeof newInstance;
|
|
177
|
+
extend: typeof extend;
|
|
178
|
+
decomposeStrip: typeof decomposeStrip;
|
|
179
|
+
};
|
|
180
|
+
export default vtkTriangleStrip;
|
|
@@ -0,0 +1,396 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkCell from './Cell.js';
|
|
3
|
+
import vtkLine from './Line.js';
|
|
4
|
+
import vtkTriangle from './Triangle.js';
|
|
5
|
+
import { CellType } from './CellTypes/Constants.js';
|
|
6
|
+
|
|
7
|
+
const {
|
|
8
|
+
vtkErrorMacro
|
|
9
|
+
} = macro;
|
|
10
|
+
|
|
11
|
+
// ----------------------------------------------------------------------------
|
|
12
|
+
// Global methods
|
|
13
|
+
// ----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
function notImplemented(method) {
|
|
16
|
+
return () => vtkErrorMacro(`vtkTriangleStrip.${method} - NOT IMPLEMENTED`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Decomposes a triangle strip into individual triangles.
|
|
21
|
+
* @param {*} pts Points of the triangle strip
|
|
22
|
+
* @param {*} polys Cell array to store the resulting triangles
|
|
23
|
+
*/
|
|
24
|
+
function decomposeStrip(pts, polys) {
|
|
25
|
+
if (!Array.isArray(pts) || pts.length < 3) {
|
|
26
|
+
vtkErrorMacro('decomposeStrip - Invalid points array');
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
let p1 = pts[0];
|
|
30
|
+
let p2 = pts[1];
|
|
31
|
+
for (let i = 0; i < pts.length - 2; i++) {
|
|
32
|
+
const p3 = pts[i + 2];
|
|
33
|
+
if (i % 2) {
|
|
34
|
+
// Flip ordering to preserve consistency
|
|
35
|
+
polys.insertNextCell([p2, p1, p3]);
|
|
36
|
+
} else {
|
|
37
|
+
polys.insertNextCell([p1, p2, p3]);
|
|
38
|
+
}
|
|
39
|
+
p1 = p2;
|
|
40
|
+
p2 = p3;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ----------------------------------------------------------------------------
|
|
45
|
+
// Static API
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
const STATIC = {
|
|
49
|
+
decomposeStrip
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
// vtkTriangleStrip methods
|
|
54
|
+
// ----------------------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
function vtkTriangleStrip(publicAPI, model) {
|
|
57
|
+
// Set our className
|
|
58
|
+
model.classHierarchy.push('vtkTriangleStrip');
|
|
59
|
+
const superInitialize = publicAPI.initialize;
|
|
60
|
+
publicAPI.initialize = (points, pointsIds) => {
|
|
61
|
+
model.triangle.initialize(points, pointsIds);
|
|
62
|
+
superInitialize(points, pointsIds);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Get the cell type.
|
|
67
|
+
* @returns {number} Cell type
|
|
68
|
+
*/
|
|
69
|
+
publicAPI.getCellType = () => CellType.VTK_TRIANGLE_STRIP;
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get the cell dimension.
|
|
73
|
+
* The dimension of a triangle strip is always 2.
|
|
74
|
+
* @returns {number} Cell dimension
|
|
75
|
+
*/
|
|
76
|
+
publicAPI.getCellDimension = () => 2;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Get the number of edges.
|
|
80
|
+
* @returns {number} Number of edges
|
|
81
|
+
*/
|
|
82
|
+
publicAPI.getNumberOfEdges = () => model.pointsIds.length;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Get the number of faces.
|
|
86
|
+
* @returns {number} Number of faces
|
|
87
|
+
*/
|
|
88
|
+
publicAPI.getNumberOfFaces = () => 0;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Evaluate the position within the triangle strip.
|
|
92
|
+
* @param {*} x Intersection point
|
|
93
|
+
* @param {*} closestPoint Closest point on the triangle
|
|
94
|
+
* @param {*} pcoords Parametric coordinates
|
|
95
|
+
* @param {*} dist2 Squared distance to the closest point
|
|
96
|
+
* @param {*} weights Weights for interpolation
|
|
97
|
+
* @returns {number} Evaluation status
|
|
98
|
+
*/
|
|
99
|
+
publicAPI.evaluatePosition = (x, closestPoint, pcoords, dist2, weights) => {
|
|
100
|
+
const pc = [0, 0, 0];
|
|
101
|
+
let minDist2 = Number.MAX_VALUE;
|
|
102
|
+
let returnStatus = 0;
|
|
103
|
+
const tempWeights = [];
|
|
104
|
+
const activeWeights = [];
|
|
105
|
+
const closest = [];
|
|
106
|
+
pcoords[2] = 0.0;
|
|
107
|
+
activeWeights[0] = 0.0;
|
|
108
|
+
activeWeights[1] = 0.0;
|
|
109
|
+
activeWeights[2] = 0.0;
|
|
110
|
+
const points = model.triangle.getPoints();
|
|
111
|
+
points.setNumberOfPoints(3);
|
|
112
|
+
const pointsIds = model.triangle.getPointsIds();
|
|
113
|
+
const numPoints = pointsIds.length;
|
|
114
|
+
|
|
115
|
+
// Initialize weights
|
|
116
|
+
for (let i = 0; i < numPoints; i++) {
|
|
117
|
+
weights[i] = 0.0;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// Iterate through triangles in the strip
|
|
121
|
+
for (let i = 0; i < numPoints - 2; i++) {
|
|
122
|
+
// Set triangle points
|
|
123
|
+
const pt0 = [];
|
|
124
|
+
points.getPoint(i, pt0);
|
|
125
|
+
const pt1 = [];
|
|
126
|
+
points.getPoint(i + 1, pt1);
|
|
127
|
+
const pt2 = [];
|
|
128
|
+
points.getPoint(i + 2, pt2);
|
|
129
|
+
points.setData(Float32Array.from([...pt0, ...pt1, ...pt2]), 3);
|
|
130
|
+
|
|
131
|
+
// Use dist2 from triangle's evaluatePosition return value
|
|
132
|
+
const status = model.triangle.evaluatePosition(x, closest, pc, tempWeights);
|
|
133
|
+
const currentDist2 = status.dist2;
|
|
134
|
+
if (status.evaluation >= 0 && (currentDist2 < minDist2 || currentDist2 === minDist2 && returnStatus === 0)) {
|
|
135
|
+
returnStatus = status;
|
|
136
|
+
if (closestPoint) {
|
|
137
|
+
closestPoint[0] = closest[0];
|
|
138
|
+
closestPoint[1] = closest[1];
|
|
139
|
+
closestPoint[2] = closest[2];
|
|
140
|
+
}
|
|
141
|
+
pcoords[0] = pc[0];
|
|
142
|
+
pcoords[1] = pc[1];
|
|
143
|
+
minDist2 = currentDist2;
|
|
144
|
+
activeWeights[0] = tempWeights[0];
|
|
145
|
+
activeWeights[1] = tempWeights[1];
|
|
146
|
+
activeWeights[2] = tempWeights[2];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
dist2[0] = minDist2;
|
|
150
|
+
weights[0] = activeWeights[0];
|
|
151
|
+
weights[1] = activeWeights[1];
|
|
152
|
+
weights[2] = activeWeights[2];
|
|
153
|
+
return returnStatus;
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Evaluate the location within the triangle strip.
|
|
158
|
+
* @param {*} subId Sub-Id of the triangle
|
|
159
|
+
* @param {*} pcoords Parametric coordinates
|
|
160
|
+
* @param {*} x Intersection point
|
|
161
|
+
* @param {*} weights Weights for interpolation
|
|
162
|
+
*/
|
|
163
|
+
publicAPI.evaluateLocation = (subId, pcoords, x, weights) => {
|
|
164
|
+
const idx = [[0, 1, 2], [1, 0, 2]];
|
|
165
|
+
const order = subId % 2;
|
|
166
|
+
const numPoints = model.pointsIds.length;
|
|
167
|
+
|
|
168
|
+
// Initialize weights
|
|
169
|
+
for (let i = 0; i < numPoints; i++) {
|
|
170
|
+
weights[i] = 0.0;
|
|
171
|
+
}
|
|
172
|
+
const u3 = 1.0 - pcoords[0] - pcoords[1];
|
|
173
|
+
weights[subId] = u3;
|
|
174
|
+
weights[subId + 1] = pcoords[0];
|
|
175
|
+
weights[subId + 2] = pcoords[1];
|
|
176
|
+
|
|
177
|
+
// Get points
|
|
178
|
+
const pt1 = [];
|
|
179
|
+
model.points.getPoint(subId + idx[order][0], pt1);
|
|
180
|
+
const pt2 = [];
|
|
181
|
+
model.points.getPoint(subId + idx[order][1], pt2);
|
|
182
|
+
const pt3 = [];
|
|
183
|
+
model.points.getPoint(subId + idx[order][2], pt3);
|
|
184
|
+
|
|
185
|
+
// Interpolate position
|
|
186
|
+
for (let i = 0; i < 3; i++) {
|
|
187
|
+
x[i] = pt1[i] * weights[subId] + pt2[i] * weights[subId + 1] + pt3[i] * weights[subId + 2];
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Get the cell boundary of the triangle strip.
|
|
193
|
+
* @param {Number} subId The sub-id of the cell.
|
|
194
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
195
|
+
* @param {Vector2} pts The points of the cell.
|
|
196
|
+
*/
|
|
197
|
+
publicAPI.cellBoundary = (subId, pcoords, pts) => {
|
|
198
|
+
const idx = [[0, 1, 2], [1, 0, 2]];
|
|
199
|
+
const order = subId % 2;
|
|
200
|
+
const pointsIds = model.triangle.getPointsIds();
|
|
201
|
+
pointsIds[0] = model.pointsIds[idx[order][0]];
|
|
202
|
+
pointsIds[1] = model.pointsIds[idx[order][1]];
|
|
203
|
+
pointsIds[2] = model.pointsIds[idx[order][2]];
|
|
204
|
+
return model.triangle.cellBoundary(0, pcoords, pts);
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Get the edge of the triangle strip.
|
|
209
|
+
* @param {Number} edgeId Edge index (0 to n-1)
|
|
210
|
+
* @returns {vtkLine} The edge as a vtkLine instance
|
|
211
|
+
*/
|
|
212
|
+
publicAPI.getEdge = edgeId => {
|
|
213
|
+
let id1;
|
|
214
|
+
let id2;
|
|
215
|
+
const numPoints = model.pointsIds.length;
|
|
216
|
+
if (edgeId === 0) {
|
|
217
|
+
id1 = 0;
|
|
218
|
+
id2 = 1;
|
|
219
|
+
} else if (edgeId === numPoints - 1) {
|
|
220
|
+
id1 = edgeId - 1;
|
|
221
|
+
id2 = edgeId;
|
|
222
|
+
} else {
|
|
223
|
+
id1 = edgeId - 1;
|
|
224
|
+
id2 = edgeId + 1;
|
|
225
|
+
}
|
|
226
|
+
model.line.getPointsIds()[0] = model.pointsIds[id1];
|
|
227
|
+
model.line.getPointsIds()[1] = model.pointsIds[id2];
|
|
228
|
+
model.line.getPoints().setPoint(0, model.points.getPoint(id1));
|
|
229
|
+
model.line.getPoints().setPoint(1, model.points.getPoint(id2));
|
|
230
|
+
return model.line;
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Intersects a line with the triangle strip.
|
|
235
|
+
* @param {Vector3} p1 Start point of the line
|
|
236
|
+
* @param {Vector3} p2 End point of the line
|
|
237
|
+
* @param {number} tol Tolerance for intersection
|
|
238
|
+
* @param {Vector3} x Intersection point
|
|
239
|
+
* @param {Vector3} pcoords Parametric coordinates of the intersection
|
|
240
|
+
* @returns {Boolean} True if the line intersects the triangle strip
|
|
241
|
+
*/
|
|
242
|
+
publicAPI.intersectWithLine = (p1, p2, tol, x, pcoords) => {
|
|
243
|
+
const numTris = model.pointsIds.length - 2;
|
|
244
|
+
const points = model.triangle.getPoints();
|
|
245
|
+
points.setNumberOfPoints(3);
|
|
246
|
+
for (let i = 0; i < numTris; i++) {
|
|
247
|
+
const pt0 = [];
|
|
248
|
+
model.points.getPoint(model.pointsIds[i], pt0);
|
|
249
|
+
const pt1 = [];
|
|
250
|
+
model.points.getPoint(model.pointsIds[i + 1], pt1);
|
|
251
|
+
const pt2 = [];
|
|
252
|
+
model.points.getPoint(model.pointsIds[i + 2], pt2);
|
|
253
|
+
points.setData(Float32Array.from([...pt0, ...pt1, ...pt2]), 3);
|
|
254
|
+
const ret = model.triangle.intersectWithLine(p1, p2, tol, x, pcoords);
|
|
255
|
+
if (ret.intersect) {
|
|
256
|
+
return ret;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return false;
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
// Triangulate
|
|
263
|
+
/**
|
|
264
|
+
* Triangulate the triangle strip.
|
|
265
|
+
* @returns {Boolean} True if the triangulation is successful.
|
|
266
|
+
*/
|
|
267
|
+
publicAPI.triangulate = () => {
|
|
268
|
+
const numTris = model.points.getNumberOfPoints() - 2;
|
|
269
|
+
model.tris = new Array(3 * numTris);
|
|
270
|
+
const idx = [[0, 1, 2], [1, 0, 2]];
|
|
271
|
+
for (let subId = 0; subId < numTris; subId++) {
|
|
272
|
+
const order = subId % 2;
|
|
273
|
+
for (let i = 0; i < 3; i++) {
|
|
274
|
+
model.tris[subId * 3 + i] = subId + idx[order][i];
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
return true;
|
|
278
|
+
};
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Get the point array of the triangle strip.
|
|
282
|
+
* @returns {Array} The point array.
|
|
283
|
+
*/
|
|
284
|
+
publicAPI.getPointArray = () => model.tris;
|
|
285
|
+
|
|
286
|
+
// Derivatives
|
|
287
|
+
/**
|
|
288
|
+
* Get the derivatives of the triangle strip.
|
|
289
|
+
* @param {Number} subId - The sub-id of the triangle.
|
|
290
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
291
|
+
* @param {Number[]} values - The values at the points.
|
|
292
|
+
* @param {Number} dim - The dimension.
|
|
293
|
+
* @param {Number[]} derivs - The derivatives.
|
|
294
|
+
*/
|
|
295
|
+
publicAPI.derivatives = (subId, pcoords, values, dim, derivs) => {
|
|
296
|
+
const pt0 = [];
|
|
297
|
+
model.points.getPoint(subId, pt0);
|
|
298
|
+
const pt1 = [];
|
|
299
|
+
model.points.getPoint(subId + 1, pt1);
|
|
300
|
+
const pt2 = [];
|
|
301
|
+
model.points.getPoint(subId + 2, pt2);
|
|
302
|
+
const points = model.triangle.getPoints();
|
|
303
|
+
points.setPoint(0, ...pt0);
|
|
304
|
+
points.setPoint(1, ...pt1);
|
|
305
|
+
points.setPoint(2, ...pt2);
|
|
306
|
+
model.triangle.derivatives(0, pcoords, values, dim, derivs);
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Get the parametric center of the triangle strip.
|
|
311
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
312
|
+
* @returns {Number} The parametric center.
|
|
313
|
+
*/
|
|
314
|
+
publicAPI.getParametricCenter = pcoords => {
|
|
315
|
+
pcoords[0] = 0.333333;
|
|
316
|
+
pcoords[1] = 0.333333;
|
|
317
|
+
pcoords[2] = 0.0;
|
|
318
|
+
return Math.floor((model.pointsIds.length - 2) / 2);
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* Contour the triangle strip.
|
|
323
|
+
* @param {*} value
|
|
324
|
+
* @param {*} cellScalars
|
|
325
|
+
* @param {*} locator
|
|
326
|
+
* @param {*} verts
|
|
327
|
+
* @param {*} lines
|
|
328
|
+
* @param {*} polys
|
|
329
|
+
* @param {*} inPd
|
|
330
|
+
* @param {*} outPd
|
|
331
|
+
* @param {*} inCd
|
|
332
|
+
* @param {*} cellId
|
|
333
|
+
* @param {*} outCd
|
|
334
|
+
* @returns
|
|
335
|
+
*/
|
|
336
|
+
publicAPI.contour = (value, cellScalars, locator, verts, lines, polys, inPd, outPd, inCd, cellId, outCd) => notImplemented('contour')();
|
|
337
|
+
|
|
338
|
+
/**
|
|
339
|
+
* Clip the triangle strip.
|
|
340
|
+
* @param {*} value Clipping value
|
|
341
|
+
* @param {*} cellScalars Cell scalars
|
|
342
|
+
* @param {*} locator Locator
|
|
343
|
+
* @param {*} tris Triangle indices
|
|
344
|
+
* @param {*} inPd Input point data
|
|
345
|
+
* @param {*} outPd Output point data
|
|
346
|
+
* @param {*} inCd
|
|
347
|
+
* @param {*} cellId
|
|
348
|
+
* @param {*} outCd
|
|
349
|
+
* @param {*} insideOut
|
|
350
|
+
* @returns
|
|
351
|
+
*/
|
|
352
|
+
publicAPI.clip = (value, cellScalars, locator, tris, inPd, outPd, inCd, cellId, outCd, insideOut) => notImplemented('clip')();
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
// ----------------------------------------------------------------------------
|
|
356
|
+
// Object factory
|
|
357
|
+
// ----------------------------------------------------------------------------
|
|
358
|
+
|
|
359
|
+
const DEFAULT_VALUES = {
|
|
360
|
+
line: null,
|
|
361
|
+
triangle: null,
|
|
362
|
+
tris: null
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
// ----------------------------------------------------------------------------
|
|
366
|
+
|
|
367
|
+
function extend(publicAPI, model) {
|
|
368
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
369
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
370
|
+
|
|
371
|
+
// Inheritance
|
|
372
|
+
vtkCell.extend(publicAPI, model, initialValues);
|
|
373
|
+
if (!model.line) {
|
|
374
|
+
model.line = vtkLine.newInstance();
|
|
375
|
+
}
|
|
376
|
+
if (!model.triangle) {
|
|
377
|
+
model.triangle = vtkTriangle.newInstance();
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
// Build VTK API
|
|
381
|
+
vtkTriangleStrip(publicAPI, model);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
// ----------------------------------------------------------------------------
|
|
385
|
+
|
|
386
|
+
const newInstance = macro.newInstance(extend, 'vtkTriangleStrip');
|
|
387
|
+
|
|
388
|
+
// ----------------------------------------------------------------------------
|
|
389
|
+
|
|
390
|
+
var vtkTriangleStrip$1 = {
|
|
391
|
+
newInstance,
|
|
392
|
+
extend,
|
|
393
|
+
...STATIC
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
export { STATIC, vtkTriangleStrip$1 as default, extend, newInstance };
|
package/Common/DataModel.js
CHANGED
|
@@ -18,6 +18,7 @@ import vtkSelectionNode from './DataModel/SelectionNode.js';
|
|
|
18
18
|
import vtkSphere from './DataModel/Sphere.js';
|
|
19
19
|
import vtkStructuredData from './DataModel/StructuredData.js';
|
|
20
20
|
import vtkTriangle from './DataModel/Triangle.js';
|
|
21
|
+
import vtkTriangleStrip from './DataModel/TriangleStrip.js';
|
|
21
22
|
|
|
22
23
|
var DataModel = {
|
|
23
24
|
vtkBoundingBox,
|
|
@@ -39,7 +40,8 @@ var DataModel = {
|
|
|
39
40
|
vtkSelectionNode,
|
|
40
41
|
vtkSphere,
|
|
41
42
|
vtkStructuredData,
|
|
42
|
-
vtkTriangle
|
|
43
|
+
vtkTriangle,
|
|
44
|
+
vtkTriangleStrip
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export { DataModel as default };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mat4, mat3 } from 'gl-matrix';
|
|
2
2
|
import Constants from './LandmarkTransform/Constants.js';
|
|
3
3
|
import { m as macro } from '../../macros2.js';
|
|
4
|
-
import {
|
|
4
|
+
import { q as jacobiN, t as perpendiculars } from '../Core/Math/index.js';
|
|
5
5
|
|
|
6
6
|
const {
|
|
7
7
|
Mode
|