@kitware/vtk.js 24.8.0 → 24.11.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.
Files changed (68) hide show
  1. package/Common/Core/LookupTable.d.ts +6 -6
  2. package/Common/Core/Math/index.js +1 -1
  3. package/Common/Core/Math.js +1 -1
  4. package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
  5. package/Common/Core/ScalarsToColors.d.ts +6 -16
  6. package/Common/DataModel/Box.d.ts +4 -4
  7. package/Common/DataModel/CardinalSpline1D.d.ts +8 -4
  8. package/Common/DataModel/CardinalSpline1D.js +133 -4
  9. package/Common/DataModel/Cell.js +3 -1
  10. package/Common/DataModel/CellTypes.js +6 -1
  11. package/Common/DataModel/ITKHelper.d.ts +54 -0
  12. package/Common/DataModel/KochanekSpline1D.d.ts +8 -4
  13. package/Common/DataModel/KochanekSpline1D.js +103 -2
  14. package/Common/DataModel/Line.d.ts +8 -3
  15. package/Common/DataModel/Line.js +16 -11
  16. package/Common/DataModel/PiecewiseFunction.js +8 -8
  17. package/Common/DataModel/Plane.js +1 -1
  18. package/Common/DataModel/PolyData/Constants.d.ts +6 -0
  19. package/Common/DataModel/PolyLine.d.ts +63 -0
  20. package/Common/DataModel/PolyLine.js +77 -0
  21. package/Common/DataModel/Polygon.js +1 -1
  22. package/Common/DataModel/Spline1D/Constants.js +17 -0
  23. package/Common/DataModel/Spline1D.d.ts +20 -2
  24. package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
  25. package/Common/DataModel/Spline3D.d.ts +4 -9
  26. package/Common/DataModel/Spline3D.js +20 -15
  27. package/Filters/General/ImageCropFilter.d.ts +9 -6
  28. package/Filters/Sources/LineSource.js +1 -1
  29. package/Filters/Sources/PlaneSource.js +1 -1
  30. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  31. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  32. package/Interaction/Manipulators/MouseRangeManipulator.js +23 -6
  33. package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
  34. package/Interaction/Widgets/OrientationMarkerWidget.d.ts +2 -6
  35. package/Rendering/Core/CellPicker.js +53 -32
  36. package/Rendering/Core/Mapper/Constants.d.ts +26 -0
  37. package/Rendering/Core/Mapper.d.ts +5 -21
  38. package/Rendering/Core/Property/Constants.d.ts +24 -0
  39. package/Rendering/Core/Property.d.ts +6 -20
  40. package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
  41. package/Rendering/Core/RenderWindowInteractor.d.ts +223 -121
  42. package/Rendering/Core/ScalarBarActor.d.ts +37 -15
  43. package/Rendering/Core/ScalarBarActor.js +39 -14
  44. package/Rendering/Core/Viewport.d.ts +2 -4
  45. package/Rendering/Core/VolumeMapper/Constants.d.ts +19 -0
  46. package/Rendering/Core/VolumeMapper.d.ts +5 -9
  47. package/Rendering/Core/VolumeProperty.d.ts +5 -13
  48. package/Rendering/Misc/FullScreenRenderWindow.d.ts +3 -2
  49. package/Rendering/OpenGL/RenderWindow.d.ts +28 -10
  50. package/Widgets/Manipulators/LineManipulator.js +1 -1
  51. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  52. package/Widgets/Representations/SplineContextRepresentation.js +27 -9
  53. package/Widgets/Representations/WidgetRepresentation.js +1 -1
  54. package/Widgets/Widgets3D/AngleWidget/behavior.js +10 -5
  55. package/Widgets/Widgets3D/AngleWidget.js +1 -1
  56. package/Widgets/Widgets3D/DistanceWidget/behavior.js +11 -5
  57. package/Widgets/Widgets3D/LabelWidget/behavior.js +10 -4
  58. package/Widgets/Widgets3D/LineWidget/behavior.js +1 -1
  59. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  60. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +7 -5
  61. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  62. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  63. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  64. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -1
  65. package/Widgets/Widgets3D/SplineWidget/state.js +10 -0
  66. package/Widgets/Widgets3D/SplineWidget.js +1 -1
  67. package/index.d.ts +16 -6
  68. package/package.json +43 -43
