@kitware/vtk.js 34.5.0 → 34.6.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 +1 -1
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/Triangle.d.ts +68 -19
- package/Common/DataModel/Triangle.js +140 -1
- 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 +41 -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/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/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/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 +2 -0
- package/package.json +1 -1
|
@@ -39,6 +39,9 @@ export interface vtkCellArray extends vtkDataArray {
|
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Insert a cell to this array in the next available slot.
|
|
42
|
+
* This may re-allocate a new typed array if the current one is not large enough.
|
|
43
|
+
* If the final size of the array is known up-front, it is more efficient to call
|
|
44
|
+
* `allocate()` before calling `insertNextCell()` multiple times.
|
|
42
45
|
* @param {Number[]} cellPointIds The list of point ids (NOT prefixed with the number of points)
|
|
43
46
|
* @returns {Number} Idx of where the cell was inserted
|
|
44
47
|
*/
|
package/Common/Core/CellArray.js
CHANGED
|
@@ -2,6 +2,9 @@ import { m as macro } from '../../macros2.js';
|
|
|
2
2
|
import vtkDataArray from './DataArray.js';
|
|
3
3
|
import { VtkDataTypes } from './DataArray/Constants.js';
|
|
4
4
|
|
|
5
|
+
const {
|
|
6
|
+
isVtkObject
|
|
7
|
+
} = macro;
|
|
5
8
|
// ----------------------------------------------------------------------------
|
|
6
9
|
// Global methods
|
|
7
10
|
// ----------------------------------------------------------------------------
|
|
@@ -65,6 +68,8 @@ function vtkCellArray(publicAPI, model) {
|
|
|
65
68
|
|
|
66
69
|
/**
|
|
67
70
|
* When `resize()` is being used, you then MUST use `insertNextCell()`.
|
|
71
|
+
* @see vtkCellArray#insertNextCell
|
|
72
|
+
* @see vtkDataArray#allocate
|
|
68
73
|
*/
|
|
69
74
|
publicAPI.resize = requestedNumTuples => {
|
|
70
75
|
const oldNumTuples = publicAPI.getNumberOfTuples();
|
|
@@ -92,7 +97,13 @@ function vtkCellArray(publicAPI, model) {
|
|
|
92
97
|
const numberOfPoints = model.values[cellLoc++];
|
|
93
98
|
return model.values.subarray(cellLoc, cellLoc + numberOfPoints);
|
|
94
99
|
};
|
|
95
|
-
publicAPI.insertNextCell =
|
|
100
|
+
publicAPI.insertNextCell = cell => {
|
|
101
|
+
let cellPointIds;
|
|
102
|
+
if (isVtkObject(cell)) {
|
|
103
|
+
cellPointIds = cell.getPointsIds();
|
|
104
|
+
} else {
|
|
105
|
+
cellPointIds = cell;
|
|
106
|
+
}
|
|
96
107
|
const cellId = publicAPI.getNumberOfCells();
|
|
97
108
|
publicAPI.insertNextTuples([cellPointIds.length, ...cellPointIds]);
|
|
98
109
|
// By computing the number of cells earlier, we made sure that numberOfCells is defined
|
|
@@ -168,6 +168,7 @@ export interface vtkDataArray extends vtkObject {
|
|
|
168
168
|
*
|
|
169
169
|
* @see insertNextTuple
|
|
170
170
|
* @see getNumberOfTuples
|
|
171
|
+
* @see allocate
|
|
171
172
|
*
|
|
172
173
|
* @param {Number} idx
|
|
173
174
|
* @param {Array<Number>|TypedArray} tuple
|
|
@@ -189,6 +190,7 @@ export interface vtkDataArray extends vtkObject {
|
|
|
189
190
|
* NOTE: May resize the data values array. "Safe" version of setTuple.
|
|
190
191
|
*
|
|
191
192
|
* @see insertTuple
|
|
193
|
+
* @see allocate
|
|
192
194
|
*
|
|
193
195
|
* @param {Array<Number>|TypedArray} tuple
|
|
194
196
|
* @returns {Number} Index of the inserted tuple.
|
|
@@ -303,6 +305,18 @@ export interface vtkDataArray extends vtkObject {
|
|
|
303
305
|
t: float
|
|
304
306
|
): void;
|
|
305
307
|
|
|
308
|
+
/**
|
|
309
|
+
* Resize the array to the requested number of extra tuples
|
|
310
|
+
* (added to the current number of tuples) and preserve data.
|
|
311
|
+
* model.size WILL NOT be modified.
|
|
312
|
+
* This is useful before multiple calls to `insertNextTuple()` or `insertNextTuples()`.
|
|
313
|
+
* @param {Number} extraNumTuples Number of tuples to allocate memory wise.
|
|
314
|
+
* @see insertNextTuple
|
|
315
|
+
* @see insertNextTuples
|
|
316
|
+
* @see allocate
|
|
317
|
+
*/
|
|
318
|
+
allocate(extraNumTuples: number): void;
|
|
319
|
+
|
|
306
320
|
/**
|
|
307
321
|
* Resize the array to the requested number of tuples and preserve data.
|
|
308
322
|
* Increasing the array size may allocate extra memory beyond what was
|
|
@@ -318,6 +332,7 @@ export interface vtkDataArray extends vtkObject {
|
|
|
318
332
|
* @see insertNextTuple
|
|
319
333
|
* @see insertNextTuples
|
|
320
334
|
* @see initialize
|
|
335
|
+
* @see allocate
|
|
321
336
|
*/
|
|
322
337
|
resize(requestedNumTuples: number): boolean;
|
|
323
338
|
|
package/Common/Core/DataArray.js
CHANGED
|
@@ -156,17 +156,18 @@ function vtkDataArray(publicAPI, model) {
|
|
|
156
156
|
return false;
|
|
157
157
|
}
|
|
158
158
|
const numComps = publicAPI.getNumberOfComponents();
|
|
159
|
-
const
|
|
160
|
-
if (requestedNumTuples ===
|
|
159
|
+
const numAllocatedTuples = model.values.length / (numComps > 0 ? numComps : 1);
|
|
160
|
+
if (requestedNumTuples === numAllocatedTuples) {
|
|
161
161
|
return true;
|
|
162
162
|
}
|
|
163
|
-
if (requestedNumTuples >
|
|
163
|
+
if (requestedNumTuples > numAllocatedTuples) {
|
|
164
164
|
// Requested size is bigger than current size. Allocate enough
|
|
165
165
|
// memory to fit the requested size and be more than double the
|
|
166
166
|
// currently allocated memory.
|
|
167
167
|
const oldValues = model.values;
|
|
168
|
-
model.values = newTypedArray(model.dataType, (requestedNumTuples +
|
|
168
|
+
model.values = newTypedArray(model.dataType, (requestedNumTuples + numAllocatedTuples) * numComps);
|
|
169
169
|
model.values.set(oldValues);
|
|
170
|
+
// The actual number of tuples is not increased, only memory is allocated.
|
|
170
171
|
return true;
|
|
171
172
|
}
|
|
172
173
|
|
|
@@ -181,6 +182,9 @@ function vtkDataArray(publicAPI, model) {
|
|
|
181
182
|
model.ranges = null;
|
|
182
183
|
publicAPI.modified();
|
|
183
184
|
};
|
|
185
|
+
publicAPI.allocate = extraNumTuples => {
|
|
186
|
+
resize(publicAPI.getNumberOfTuples() + extraNumTuples);
|
|
187
|
+
};
|
|
184
188
|
publicAPI.resize = requestedNumTuples => {
|
|
185
189
|
resize(requestedNumTuples);
|
|
186
190
|
const newSize = requestedNumTuples * publicAPI.getNumberOfComponents();
|
|
@@ -2256,4 +2256,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2256
2256
|
'default': vtkMath
|
|
2257
2257
|
});
|
|
2258
2258
|
|
|
2259
|
-
export {
|
|
2259
|
+
export { Pi as $, rowsToMat3 as A, degreesFromRadians as B, ldexp as C, xyz2rgb as D, areEquals as E, clampValue as F, arrayRange as G, getMajorAxisIndex as H, createUninitializedBounds as I, identity as J, multiplyMatrix as K, floor as L, isInf as M, rgb2hsv as N, rgb2lab as O, lab2rgb as P, round as Q, normalize2D as R, nearestPowerOfTwo as S, multiply3x3_vect3 as T, getSparseOrthogonalMatrix as U, areBoundsInitialized as V, floatRGB2HexCode as W, isPowerOfTwo as X, angleBetweenVectors as Y, signedAngleBetweenVectors as Z, createArray as _, areMatricesEqual as a, floatToHex2 as a$, ceil as a0, min as a1, max as a2, arrayMin as a3, arrayMax as a4, ceilLog2 as a5, factorial as a6, binomial as a7, beginCombination as a8, nextCombination as a9, roundNumber as aA, matrix3x3ToQuaternion as aB, multiplyQuaternion as aC, orthogonalize3x3 as aD, diagonalize3x3 as aE, singularValueDecomposition3x3 as aF, luFactorLinearSystem as aG, luSolveLinearSystem as aH, estimateMatrixCondition as aI, solveHomogeneousLeastSquares as aJ, solveLeastSquares as aK, hex2float as aL, lab2xyz as aM, xyz2lab as aN, rgb2xyz as aO, computeBoundsFromPoints as aP, clampAndNormalizeValue as aQ, getScalarTypeFittingRange as aR, getAdjustedScalarRange as aS, extentIsWithinOtherExtent as aT, boundsIsWithinOtherBounds as aU, pointIsWithinBounds as aV, solve3PointCircle as aW, inf as aX, negInf as aY, isFinite as aZ, isNaN as a_, randomSeed as aa, getSeed as ab, gaussian as ac, multiplyScalar2D as ad, multiplyAccumulate2D as ae, outer as af, projectVector as ag, dot2D as ah, projectVector2D as ai, gaussianAmplitude as aj, gaussianWeight as ak, outer2D as al, norm2D as am, rowsToMat4 as an, columnsToMat4 as ao, columnsToMat3 as ap, LUFactor3x3 as aq, LUSolve3x3 as ar, linearSolve3x3 as as, multiply3x3_mat3 as at, transpose3x3 as au, invert3x3 as av, identity3x3 as aw, isIdentity as ax, isIdentity3x3 as ay, quaternionToMatrix3x3 as az, roundVector as b, float2CssRGBA as b0, clampVector as c, dot as d, distance2BetweenPoints as e, vtkMath as f, solveLinearSystem as g, hsv2rgb as h, isNan as i, cross as j, add as k, normalize as l, multiplyAccumulate as m, norm as n, determinant2x2 as o, invertMatrix as p, jacobiN as q, radiansFromDegrees as r, subtract as s, perpendiculars as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
|
package/Common/Core/Math.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import 'seedrandom';
|
|
2
2
|
import '../../macros2.js';
|
|
3
3
|
import './Math/Constants.js';
|
|
4
|
-
export {
|
|
4
|
+
export { aq as LUFactor3x3, ar as LUSolve3x3, $ as Pi, k as add, Y as angleBetweenVectors, V as areBoundsInitialized, E as areEquals, a as areMatricesEqual, a4 as arrayMax, a3 as arrayMin, G as arrayRange, a8 as beginCombination, a7 as binomial, aU as boundsIsWithinOtherBounds, a0 as ceil, a5 as ceilLog2, aQ as clampAndNormalizeValue, F as clampValue, c as clampVector, ap as columnsToMat3, ao as columnsToMat4, aP as computeBoundsFromPoints, _ as createArray, I as createUninitializedBounds, j as cross, f as default, B as degreesFromRadians, o as determinant2x2, z as determinant3x3, aE as diagonalize3x3, e as distance2BetweenPoints, d as dot, ah as dot2D, aI as estimateMatrixCondition, aT as extentIsWithinOtherExtent, a6 as factorial, b0 as float2CssRGBA, W as floatRGB2HexCode, a$ as floatToHex2, L as floor, ac as gaussian, aj as gaussianAmplitude, ak as gaussianWeight, aS as getAdjustedScalarRange, H as getMajorAxisIndex, aR as getScalarTypeFittingRange, ab as getSeed, U as getSparseOrthogonalMatrix, aL as hex2float, h as hsv2rgb, J as identity, aw as identity3x3, aX as inf, av as invert3x3, p as invertMatrix, aZ as isFinite, ax as isIdentity, ay as isIdentity3x3, M as isInf, a_ as isNaN, i as isNan, X as isPowerOfTwo, w as jacobi, q as jacobiN, P as lab2rgb, aM as lab2xyz, C as ldexp, as as linearSolve3x3, aG as luFactorLinearSystem, aH as luSolveLinearSystem, aB as matrix3x3ToQuaternion, a2 as max, a1 as min, at as multiply3x3_mat3, T as multiply3x3_vect3, m as multiplyAccumulate, ae as multiplyAccumulate2D, K as multiplyMatrix, aC as multiplyQuaternion, x as multiplyScalar, ad as multiplyScalar2D, S as nearestPowerOfTwo, aY as negInf, a9 as nextCombination, n as norm, am as norm2D, l as normalize, R as normalize2D, aD as orthogonalize3x3, af as outer, al as outer2D, t as perpendiculars, aV as pointIsWithinBounds, ag as projectVector, ai as projectVector2D, az as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, aa as randomSeed, N as rgb2hsv, O as rgb2lab, aO as rgb2xyz, Q as round, aA as roundNumber, b as roundVector, A as rowsToMat3, an as rowsToMat4, Z as signedAngleBetweenVectors, aF as singularValueDecomposition3x3, aW as solve3PointCircle, aJ as solveHomogeneousLeastSquares, aK as solveLeastSquares, g as solveLinearSystem, s as subtract, au as transpose3x3, u as uninitializeBounds, aN as xyz2lab, D as xyz2rgb } from './Math/index.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3 } from './../../types';
|
|
1
|
+
import { Vector2, Vector3 } from './../../types';
|
|
2
2
|
import vtkCell, { ICellInitialValues } from './Cell';
|
|
3
3
|
|
|
4
4
|
export interface ITriangleInitialValues extends ICellInitialValues {}
|
|
@@ -11,6 +11,14 @@ export interface IIntersectWithLine {
|
|
|
11
11
|
betweenPoints?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
export interface IIntersectWithTriangle {
|
|
15
|
+
intersect: boolean;
|
|
16
|
+
coplanar: boolean;
|
|
17
|
+
pt1: Vector3;
|
|
18
|
+
pt2: Vector3;
|
|
19
|
+
surfaceId: number;
|
|
20
|
+
}
|
|
21
|
+
|
|
14
22
|
export interface vtkTriangle extends vtkCell {
|
|
15
23
|
/**
|
|
16
24
|
* Get the topological dimensional of the cell (0, 1, 2 or 3).
|
|
@@ -48,23 +56,36 @@ export interface vtkTriangle extends vtkCell {
|
|
|
48
56
|
): IIntersectWithLine;
|
|
49
57
|
|
|
50
58
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
* {
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* }
|
|
67
|
-
|
|
59
|
+
* Get the nearest cell boundary to the specified parametric
|
|
60
|
+
* coordinates and whether the point is inside or outside the cell.
|
|
61
|
+
* @param {Number} subId The sub-id of the cell.
|
|
62
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
63
|
+
* @param {Vector2} pts The points of the cell.
|
|
64
|
+
*/
|
|
65
|
+
cellBoundary(subId: number, pcoords: Vector3, pts: Vector2): boolean;
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the derivatives of the triangle at the specified parametric
|
|
69
|
+
* coordinates.
|
|
70
|
+
* @param {Number} subId - The sub-id of the triangle.
|
|
71
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
72
|
+
* @param {Number[]} values - The values at the points.
|
|
73
|
+
* @param {Number} dim - The dimension.
|
|
74
|
+
* @param {Number[]} derivs - The derivatives.
|
|
75
|
+
*/
|
|
76
|
+
derivatives(
|
|
77
|
+
subId: number,
|
|
78
|
+
pcoords: Vector3,
|
|
79
|
+
values: any,
|
|
80
|
+
dim: number,
|
|
81
|
+
derivs: number[]
|
|
82
|
+
): void;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Evaluates whether the specified point is inside (1), outside (0), or
|
|
86
|
+
* indeterminate (-1) for the cell; computes parametric coordinates, sub-cell
|
|
87
|
+
* ID (if applicable), squared distance to the cell (and closest point if
|
|
88
|
+
* requested), and interpolation weights for the cell.
|
|
68
89
|
*
|
|
69
90
|
* @param {Vector3} x The x point coordinate.
|
|
70
91
|
* @param {Vector3} closestPoint The closest point coordinate.
|
|
@@ -79,7 +100,8 @@ export interface vtkTriangle extends vtkCell {
|
|
|
79
100
|
): IIntersectWithLine;
|
|
80
101
|
|
|
81
102
|
/**
|
|
82
|
-
* Determine global
|
|
103
|
+
* Determine global coordinates (x) from the given subId and parametric
|
|
104
|
+
* coordinates.
|
|
83
105
|
* @param {Vector3} pcoords The parametric coordinates.
|
|
84
106
|
* @param {Vector3} x The x point coordinate.
|
|
85
107
|
* @param {Number[]} weights The number of weights.
|
|
@@ -144,6 +166,31 @@ export function computeNormal(
|
|
|
144
166
|
n: Vector3
|
|
145
167
|
): void;
|
|
146
168
|
|
|
169
|
+
/**
|
|
170
|
+
* Compute the interpolation functions/derivatives
|
|
171
|
+
* @param {Number[]} derivs - The derivatives.
|
|
172
|
+
*/
|
|
173
|
+
export function interpolationDerivs(derivs: number[]): void;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Compute the intersection between two triangles.
|
|
177
|
+
* @param {Vector3} p1 The first point coordinate of the first triangle.
|
|
178
|
+
* @param {Vector3} q1 The second point coordinate of the first triangle.
|
|
179
|
+
* @param {Vector3} r1 The third point coordinate of the first triangle.
|
|
180
|
+
* @param {Vector3} p2 The first point coordinate of the second triangle.
|
|
181
|
+
* @param {Vector3} q2 The second point coordinate of the second triangle.
|
|
182
|
+
* @param {Vector3} r2 The third point coordinate of the second triangle.
|
|
183
|
+
*/
|
|
184
|
+
export function intersectWithTriangle(
|
|
185
|
+
p1: Vector3,
|
|
186
|
+
q1: Vector3,
|
|
187
|
+
r1: Vector3,
|
|
188
|
+
p2: Vector3,
|
|
189
|
+
q2: Vector3,
|
|
190
|
+
r2: Vector3,
|
|
191
|
+
tolerance?: number
|
|
192
|
+
): IIntersectWithTriangle;
|
|
193
|
+
|
|
147
194
|
/**
|
|
148
195
|
* vtkTriangle is a cell which representant a triangle. It contains static
|
|
149
196
|
* method to make some computations directly link to triangle.
|
|
@@ -155,5 +202,7 @@ export declare const vtkTriangle: {
|
|
|
155
202
|
extend: typeof extend;
|
|
156
203
|
computeNormalDirection: typeof computeNormalDirection;
|
|
157
204
|
computeNormal: typeof computeNormal;
|
|
205
|
+
interpolationDerivs: typeof interpolationDerivs;
|
|
206
|
+
intersectWithTriangle: typeof intersectWithTriangle;
|
|
158
207
|
};
|
|
159
208
|
export default vtkTriangle;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkCell from './Cell.js';
|
|
3
|
-
import { d as dot, j as cross, l as normalize, m as multiplyAccumulate, e as distance2BetweenPoints, o as determinant2x2 } from '../Core/Math/index.js';
|
|
3
|
+
import { d as dot, j as cross, l as normalize, m as multiplyAccumulate, e as distance2BetweenPoints, o as determinant2x2, p as invertMatrix } from '../Core/Math/index.js';
|
|
4
4
|
import vtkLine from './Line.js';
|
|
5
5
|
import vtkPlane from './Plane.js';
|
|
6
6
|
|
|
@@ -29,6 +29,18 @@ function computeNormal(v1, v2, v3, n) {
|
|
|
29
29
|
n[2] /= length;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
+
function interpolationDerivs(derivs) {
|
|
33
|
+
// Order: [dN1/dr, dN2/dr, dN3/dr, dN1/ds, dN2/ds, dN3/ds]
|
|
34
|
+
// r-derivatives
|
|
35
|
+
derivs[0] = -1.0;
|
|
36
|
+
derivs[1] = 1.0;
|
|
37
|
+
derivs[2] = 0.0;
|
|
38
|
+
|
|
39
|
+
// s-derivatives
|
|
40
|
+
derivs[3] = -1.0;
|
|
41
|
+
derivs[4] = 0.0;
|
|
42
|
+
derivs[5] = 1.0;
|
|
43
|
+
}
|
|
32
44
|
function intersectWithTriangle(p1, q1, r1, p2, q2, r2) {
|
|
33
45
|
let tolerance = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 1e-6;
|
|
34
46
|
let coplanar = false;
|
|
@@ -242,6 +254,7 @@ function intersectWithTriangle(p1, q1, r1, p2, q2, r2) {
|
|
|
242
254
|
const STATIC = {
|
|
243
255
|
computeNormalDirection,
|
|
244
256
|
computeNormal,
|
|
257
|
+
interpolationDerivs,
|
|
245
258
|
intersectWithTriangle
|
|
246
259
|
};
|
|
247
260
|
|
|
@@ -343,6 +356,18 @@ function vtkTriangle(publicAPI, model) {
|
|
|
343
356
|
outObj.intersect = 0;
|
|
344
357
|
return outObj;
|
|
345
358
|
};
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Evaluates whether the specified point is inside (1), outside (0), or
|
|
362
|
+
* indeterminate (-1) for the cell; computes parametric coordinates, sub-cell
|
|
363
|
+
* ID (if applicable), squared distance to the cell (and closest point if
|
|
364
|
+
* requested), and interpolation weights for the cell.
|
|
365
|
+
*
|
|
366
|
+
* @param {Vector3} x The x point coordinate.
|
|
367
|
+
* @param {Vector3} closestPoint The closest point coordinate.
|
|
368
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
369
|
+
* @param {Number[]} weights The number of weights.
|
|
370
|
+
*/
|
|
346
371
|
publicAPI.evaluatePosition = (x, closestPoint, pcoords, weights) => {
|
|
347
372
|
// will return obj
|
|
348
373
|
const outObj = {
|
|
@@ -505,6 +530,14 @@ function vtkTriangle(publicAPI, model) {
|
|
|
505
530
|
}
|
|
506
531
|
return outObj;
|
|
507
532
|
};
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Determine global coordinates (x) from the given subId and parametric
|
|
536
|
+
* coordinates.
|
|
537
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
538
|
+
* @param {Vector3} x The x point coordinate.
|
|
539
|
+
* @param {Number[]} weights The number of weights.
|
|
540
|
+
*/
|
|
508
541
|
publicAPI.evaluateLocation = (pcoords, x, weights) => {
|
|
509
542
|
const p0 = [];
|
|
510
543
|
const p1 = [];
|
|
@@ -520,6 +553,11 @@ function vtkTriangle(publicAPI, model) {
|
|
|
520
553
|
weights[1] = pcoords[0];
|
|
521
554
|
weights[2] = pcoords[1];
|
|
522
555
|
};
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* Get the distance of the parametric coordinate provided to the cell.
|
|
559
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
560
|
+
*/
|
|
523
561
|
publicAPI.getParametricDistance = pcoords => {
|
|
524
562
|
let pDist;
|
|
525
563
|
let pDistMax = 0.0;
|
|
@@ -542,6 +580,107 @@ function vtkTriangle(publicAPI, model) {
|
|
|
542
580
|
}
|
|
543
581
|
return pDistMax;
|
|
544
582
|
};
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* Get the derivatives of the triangle strip.
|
|
586
|
+
* @param {Number} subId - The sub-id of the triangle.
|
|
587
|
+
* @param {Vector3} pcoords - The parametric coordinates.
|
|
588
|
+
* @param {Number[]} values - The values at the points.
|
|
589
|
+
* @param {Number} dim - The dimension.
|
|
590
|
+
* @param {Number[]} derivs - The derivatives.
|
|
591
|
+
*/
|
|
592
|
+
publicAPI.derivatives = (subId, pcoords, values, dim, derivs) => {
|
|
593
|
+
const x0 = [];
|
|
594
|
+
const x1 = [];
|
|
595
|
+
const x2 = [];
|
|
596
|
+
model.points.getPoint(0, x0);
|
|
597
|
+
model.points.getPoint(1, x1);
|
|
598
|
+
model.points.getPoint(2, x2);
|
|
599
|
+
const n = [];
|
|
600
|
+
const v10 = [];
|
|
601
|
+
const v20 = [];
|
|
602
|
+
const v = [];
|
|
603
|
+
computeNormal(x0, x1, x2, n);
|
|
604
|
+
for (let i = 0; i < 3; i++) {
|
|
605
|
+
v10[i] = x1[i] - x0[i];
|
|
606
|
+
v[i] = x2[i] - x0[i];
|
|
607
|
+
}
|
|
608
|
+
cross(n, v10, v20);
|
|
609
|
+
const lenX = normalize(v10); // check for degenerate triangle
|
|
610
|
+
|
|
611
|
+
if (lenX <= 0.0 || normalize(v20) <= 0.0) {
|
|
612
|
+
// degenerate
|
|
613
|
+
for (let j = 0; j < dim; j++) {
|
|
614
|
+
for (let i = 0; i < 3; i++) {
|
|
615
|
+
derivs[j * dim + i] = 0.0;
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
// 2D coordinates
|
|
622
|
+
const v0 = [0, 0];
|
|
623
|
+
const v1 = [lenX, 0];
|
|
624
|
+
const v2 = [dot(v, v10), dot(v, v20)];
|
|
625
|
+
const functionDerivs = new Array(6);
|
|
626
|
+
interpolationDerivs(functionDerivs);
|
|
627
|
+
|
|
628
|
+
// Compute Jacobian: Jacobian is constant for a triangle.
|
|
629
|
+
const J = [v1[0] - v0[0], v1[1] - v0[1], v2[0] - v0[0], v2[1] - v0[1]];
|
|
630
|
+
|
|
631
|
+
// Compute inverse Jacobian (expects flat array)
|
|
632
|
+
const JI = new Array(4).fill(0.0);
|
|
633
|
+
invertMatrix(J, JI, 2); // returns flat array [JI00, JI01, JI10, JI11]
|
|
634
|
+
|
|
635
|
+
// Compute derivatives
|
|
636
|
+
for (let j = 0; j < dim; j++) {
|
|
637
|
+
let sum0 = 0.0;
|
|
638
|
+
let sum1 = 0.0;
|
|
639
|
+
for (let i = 0; i < 3; i++) {
|
|
640
|
+
sum0 += functionDerivs[i] * values[dim * i + j];
|
|
641
|
+
sum1 += functionDerivs[3 + i] * values[dim * i + j];
|
|
642
|
+
}
|
|
643
|
+
const dBydx = sum0 * JI[0] + sum1 * JI[1];
|
|
644
|
+
const dBydy = sum0 * JI[2] + sum1 * JI[3];
|
|
645
|
+
|
|
646
|
+
// Transform into global system (dot product with global axes)
|
|
647
|
+
derivs[3 * j] = dBydx * v10[0] + dBydy * v20[0];
|
|
648
|
+
derivs[3 * j + 1] = dBydx * v10[1] + dBydy * v20[1];
|
|
649
|
+
derivs[3 * j + 2] = dBydx * v10[2] + dBydy * v20[2];
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
|
|
653
|
+
/**
|
|
654
|
+
* Get the nearest cell boundary to the specified parametric
|
|
655
|
+
* coordinates and whether the point is inside or outside the cell.
|
|
656
|
+
* @param {Number} subId The sub-id of the cell.
|
|
657
|
+
* @param {Vector3} pcoords The parametric coordinates.
|
|
658
|
+
* @param {Vector2} pts The points of the cell.
|
|
659
|
+
*/
|
|
660
|
+
publicAPI.cellBoundary = (subId, pcoords, pts) => {
|
|
661
|
+
const t1 = pcoords[0] - pcoords[1];
|
|
662
|
+
const t2 = 0.5 * (1.0 - pcoords[0]) - pcoords[1];
|
|
663
|
+
const t3 = 2.0 * pcoords[0] + pcoords[1] - 1.0;
|
|
664
|
+
|
|
665
|
+
// compare against three lines in parametric space that divide element
|
|
666
|
+
// into three pieces
|
|
667
|
+
if (t1 >= 0.0 && t2 >= 0.0) {
|
|
668
|
+
pts[0] = model.pointsIds[0];
|
|
669
|
+
pts[1] = model.pointsIds[1];
|
|
670
|
+
} else if (t2 < 0.0 && t3 >= 0.0) {
|
|
671
|
+
pts[0] = model.pointsIds[1];
|
|
672
|
+
pts[1] = model.pointsIds[2];
|
|
673
|
+
} // ( t1 < 0.0 && t3 < 0.0 )
|
|
674
|
+
else {
|
|
675
|
+
pts[0] = model.pointsIds[2];
|
|
676
|
+
pts[1] = model.pointsIds[0];
|
|
677
|
+
}
|
|
678
|
+
if (pcoords[0] < 0.0 || pcoords[1] < 0.0 || pcoords[0] > 1.0 || pcoords[1] > 1.0 || 1.0 - pcoords[0] - pcoords[1] < 0.0) {
|
|
679
|
+
return false; // outside of triangle
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
return true; // inside triangle
|
|
683
|
+
};
|
|
545
684
|
}
|
|
546
685
|
|
|
547
686
|
// ----------------------------------------------------------------------------
|
|
@@ -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;
|