@@ -22,12 +22,12 @@ export interface vtkLookupTable extends vtkScalarsToColors {
22
22
  /**
23
23
  *
24
24
  */
25
- getAboveRangeColor(): Range;
25
+ getAboveRangeColor(): RGBAColor;
26
26
 
27
27
  /**
28
28
  *
29
29
  */
30
- getAboveRangeColorByReference(): Range;
30
+ getAboveRangeColorByReference(): RGBAColor;
31
31
 
32
32
  /**
33
33
  *
@@ -153,13 +153,13 @@ export interface vtkLookupTable extends vtkScalarsToColors {
153
153
  *
154
154
  * @param aboveRangeColor
155
155
  */
156
- setAboveRangeColor(aboveRangeColor: Range): boolean;
156
+ setAboveRangeColor(aboveRangeColor: RGBAColor): boolean;
157
157
 
158
158
  /**
159
159
  *
160
160
  * @param aboveRangeColor
161
161
  */
162
- setAboveRangeColorFrom(aboveRangeColor: Range): boolean;
162
+ setAboveRangeColorFrom(aboveRangeColor: RGBAColor): boolean;
163
163
 
164
164
  /**
165
165
  *
@@ -177,13 +177,13 @@ export interface vtkLookupTable extends vtkScalarsToColors {
177
177
  *
178
178
  * @param belowRangeColor
179
179
  */
180
- setBelowRangeColor(belowRangeColor: Range): boolean;
180
+ setBelowRangeColor(belowRangeColor: RGBAColor): boolean;
181
181
 
182
182
  /**
183
183
  *
184
184
  * @param belowRangeColor
185
185
  */
186
- setBelowRangeColorFrom(belowRangeColor: Range): boolean;
186
+ setBelowRangeColorFrom(belowRangeColor: RGBAColor): boolean;
187
187
 
188
188
  /**
189
189
  *
@@ -2329,4 +2329,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
2329
2329
  'default': vtkMath
2330
2330
  });
2331
2331
 
2332
- export { binomial as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, isInf as F, rgb2hsv as G, rgb2lab as H, lab2rgb as I, floor as J, round as K, normalize2D as L, nearestPowerOfTwo as M, createUninitializedBounds as N, multiply3x3_vect3 as O, areBoundsInitialized as P, isPowerOfTwo as Q, angleBetweenVectors as R, signedAngleBetweenVectors as S, Pi as T, ceil as U, min as V, max as W, arrayMin as X, arrayMax as Y, ceilLog2 as Z, factorial as _, areMatricesEqual as a, beginCombination as a0, nextCombination as a1, randomSeed as a2, getSeed as a3, gaussian as a4, multiplyScalar2D as a5, multiplyAccumulate2D as a6, outer as a7, projectVector as a8, dot2D as a9, hex2float as aA, lab2xyz as aB, xyz2lab as aC, xyz2rgb as aD, rgb2xyz as aE, clampAndNormalizeValue as aF, getScalarTypeFittingRange as aG, getAdjustedScalarRange as aH, extentIsWithinOtherExtent as aI, boundsIsWithinOtherBounds as aJ, pointIsWithinBounds as aK, solve3PointCircle as aL, inf as aM, negInf as aN, isFinite as aO, isNaN as aP, floatToHex2 as aQ, floatRGB2HexCode as aR, float2CssRGBA as aS, projectVector2D as aa, gaussianAmplitude as ab, gaussianWeight as ac, outer2D as ad, norm2D as ae, LUFactor3x3 as af, LUSolve3x3 as ag, linearSolve3x3 as ah, multiply3x3_mat3 as ai, multiplyMatrix as aj, transpose3x3 as ak, invert3x3 as al, identity3x3 as am, quaternionToMatrix3x3 as an, roundNumber as ao, matrix3x3ToQuaternion as ap, multiplyQuaternion as aq, orthogonalize3x3 as ar, diagonalize3x3 as as, singularValueDecomposition3x3 as at, luFactorLinearSystem as au, luSolveLinearSystem as av, invertMatrix as aw, estimateMatrixCondition as ax, solveHomogeneousLeastSquares as ay, solveLeastSquares as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints as f, subtract 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, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, solveLinearSystem as s, vtkMath as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
2332
+ export { binomial as $, degreesFromRadians as A, areEquals as B, clampValue as C, arrayRange as D, getMajorAxisIndex as E, isInf as F, rgb2hsv as G, rgb2lab as H, lab2rgb as I, floor as J, round as K, normalize2D as L, nearestPowerOfTwo as M, createUninitializedBounds as N, multiply3x3_vect3 as O, areBoundsInitialized as P, isPowerOfTwo as Q, angleBetweenVectors as R, signedAngleBetweenVectors as S, Pi as T, ceil as U, min as V, max as W, arrayMin as X, arrayMax as Y, ceilLog2 as Z, factorial as _, areMatricesEqual as a, beginCombination as a0, nextCombination as a1, randomSeed as a2, getSeed as a3, gaussian as a4, multiplyScalar2D as a5, multiplyAccumulate2D as a6, outer as a7, projectVector as a8, dot2D as a9, hex2float as aA, lab2xyz as aB, xyz2lab as aC, xyz2rgb as aD, rgb2xyz as aE, clampAndNormalizeValue as aF, getScalarTypeFittingRange as aG, getAdjustedScalarRange as aH, extentIsWithinOtherExtent as aI, boundsIsWithinOtherBounds as aJ, pointIsWithinBounds as aK, solve3PointCircle as aL, inf as aM, negInf as aN, isFinite as aO, isNaN as aP, floatToHex2 as aQ, floatRGB2HexCode as aR, float2CssRGBA as aS, projectVector2D as aa, gaussianAmplitude as ab, gaussianWeight as ac, outer2D as ad, norm2D as ae, LUFactor3x3 as af, LUSolve3x3 as ag, linearSolve3x3 as ah, multiply3x3_mat3 as ai, multiplyMatrix as aj, transpose3x3 as ak, invert3x3 as al, identity3x3 as am, quaternionToMatrix3x3 as an, roundNumber as ao, matrix3x3ToQuaternion as ap, multiplyQuaternion as aq, orthogonalize3x3 as ar, diagonalize3x3 as as, singularValueDecomposition3x3 as at, luFactorLinearSystem as au, luSolveLinearSystem as av, invertMatrix as aw, estimateMatrixCondition as ax, solveHomogeneousLeastSquares as ay, solveLeastSquares as az, roundVector as b, computeBoundsFromPoints as c, dot as d, clampVector as e, distance2BetweenPoints 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, jacobiN as p, perpendiculars as q, radiansFromDegrees as r, subtract as s, vtkMath as t, uninitializeBounds as u, vtkMath$1 as v, jacobi as w, multiplyScalar as x, random as y, determinant3x3 as z };
@@ -1,4 +1,4 @@
1
1
  import '@babel/runtime/helpers/slicedToArray';
2
2
  import 'seedrandom';
3
3
  import '../../macros.js';
4
- export { af as LUFactor3x3, ag as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, P as areBoundsInitialized, B as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, D as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, C as clampValue, e as clampVector, c as computeBoundsFromPoints, N as createUninitializedBounds, j as cross, t as default, A as degreesFromRadians, o as determinant2x2, z as determinant3x3, as as diagonalize3x3, f as distance2BetweenPoints, d as dot, a9 as dot2D, ax as estimateMatrixCondition, aI as extentIsWithinOtherExtent, _ as factorial, aS as float2CssRGBA, aR as floatRGB2HexCode, aQ as floatToHex2, J as floor, a4 as gaussian, ab as gaussianAmplitude, ac as gaussianWeight, aH as getAdjustedScalarRange, E as getMajorAxisIndex, aG as getScalarTypeFittingRange, a3 as getSeed, aA as hex2float, h as hsv2rgb, am as identity3x3, aM as inf, al as invert3x3, aw as invertMatrix, aO as isFinite, F as isInf, aP as isNaN, i as isNan, Q as isPowerOfTwo, w as jacobi, p as jacobiN, I as lab2rgb, aB as lab2xyz, ah as linearSolve3x3, au as luFactorLinearSystem, av as luSolveLinearSystem, ap as matrix3x3ToQuaternion, W as max, V as min, ai as multiply3x3_mat3, O as multiply3x3_vect3, m as multiplyAccumulate, a6 as multiplyAccumulate2D, aj as multiplyMatrix, aq as multiplyQuaternion, x as multiplyScalar, a5 as multiplyScalar2D, M as nearestPowerOfTwo, aN as negInf, a1 as nextCombination, n as norm, ae as norm2D, l as normalize, L as normalize2D, ar as orthogonalize3x3, a7 as outer, ad as outer2D, q as perpendiculars, aK as pointIsWithinBounds, a8 as projectVector, aa as projectVector2D, an as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, a2 as randomSeed, G as rgb2hsv, H as rgb2lab, aE as rgb2xyz, K as round, ao as roundNumber, b as roundVector, S as signedAngleBetweenVectors, at as singularValueDecomposition3x3, aL as solve3PointCircle, ay as solveHomogeneousLeastSquares, az as solveLeastSquares, s as solveLinearSystem, g as subtract, ak as transpose3x3, u as uninitializeBounds, aC as xyz2lab, aD as xyz2rgb } from './Math/index.js';
4
+ export { af as LUFactor3x3, ag as LUSolve3x3, T as Pi, k as add, R as angleBetweenVectors, P as areBoundsInitialized, B as areEquals, a as areMatricesEqual, Y as arrayMax, X as arrayMin, D as arrayRange, a0 as beginCombination, $ as binomial, aJ as boundsIsWithinOtherBounds, U as ceil, Z as ceilLog2, aF as clampAndNormalizeValue, C as clampValue, e as clampVector, c as computeBoundsFromPoints, N as createUninitializedBounds, j as cross, t as default, A as degreesFromRadians, o as determinant2x2, z as determinant3x3, as as diagonalize3x3, f as distance2BetweenPoints, d as dot, a9 as dot2D, ax as estimateMatrixCondition, aI as extentIsWithinOtherExtent, _ as factorial, aS as float2CssRGBA, aR as floatRGB2HexCode, aQ as floatToHex2, J as floor, a4 as gaussian, ab as gaussianAmplitude, ac as gaussianWeight, aH as getAdjustedScalarRange, E as getMajorAxisIndex, aG as getScalarTypeFittingRange, a3 as getSeed, aA as hex2float, h as hsv2rgb, am as identity3x3, aM as inf, al as invert3x3, aw as invertMatrix, aO as isFinite, F as isInf, aP as isNaN, i as isNan, Q as isPowerOfTwo, w as jacobi, p as jacobiN, I as lab2rgb, aB as lab2xyz, ah as linearSolve3x3, au as luFactorLinearSystem, av as luSolveLinearSystem, ap as matrix3x3ToQuaternion, W as max, V as min, ai as multiply3x3_mat3, O as multiply3x3_vect3, m as multiplyAccumulate, a6 as multiplyAccumulate2D, aj as multiplyMatrix, aq as multiplyQuaternion, x as multiplyScalar, a5 as multiplyScalar2D, M as nearestPowerOfTwo, aN as negInf, a1 as nextCombination, n as norm, ae as norm2D, l as normalize, L as normalize2D, ar as orthogonalize3x3, a7 as outer, ad as outer2D, q as perpendiculars, aK as pointIsWithinBounds, a8 as projectVector, aa as projectVector2D, an as quaternionToMatrix3x3, r as radiansFromDegrees, y as random, a2 as randomSeed, G as rgb2hsv, H as rgb2lab, aE as rgb2xyz, K as round, ao as roundNumber, b as roundVector, S as signedAngleBetweenVectors, at as singularValueDecomposition3x3, aL as solve3PointCircle, ay as solveHomogeneousLeastSquares, az as solveLeastSquares, g as solveLinearSystem, s as subtract, ak as transpose3x3, u as uninitializeBounds, aC as xyz2lab, aD as xyz2rgb } from './Math/index.js';
@@ -0,0 +1,18 @@
1
+ export declare enum VectorMode {
2
+ MAGNITUDE = 0,
3
+ COMPONENT = 1,
4
+ RGBCOLORS = 2,
5
+ }
6
+
7
+ export declare enum ScalarMappingTarget {
8
+ LUMINANCE = 1,
9
+ LUMINANCE_ALPHA = 2,
10
+ RGB = 3,
11
+ RGBA = 4,
12
+ }
13
+
14
+ declare const _default: {
15
+ VectorMode: typeof VectorMode;
16
+ ScalarMappingTarget: typeof ScalarMappingTarget;
17
+ };
18
+ export default _default;
@@ -1,19 +1,7 @@
1
- import { vtkObject } from './../../interfaces' ;
2
- import { ColorMode } from './../../Rendering/Core/Mapper';
3
- import { Range } from './../../types' ;
4
-
5
- export enum VectorMode {
6
- MAGNITUDE,
7
- COMPONENT,
8
- RGBCOLORS
9
- }
10
-
11
- export enum ScalarMappingTarget {
12
- LUMINANCE,
13
- LUMINANCE_ALPHA,
14
- RGB,
15
- RGBA
16
- }
1
+ import { vtkObject } from './../../interfaces';
2
+ import { ColorMode } from './../../Rendering/Core/Mapper/Constants';
3
+ import { Range } from './../../types';
4
+ import { ScalarMappingTarget, VectorMode } from './ScalarsToColors/Constants';
17
5
 
18
6
  /**
19
7
  *
@@ -370,5 +358,7 @@ export function newInstance(initialValues?: IScalarsToColorsInitialValues): vtkS
370
358
  export declare const vtkScalarsToColors: {
371
359
  newInstance: typeof newInstance;
372
360
  extend: typeof extend;
361
+ VectorMode: typeof VectorMode;
362
+ ScalarMappingTarget: typeof VectorMode;
373
363
  }
374
364
  export default vtkScalarsToColors;
@@ -1,5 +1,5 @@
1
- import { vtkObject } from './../../interfaces' ;
2
- import { Bounds, Point } from './../../types';
1
+ import { vtkObject } from './../../interfaces';
2
+ import { Bounds, Vector3 } from './../../types';
3
3
 
4
4
 
5
5
  export interface IBoxInitialValues {
@@ -22,9 +22,9 @@ export interface vtkBox extends vtkObject {
22
22
 
23
23
  /**
24
24
  *
25
- * @param {Point} x The point coordinate.
25
+ * @param {Vector3} x The point coordinate.
26
26
  */
27
- evaluateFunction(x: Point): number;
27
+ evaluateFunction(x: Vector3): number;
28
28
 
29
29
  /**
30
30
  *
@@ -1,6 +1,5 @@
1
1
  import { Vector3 } from './../../types';
2
- import vtkSpline1D, { ISpline1DInitialValues } from './Spline1D';
3
-
2
+ import vtkSpline1D, { ISpline1DInitialValues, BoundaryCondition } from './Spline1D';
4
3
 
5
4
  export interface ICardinalSpline1DInitialValues extends ISpline1DInitialValues {}
6
5
 
@@ -20,9 +19,14 @@ export interface vtkCardinalSpline1D extends vtkSpline1D {
20
19
  * @param {Number} size
21
20
  * @param {Float32Array} work
22
21
  * @param {Vector3} x
23
- * @param {Vector3} y
22
+ * @param {Vector3} y
23
+ * @param {Object} options
24
+ * @param {BoundaryCondition} options.leftConstraint
25
+ * @param {Number} options.leftValue
26
+ * @param {BoundaryCondition} options.rightConstraint
27
+ * @param {Number} options.rightValue
24
28
  */
25
- computeOpenCoefficients(size: number, work: Float32Array, x: Vector3, y: Vector3): void;
29
+ computeOpenCoefficients(size: number, work: Float32Array, x: Vector3, y: Vector3, options: { leftConstraint: BoundaryCondition, leftValue: number, rightConstraint: BoundaryCondition, rightValue: Number }): void;
26
30
 
27
31
  /**
28
32
  *
@@ -1,7 +1,8 @@
1
1
  import macro from '../../macros.js';
2
2
  import vtkSpline1D from './Spline1D.js';
3
+ import { BoundaryCondition } from './Spline1D/Constants.js';
3
4
 
4
- var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
5
+ var VTK_EPSILON = 0.0001; // ----------------------------------------------------------------------------
5
6
  // vtkCardinalSpline1D methods
6
7
  // ----------------------------------------------------------------------------
7
8
 
@@ -38,9 +39,9 @@ function vtkCardinalSpline1D(publicAPI, model) {
38
39
  var cN = model.coefficients[4 * N + 2];
39
40
  var dN = work[N]; // solve resulting set of equations.
40
41
 
41
- model.coefficients[0 * 4 + 2] = 0;
42
+ model.coefficients[4 * 0 + 2] = 0;
42
43
  work[0] = 0;
43
- model.coefficients[0 * 4 + 3] = 1;
44
+ model.coefficients[4 * 0 + 3] = 1;
44
45
 
45
46
  for (var _k = 1; _k <= N; _k++) {
46
47
  model.coefficients[4 * _k + 1] -= model.coefficients[4 * _k + 0] * model.coefficients[4 * (_k - 1) + 2];
@@ -86,7 +87,135 @@ function vtkCardinalSpline1D(publicAPI, model) {
86
87
 
87
88
 
88
89
  publicAPI.computeOpenCoefficients = function (size, work, x, y) {
89
- vtkErrorMacro('Open splines are not implemented yet!');
90
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
91
+
92
+ if (!model.coefficients || model.coefficients.length !== 4 * size) {
93
+ model.coefficients = new Float32Array(4 * size);
94
+ }
95
+
96
+ var N = size - 1; // develop constraint at leftmost point.
97
+
98
+ switch (options.leftConstraint) {
99
+ case BoundaryCondition.DERIVATIVE:
100
+ // desired slope at leftmost point is leftValue.
101
+ model.coefficients[4 * 0 + 1] = 1.0;
102
+ model.coefficients[4 * 0 + 2] = 0.0;
103
+ work[0] = options.leftValue;
104
+ break;
105
+
106
+ case BoundaryCondition.SECOND_DERIVATIVE:
107
+ // desired second derivative at leftmost point is leftValue.
108
+ model.coefficients[4 * 0 + 1] = 2.0;
109
+ model.coefficients[4 * 0 + 2] = 1.0;
110
+ work[0] = 3.0 * ((y[1] - y[0]) / (x[1] - x[0])) - 0.5 * (x[1] - x[0]) * options.leftValue;
111
+ break;
112
+
113
+ case BoundaryCondition.SECOND_DERIVATIVE_INTERIOR_POINT:
114
+ // desired second derivative at leftmost point is
115
+ // leftValue times second derivative at first interior point.
116
+ model.coefficients[4 * 0 + 1] = 2.0;
117
+
118
+ if (Math.abs(options.leftValue + 2) > VTK_EPSILON) {
119
+ model.coefficients[4 * 0 + 2] = 4.0 * ((0.5 + options.leftValue) / (2.0 + options.leftValue));
120
+ work[0] = 6.0 * ((1.0 + options.leftValue) / (2.0 + options.leftValue)) * ((y[1] - y[0]) / (x[1] - x[0]));
121
+ } else {
122
+ model.coefficients[4 * 0 + 2] = 0;
123
+ work[0] = 0;
124
+ }
125
+
126
+ break;
127
+
128
+ case BoundaryCondition.DEFAULT:
129
+ default:
130
+ // desired slope at leftmost point is derivative from two points
131
+ model.coefficients[4 * 0 + 1] = 1.0;
132
+ model.coefficients[4 * 0 + 2] = 0.0;
133
+ work[0] = y[2] - y[0];
134
+ break;
135
+ }
136
+
137
+ for (var k = 1; k < N; k++) {
138
+ var xlk = x[k] - x[k - 1];
139
+ var xlkp = x[k + 1] - x[k];
140
+ model.coefficients[4 * k + 0] = xlkp;
141
+ model.coefficients[4 * k + 1] = 2 * (xlkp + xlk);
142
+ model.coefficients[4 * k + 2] = xlk;
143
+ work[k] = 3.0 * (xlkp * (y[k] - y[k - 1]) / xlk + xlk * (y[k + 1] - y[k]) / xlkp);
144
+ } // develop constraint at rightmost point.
145
+
146
+
147
+ switch (options.rightConstraint) {
148
+ case BoundaryCondition.DERIVATIVE:
149
+ // desired slope at rightmost point is rightValue
150
+ model.coefficients[4 * N + 0] = 0.0;
151
+ model.coefficients[4 * N + 1] = 1.0;
152
+ work[N] = options.rightValue;
153
+ break;
154
+
155
+ case BoundaryCondition.SECOND_DERIVATIVE:
156
+ // desired second derivative at rightmost point is rightValue.
157
+ model.coefficients[4 * N + 0] = 1.0;
158
+ model.coefficients[4 * N + 1] = 2.0;
159
+ work[N] = 3.0 * ((y[N] - y[N - 1]) / (x[N] - x[N - 1])) + 0.5 * (x[N] - x[N - 1]) * options.rightValue;
160
+ break;
161
+
162
+ case BoundaryCondition.SECOND_DERIVATIVE_INTERIOR_POINT:
163
+ // desired second derivative at rightmost point is
164
+ // rightValue times second derivative at last interior point.
165
+ model.coefficients[4 * N + 1] = 2.0;
166
+
167
+ if (Math.abs(options.rightValue + 2) > VTK_EPSILON) {
168
+ model.coefficients[4 * N + 0] = 4.0 * ((0.5 + options.rightValue) / (2.0 + options.rightValue));
169
+ work[N] = 6.0 * ((1.0 + options.rightValue) / (2.0 + options.rightValue)) * ((y[N] - y[size - 2]) / (x[N] - x[size - 2]));
170
+ } else {
171
+ model.coefficients[4 * N + 0] = 0;
172
+ work[N] = 0;
173
+ }
174
+
175
+ break;
176
+
177
+ case BoundaryCondition.DEFAULT:
178
+ default:
179
+ // desired slope at rightmost point is derivative from two points
180
+ model.coefficients[4 * N + 0] = 0.0;
181
+ model.coefficients[4 * N + 1] = 1.0;
182
+ work[N] = y[N] - y[N - 2];
183
+ break;
184
+ } // solve resulting set of equations.
185
+
186
+
187
+ model.coefficients[4 * 0 + 2] /= model.coefficients[4 * 0 + 1];
188
+ work[0] /= model.coefficients[4 * N + 1];
189
+ model.coefficients[4 * N + 3] = 1;
190
+
191
+ for (var _k5 = 1; _k5 <= N; _k5++) {
192
+ model.coefficients[4 * _k5 + 1] -= model.coefficients[4 * _k5 + 0] * model.coefficients[4 * (_k5 - 1) + 2];
193
+ model.coefficients[4 * _k5 + 2] /= model.coefficients[4 * _k5 + 1];
194
+ work[_k5] = (work[_k5] - model.coefficients[4 * _k5 + 0] * work[_k5 - 1]) / model.coefficients[4 * _k5 + 1];
195
+ }
196
+
197
+ for (var _k6 = N - 1; _k6 >= 0; _k6--) {
198
+ work[_k6] -= model.coefficients[4 * _k6 + 2] * work[_k6 + 1];
199
+ } // the column vector work now contains the first
200
+ // derivative of the spline function at each joint.
201
+ // compute the coefficients of the cubic between
202
+ // each pair of joints.
203
+
204
+
205
+ for (var _k7 = 0; _k7 < N; _k7++) {
206
+ var b = x[_k7 + 1] - x[_k7];
207
+ model.coefficients[4 * _k7 + 0] = y[_k7];
208
+ model.coefficients[4 * _k7 + 1] = work[_k7];
209
+ model.coefficients[4 * _k7 + 2] = 3 * (y[_k7 + 1] - y[_k7]) / (b * b) - (work[_k7 + 1] + 2 * work[_k7]) / b;
210
+ model.coefficients[4 * _k7 + 3] = 2 * (y[_k7] - y[_k7 + 1]) / (b * b * b) + (work[_k7 + 1] + work[_k7]) / (b * b);
211
+ } // the coefficients of a fictitious nth cubic
212
+ // are the same as the coefficients in the first interval
213
+
214
+
215
+ model.coefficients[4 * N + 0] = y[N];
216
+ model.coefficients[4 * N + 1] = work[N];
217
+ model.coefficients[4 * N + 2] = model.coefficients[4 * 0 + 2];
218
+ model.coefficients[4 * N + 3] = model.coefficients[4 * 0 + 3];
90
219
  }; // --------------------------------------------------------------------------
91
220
 
92
221
 
@@ -119,7 +119,9 @@ function vtkCell(publicAPI, model) {
119
119
  publicAPI.intersectWithLine = function (p1, p2, tol, t, x, pcoords, subId) {}; // virtual
120
120
 
121
121
 
122
- publicAPI.evaluatePosition = function (x, closestPoint, subId, pcoords, dist2, weights) {}; // virtual
122
+ publicAPI.evaluatePosition = function (x, closestPoint, subId, pcoords, dist2, weights) {
123
+ macro.vtkErrorMacro('vtkCell.evaluatePosition is not implemented.');
124
+ }; // virtual
123
125
 
124
126
  } // ----------------------------------------------------------------------------
125
127
  // Object factory
@@ -35,6 +35,10 @@ function getTypeIdFromClassName(cellTypeString) {
35
35
 
36
36
  function isLinear(type) {
37
37
  return type < CellType.VTK_QUADRATIC_EDGE || type === CellType.VTK_CONVEX_POINT_SET || type === CellType.VTK_POLYHEDRON;
38
+ }
39
+
40
+ function hasSubCells(cellType) {
41
+ return cellType === CellType.VTK_TRIANGLE_STRIP || cellType === CellType.VTK_POLY_LINE || cellType === CellType.VTK_POLY_VERTEX;
38
42
  } // ----------------------------------------------------------------------------
39
43
  // Static API
40
44
  // ----------------------------------------------------------------------------
@@ -43,7 +47,8 @@ function isLinear(type) {
43
47
  var STATIC = {
44
48
  getClassNameFromTypeId: getClassNameFromTypeId,
45
49
  getTypeIdFromClassName: getTypeIdFromClassName,
46
- isLinear: isLinear
50
+ isLinear: isLinear,
51
+ hasSubCells: hasSubCells
47
52
  }; // ----------------------------------------------------------------------------
48
53
  // vtkCellTypes methods
49
54
  // ----------------------------------------------------------------------------
@@ -0,0 +1,54 @@
1
+ import vtkPolyData from './PolyData';
2
+ import vtkImageData from './ImageData';
3
+
4
+ export interface IOptions {
5
+ pointDataName?: string;
6
+ scalarArrayName?: string;
7
+ cellDataName?: string;
8
+ }
9
+
10
+ /**
11
+ * Converts an itk-wasm Image to a vtk.js vtkImageData.
12
+ * Requires an itk-wasm Image as input.
13
+ * @param itkImage
14
+ * @param {IOptions} [options]
15
+ */
16
+ export function convertItkToVtkImage(itkImage: any, options?: IOptions): vtkImageData;
17
+
18
+ /**
19
+ * Converts a vtk.js vtkImageData to an itk-wasm Image.
20
+ * Requires a vtk.js vtkImageData as input.
21
+ * @param {vtkImageData} vtkImage
22
+ * @param {IOptions} [options]
23
+ */
24
+ export function convertVtkToItkImage(vtkImage: vtkImageData, options?: IOptions): any;
25
+
26
+ /**
27
+ * Converts an itk-wasm PolyData to a vtk.js vtkPolyData.
28
+ * Requires an itk-wasm PolyData as input.
29
+ * @param itkPolyData
30
+ * @param {IOptions} [options]
31
+ */
32
+ export function convertItkToVtkPolyData(itkPolyData: any, options?: IOptions): vtkPolyData;
33
+
34
+ /**
35
+ * Converts a vtk.js vtkPolyData to an itk-wasm PolyData.
36
+ * Requires a vtk.js vtkPolyData as input.
37
+ *
38
+ * @param {vtkPolyData} polyData
39
+ * @param {IOptions} [options]
40
+ */
41
+ export function convertVtkToItkPolyData(polyData: vtkPolyData, options?: IOptions): any;
42
+
43
+
44
+ /**
45
+ * vtkITKHelper is a helper which provides a set of functions to work with
46
+ * itk-wasm module.
47
+ */
48
+ export declare const vtkITKHelper: {
49
+ convertItkToVtkImage: typeof convertItkToVtkImage,
50
+ convertVtkToItkImage: typeof convertVtkToItkImage,
51
+ convertItkToVtkPolyData: typeof convertItkToVtkPolyData,
52
+ convertVtkToItkPolyData: typeof convertVtkToItkPolyData,
53
+ };
54
+ export default vtkITKHelper;
@@ -1,5 +1,4 @@
1
- import vtkSpline1D, { ISpline1DInitialValues } from './Spline1D';
2
-
1
+ import vtkSpline1D, { ISpline1DInitialValues, BoundaryCondition } from './Spline1D';
3
2
 
4
3
  export interface IKochanekSpline1DInitialValues extends ISpline1DInitialValues {
5
4
  tension?: number;
@@ -23,9 +22,14 @@ export interface vtkKochanekSpline1D extends vtkSpline1D {
23
22
  * @param {Number} size
24
23
  * @param {Float32Array} work
25
24
  * @param {Number[]} x
26
- * @param {Number[]} y
25
+ * @param {Number[]} y
26
+ * @param {Object} options
27
+ * @param {BoundaryCondition} options.leftConstraint
28
+ * @param {Number} options.leftValue
29
+ * @param {BoundaryCondition} options.rightConstraint
30
+ * @param {Number} options.rightValue
27
31
  */
28
- computeOpenCoefficients(size: number, work: Float32Array, x: number[], y: number[]): void;
32
+ computeOpenCoefficients(size: number, work: Float32Array, x: number[], y: number[], options: { leftConstraint: BoundaryCondition, leftValue: number, rightConstraint: BoundaryCondition, rightValue: Number }): void;
29
33
 
30
34
  /**
31
35
  *
@@ -1,7 +1,8 @@
1
1
  import macro from '../../macros.js';
2
2
  import vtkSpline1D from './Spline1D.js';
3
+ import { BoundaryCondition } from './Spline1D/Constants.js';
3
4
 
4
- var vtkErrorMacro = macro.vtkErrorMacro; // ----------------------------------------------------------------------------
5
+ var VTK_EPSILON = 0.0001; // ----------------------------------------------------------------------------
5
6
  // vtkKochanekSpline1D methods
6
7
  // ----------------------------------------------------------------------------
7
8
 
@@ -79,7 +80,107 @@ function vtkKochanekSpline1D(publicAPI, model) {
79
80
 
80
81
 
81
82
  publicAPI.computeOpenCoefficients = function (size, work, x, y) {
82
- vtkErrorMacro('Open splines are not implemented yet!');
83
+ var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
84
+
85
+ if (!model.coefficients || model.coefficients.length !== 4 * size) {
86
+ model.coefficients = new Float32Array(4 * size);
87
+ }
88
+
89
+ var N = size - 1;
90
+
91
+ for (var i = 1; i < N; i++) {
92
+ var cs = y[i] - y[i - 1];
93
+ var cd = y[i + 1] - y[i];
94
+ var ds = cs * ((1 - model.tension) * (1 - model.continuity) * (1 + model.bias)) + cd * ((1 - model.tension) * (1 + model.continuity) * (1 - model.bias));
95
+ var dd = cs * ((1 - model.tension) * (1 + model.continuity) * (1 + model.bias)) + cd * ((1 - model.tension) * (1 - model.continuity) * (1 - model.bias)); // adjust deriviatives for non uniform spacing between nodes
96
+
97
+ var n1 = x[i + 1] - x[i];
98
+ var n0 = x[i] - x[i - 1];
99
+ ds *= n0 / (n0 + n1);
100
+ dd *= n1 / (n0 + n1);
101
+ model.coefficients[4 * i + 0] = y[i];
102
+ model.coefficients[4 * i + 1] = dd;
103
+ model.coefficients[4 * i + 2] = ds;
104
+ }
105
+
106
+ model.coefficients[4 * 0 + 0] = y[0];
107
+ model.coefficients[4 * N + 0] = y[N]; // Calculate the deriviatives at the end points
108
+
109
+ switch (options.leftConstraint) {
110
+ // desired slope at leftmost point is leftValue
111
+ case BoundaryCondition.DERIVATIVE:
112
+ model.coefficients[4 * 0 + 1] = options.leftValue;
113
+ break;
114
+
115
+ case BoundaryCondition.SECOND_DERIVATIVE:
116
+ // desired second derivative at leftmost point is leftValue
117
+ model.coefficients[4 * 0 + 1] = (6 * (y[1] - y[0]) - 2 * model.coefficients[4 * 1 + 2] - options.leftValue) / 4;
118
+ break;
119
+
120
+ case BoundaryCondition.SECOND_DERIVATIVE_INTERIOR_POINT:
121
+ // desired second derivative at leftmost point is leftValue
122
+ // times second derivative at first interior point
123
+ if (Math.abs(options.leftValue + 2) > VTK_EPSILON) {
124
+ model.coefficients[4 * 0 + 1] = (3 * (1 + options.leftValue) * (y[1] - y[0]) - (1 + 2 * options.leftValue) * model.coefficients[4 * 1 + 2]) / (2 + options.leftValue);
125
+ } else {
126
+ model.coefficients[4 * 0 + 1] = 0.0;
127
+ }
128
+
129
+ break;
130
+
131
+ case BoundaryCondition.DEFAULT:
132
+ default:
133
+ // desired slope at leftmost point is derivative from two points
134
+ model.coefficients[4 * 0 + 1] = y[2] - y[0];
135
+ break;
136
+ }
137
+
138
+ switch (options.rightConstraint) {
139
+ case BoundaryCondition.DERIVATIVE:
140
+ // desired slope at rightmost point is leftValue
141
+ model.coefficients[4 * N + 2] = options.leftValue;
142
+ break;
143
+
144
+ case BoundaryCondition.SECOND_DERIVATIVE:
145
+ // desired second derivative at rightmost point is leftValue
146
+ model.coefficients[4 * N + 2] = (6 * (y[N] - y[N - 1]) - 2 * model.coefficients[4 * (N - 1) + 1] + options.leftValue) / 4.0;
147
+ break;
148
+
149
+ case BoundaryCondition.SECOND_DERIVATIVE_INTERIOR_POINT:
150
+ // desired second derivative at rightmost point is leftValue
151
+ // times second derivative at last interior point
152
+ if (Math.abs(options.leftValue + 2) > VTK_EPSILON) {
153
+ model.coefficients[4 * N + 2] = (3 * (1 + options.leftValue) * (y[N] - y[N - 1]) - (1 + 2 * options.leftValue) * model.coefficients[4 * (N - 1) + 1]) / (2 + options.leftValue);
154
+ } else {
155
+ model.coefficients[4 * N + 2] = 0.0;
156
+ }
157
+
158
+ break;
159
+
160
+ case BoundaryCondition.DEFAULT:
161
+ default:
162
+ // desired slope at rightmost point is rightValue
163
+ model.coefficients[4 * N + 2] = y[N] - y[N - 2];
164
+ break;
165
+ }
166
+
167
+ for (var _i2 = 0; _i2 < N; _i2++) {
168
+ //
169
+ // c0 = P ; c1 = DD ;
170
+ // i i i i
171
+ //
172
+ // c1 = P ; c2 = DS ;
173
+ // i+1 i+1 i+1 i+1
174
+ //
175
+ // c2 = -3P + 3P - 2DD - DS ;
176
+ // i i i+1 i i+1
177
+ //
178
+ // c3 = 2P - 2P + DD + DS ;
179
+ // i i i+1 i i+1
180
+ //
181
+ model.coefficients[4 * _i2 + 2] = -3 * y[_i2] + 3 * y[_i2 + 1] + -2 * model.coefficients[4 * _i2 + 1] + -1 * model.coefficients[4 * (_i2 + 1) + 2];
182
+ model.coefficients[4 * _i2 + 3] = 2 * y[_i2] + -2 * y[_i2 + 1] + 1 * model.coefficients[4 * _i2 + 1] + 1 * model.coefficients[4 * (_i2 + 1) + 2];
183
+ }
83
184
  }; // --------------------------------------------------------------------------
84
185
 
85
186
 
@@ -1,4 +1,4 @@
1
- import { Vector3 } from './../../types';
1
+ import { Vector3, Vector2 } from './../../types';
2
2
  import vtkCell from './Cell';
3
3
 
4
4
  export enum IntersectionState {
@@ -9,7 +9,7 @@ export enum IntersectionState {
9
9
 
10
10
  interface ILineInitialValues { }
11
11
 
12
- interface IIntersectWithLine {
12
+ export interface IIntersectWithLine {
13
13
  intersect: number;
14
14
  t: number;
15
15
  subId: number;
@@ -50,6 +50,11 @@ export interface vtkLine extends vtkCell {
50
50
  * @param {Vector3} pcoords The parametric coordinates.
51
51
  */
52
52
  intersectWithLine(p1: Vector3, p2: Vector3, tol: number, x: Vector3, pcoords: Vector3): IIntersectWithLine;
53
+
54
+ /**
55
+ * Determine the global coordinates `x' and parametric coordinates `pcoords' in the cell.
56
+ */
57
+ evaluateLocation(pcoords: Vector3, x: Vector3, weights: Vector2): void
53
58
  }
54
59
 
55
60
  /**
@@ -77,7 +82,7 @@ export function newInstance(initialValues?: ILineInitialValues): vtkLine;
77
82
  * t: tolerance of the distance
78
83
  * distance: quared distance between closest point and x
79
84
  * }
80
- *
85
+ * ```
81
86
  * @static
82
87
  * @param {Vector3} x
83
88
  * @param {Vector3} p1
@@ -2,7 +2,7 @@ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import macro from '../../macros.js';
3
3
  import Constants from './Line/Constants.js';
4
4
  import vtkCell from './Cell.js';
5
- import { d as dot, f as distance2BetweenPoints, s as solveLinearSystem } from '../Core/Math/index.js';
5
+ import { d as dot, f as distance2BetweenPoints, s as subtract, g as solveLinearSystem } from '../Core/Math/index.js';
6
6
 
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
 
@@ -69,15 +69,9 @@ function intersection(a1, a2, b1, b2, u, v) {
69
69
  u[0] = 0.0;
70
70
  v[0] = 0.0; // Determine line vectors.
71
71
 
72
- a21[0] = a2[0] - a1[0];
73
- a21[1] = a2[1] - a1[1];
74
- a21[2] = a2[2] - a1[2];
75
- b21[0] = b2[0] - b1[0];
76
- b21[1] = b2[1] - b1[1];
77
- b21[2] = b2[2] - b1[2];
78
- b1a1[0] = b1[0] - a1[0];
79
- b1a1[1] = b1[1] - a1[1];
80
- b1a1[2] = b1[2] - a1[2]; // Compute the system (least squares) matrix.
72
+ subtract(a2, a1, a21);
73
+ subtract(b2, b1, b21);
74
+ subtract(b1, a1, b1a1); // Compute the system (least squares) matrix.
81
75
 
82
76
  var A = [];
83
77
  A[0] = [dot(a21, a21), -dot(a21, b21)];
@@ -237,8 +231,19 @@ function vtkLine(publicAPI, model) {
237
231
  return outObj;
238
232
  };
239
233
 
240
- publicAPI.evaluatePosition = function (x, closestPoint, subId, pcoords, dist2, weights) {}; // virtual
234
+ publicAPI.evaluateLocation = function (pcoords, x, weights) {
235
+ var a1 = [];
236
+ var a2 = [];
237
+ model.points.getPoint(0, a1);
238
+ model.points.getPoint(1, a2);
241
239
 
240
+ for (var i = 0; i < 3; i++) {
241
+ x[i] = a1[i] + pcoords[0] * (a2[i] - a1[i]);
242
+ }
243
+
244
+ weights[0] = 1.0 - pcoords[0];
245
+ weights[1] = pcoords[0];
246
+ };
242
247
  } // ----------------------------------------------------------------------------
243
248
  // Object factory
244
249
  // ----------------------------------------------------------------------------