@kitware/vtk.js 23.4.2 → 24.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +33 -0
- package/Common/Core/DataArray.js +4 -0
- package/Common/Core/Math/index.js +2 -2
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/BoundingBox.js +3 -8
- package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
- package/Common/DataModel/ITKHelper.js +2 -346
- package/Common/DataModel/ImageData.d.ts +23 -6
- package/Common/DataModel/ImageData.js +8 -1
- package/Common/DataModel/PolyData.d.ts +8 -1
- package/Common/DataModel/PolyData.js +5 -3
- package/Common/DataModel/Triangle.js +217 -2
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1249 -0
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/General.js +2 -0
- package/Filters/Sources/CircleSource.js +1 -1
- package/Filters/Sources/PointSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/IO/Core/DataAccessHelper.d.ts +0 -6
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +3 -3
- package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
- package/Interaction/Style/InteractorStyleManipulator.js +42 -28
- package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
- package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
- package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Interaction/Widgets.js +1 -35
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/InteractorObserver.js +11 -10
- package/Rendering/Core/InteractorStyle.js +9 -4
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Prop.js +6 -4
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +24 -17
- package/Rendering/Core/Renderer.js +24 -19
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/Viewport.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/OpenGL/Actor.js +2 -2
- package/Rendering/OpenGL/Actor2D.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +6 -5
- package/Rendering/OpenGL/Camera.js +3 -3
- package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
- package/Rendering/OpenGL/Framebuffer.js +13 -12
- package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
- package/Rendering/OpenGL/HardwareSelector.js +35 -25
- package/Rendering/OpenGL/ImageMapper.js +51 -45
- package/Rendering/OpenGL/ImageSlice.js +2 -2
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
- package/Rendering/OpenGL/PolyDataMapper.js +14 -11
- package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
- package/Rendering/OpenGL/Renderer.js +11 -7
- package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
- package/Rendering/OpenGL/ScalarBarActor.js +2 -2
- package/Rendering/OpenGL/ShaderCache.js +7 -5
- package/Rendering/OpenGL/Skybox.js +11 -9
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +2 -2
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
- package/Rendering/OpenGL/Texture.js +44 -31
- package/Rendering/OpenGL/VertexArrayObject.js +7 -7
- package/Rendering/OpenGL/Volume.js +3 -2
- package/Rendering/OpenGL/VolumeMapper.js +30 -26
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +8 -7
- package/Rendering/WebGPU/Renderer.js +18 -10
- package/Widgets/Core/AbstractWidget.js +5 -4
- package/Widgets/Core/AbstractWidgetFactory.js +2 -1
- package/Widgets/Core/WidgetManager.js +66 -49
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +1 -1
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
- package/Widgets/SVG/SVGRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/EllipseWidget.js +0 -1
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
- package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +79 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/LineWidget.js +0 -1
- package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
- package/Widgets/Widgets3D/RectangleWidget.js +0 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
- package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
- package/index.d.ts +1 -2
- package/interfaces.d.ts +16 -3
- package/macros.d.ts +26 -1
- package/macros.js +51 -19
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/Interaction/Widgets/AbstractWidget.js +0 -104
- package/Interaction/Widgets/DistanceRepresentation.js +0 -116
- package/Interaction/Widgets/DistanceWidget.js +0 -77
- package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
- package/Interaction/Widgets/HandleRepresentation.js +0 -100
- package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
- package/Interaction/Widgets/HandleWidget.js +0 -194
- package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
- package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
- package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
- package/Interaction/Widgets/LabelRepresentation.js +0 -325
- package/Interaction/Widgets/LabelWidget.js +0 -65
- package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
- package/Interaction/Widgets/LineRepresentation.js +0 -498
- package/Interaction/Widgets/LineWidget/Constants.js +0 -11
- package/Interaction/Widgets/LineWidget.js +0 -296
- package/Interaction/Widgets/PointPlacer.js +0 -51
- package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
- package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
- package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
- package/Interaction/Widgets/WidgetRepresentation.js +0 -121
- package/Widgets/Representations/SphereContextRepresentation.js +0 -131
- package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
- package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
- package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
- package/Widgets/Widgets3D/SphereWidget.js +0 -62
package/BREAKING_CHANGES.md
CHANGED
|
@@ -1,3 +1,36 @@
|
|
|
1
|
+
## From 23.x to 24
|
|
2
|
+
|
|
3
|
+
All old-style widgets except OrientationMarkerWidget and PiecewiseGaussianWidget have been removed.
|
|
4
|
+
|
|
5
|
+
| **Old-style/deprecated widget** | **New-style widget** |
|
|
6
|
+
|-----------------------------------|---------------------------------|
|
|
7
|
+
| `Sources/Interaction/Widgets/...` | `Sources/Widgets/Widgets3D/...` |
|
|
8
|
+
| DistanceWidget | DistanceWidget |
|
|
9
|
+
| HandleWidget | PolyLineWidget |
|
|
10
|
+
| ImageCroppingRegionsWidget | ImageCroppingWidget |
|
|
11
|
+
| LabelWidget | LabelWidget |
|
|
12
|
+
| LineWidget | LineWidget |
|
|
13
|
+
| OrientationMarkerWidget (kept) | *not implemented* |
|
|
14
|
+
| PiecewiseGaussianWidget (kept) | *not implemented* |
|
|
15
|
+
| ResliceCursor | ResliceCursorWidget |
|
|
16
|
+
|
|
17
|
+
- In SVGLandmarkRepresentation: `model.showCircle` is replaced by `model.circleProps.visible`
|
|
18
|
+
|
|
19
|
+
## From 22.x to 23
|
|
20
|
+
|
|
21
|
+
- **imagemapper**: The original behavior of the image mapper was that if a lookup table is provided,
|
|
22
|
+
it mapped the lookup table's scalar range by default. The new behavior disables using the lookup
|
|
23
|
+
table scalar range by default. Instead, the window/level values are used.
|
|
24
|
+
|
|
25
|
+
## From 21.x to 22
|
|
26
|
+
|
|
27
|
+
- `config/rules-linter.js` is now gone.
|
|
28
|
+
- **AbstractMapper**: Changed removeClippingPlane to use instance instead of index.
|
|
29
|
+
|
|
30
|
+
## From 20.x to 21
|
|
31
|
+
|
|
32
|
+
SplineWidget's handles now scale up automatically.
|
|
33
|
+
|
|
1
34
|
## From 19.x to 20
|
|
2
35
|
|
|
3
36
|
In ShapeWidget:
|
package/Common/Core/DataArray.js
CHANGED
|
@@ -337,6 +337,10 @@ function vtkDataArray(publicAPI, model) {
|
|
|
337
337
|
|
|
338
338
|
|
|
339
339
|
publicAPI.getState = function () {
|
|
340
|
+
if (model.deleted) {
|
|
341
|
+
return null;
|
|
342
|
+
}
|
|
343
|
+
|
|
340
344
|
var jsonArchive = _objectSpread(_objectSpread({}, model), {}, {
|
|
341
345
|
vtkClass: publicAPI.getClassName()
|
|
342
346
|
}); // Convert typed array to regular array
|
|
@@ -829,7 +829,7 @@ function jacobiN(a, n, w, v) {
|
|
|
829
829
|
|
|
830
830
|
for (i = j + 1; i < n; i++) {
|
|
831
831
|
// boundary incorrect, shifted already
|
|
832
|
-
if (w[i] >= tmp) {
|
|
832
|
+
if (w[i] >= tmp || Math.abs(w[i] - tmp) < VTK_SMALL_NUMBER) {
|
|
833
833
|
// why exchange if same?
|
|
834
834
|
k = i;
|
|
835
835
|
tmp = w[k];
|
|
@@ -2329,4 +2329,4 @@ var vtkMath$1 = /*#__PURE__*/Object.freeze({
|
|
|
2329
2329
|
'default': vtkMath
|
|
2330
2330
|
});
|
|
2331
2331
|
|
|
2332
|
-
export { binomial as $,
|
|
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, jacobi as t, uninitializeBounds as u, vtkMath$1 as v, vtkMath as w, multiplyScalar as x, random as y, determinant3x3 as z };
|
package/Common/Core/Math.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@babel/runtime/helpers/slicedToArray';
|
|
2
2
|
import 'seedrandom';
|
|
3
3
|
import '../../macros.js';
|
|
4
|
-
export {
|
|
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, w 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, t 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';
|
|
@@ -53,7 +53,6 @@ function _addPoint(bounds) {
|
|
|
53
53
|
bounds[3] = yMax > (arguments.length <= 2 ? undefined : arguments[2]) ? yMax : arguments.length <= 2 ? undefined : arguments[2];
|
|
54
54
|
bounds[4] = zMin < (arguments.length <= 3 ? undefined : arguments[3]) ? zMin : arguments.length <= 3 ? undefined : arguments[3];
|
|
55
55
|
bounds[5] = zMax > (arguments.length <= 3 ? undefined : arguments[3]) ? zMax : arguments.length <= 3 ? undefined : arguments[3];
|
|
56
|
-
return bounds;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
function _addBounds(bounds, xMin, xMax, yMin, yMax, zMin, zMax) {
|
|
@@ -80,8 +79,6 @@ function _addBounds(bounds, xMin, xMax, yMin, yMax, zMin, zMax) {
|
|
|
80
79
|
bounds[4] = Math.min(zMin, _zMin);
|
|
81
80
|
bounds[5] = Math.max(zMax, _zMax);
|
|
82
81
|
}
|
|
83
|
-
|
|
84
|
-
return bounds;
|
|
85
82
|
}
|
|
86
83
|
|
|
87
84
|
function _setMinPoint(bounds, x, y, z) {
|
|
@@ -127,7 +124,6 @@ function _inflate(bounds, delta) {
|
|
|
127
124
|
bounds[3] += delta;
|
|
128
125
|
bounds[4] -= delta;
|
|
129
126
|
bounds[5] += delta;
|
|
130
|
-
return bounds;
|
|
131
127
|
}
|
|
132
128
|
|
|
133
129
|
function _scale(bounds, sx, sy, sz) {
|
|
@@ -237,8 +233,6 @@ function _getCorners(bounds, corners) {
|
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
235
|
}
|
|
240
|
-
|
|
241
|
-
return corners;
|
|
242
236
|
} // Computes the two corners with minimal and miximal coordinates
|
|
243
237
|
|
|
244
238
|
function _computeCornerPoints(bounds, point1, point2) {
|
|
@@ -248,7 +242,6 @@ function _computeCornerPoints(bounds, point1, point2) {
|
|
|
248
242
|
point2[0] = bounds[1];
|
|
249
243
|
point2[1] = bounds[3];
|
|
250
244
|
point2[2] = bounds[5];
|
|
251
|
-
return point1;
|
|
252
245
|
}
|
|
253
246
|
|
|
254
247
|
function _computeScale(bounds) {
|
|
@@ -564,7 +557,9 @@ var BoundingBox = /*#__PURE__*/function () {
|
|
|
564
557
|
this.bounds = refBounds;
|
|
565
558
|
|
|
566
559
|
if (!this.bounds) {
|
|
567
|
-
this.bounds = new Float64Array(
|
|
560
|
+
this.bounds = new Float64Array(6);
|
|
561
|
+
|
|
562
|
+
_setBounds(this.bounds, INIT_BOUNDS);
|
|
568
563
|
}
|
|
569
564
|
}
|
|
570
565
|
|
|
@@ -242,11 +242,15 @@ function vtkFieldData(publicAPI, model) {
|
|
|
242
242
|
|
|
243
243
|
publicAPI.getState = function () {
|
|
244
244
|
var result = superGetState();
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
245
|
+
|
|
246
|
+
if (result) {
|
|
247
|
+
result.arrays = model.arrays.map(function (item) {
|
|
248
|
+
return {
|
|
249
|
+
data: item.data.getState()
|
|
250
|
+
};
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
250
254
|
return result;
|
|
251
255
|
};
|
|
252
256
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import macro from '../../macros.js';
|
|
2
2
|
import vtkImageData from './ImageData.js';
|
|
3
|
-
import vtkPolyData from './PolyData.js';
|
|
4
3
|
import vtkDataArray from '../Core/DataArray.js';
|
|
5
4
|
|
|
6
5
|
var vtkErrorMacro = macro.vtkErrorMacro; // see itk.js PixelTypes.js
|
|
@@ -43,7 +42,6 @@ var ITKWASMPixelTypes = {
|
|
|
43
42
|
VariableSizeMatrix: 'VariableSizeMatrix'
|
|
44
43
|
};
|
|
45
44
|
var vtkArrayTypeToItkComponentType = new Map([['Uint8Array', 'uint8'], ['Int8Array', 'int8'], ['Uint16Array', 'uint16'], ['Int16Array', 'int16'], ['Uint32Array', 'uint32'], ['Int32Array', 'int32'], ['Float32Array', 'float32'], ['Float64Array', 'float64']]);
|
|
46
|
-
var itkComponentTypeToVtkArrayType = new Map([['uint8', 'Uint8Array'], ['int8', 'Int8Array'], ['uint16', 'Uint16Array'], ['int16', 'Int16Array'], ['uint32', 'Uint32Array'], ['int32', 'Int32Array'], ['float32', 'Float32Array'], ['float64', 'Float64Array']]);
|
|
47
45
|
/**
|
|
48
46
|
* Converts an itk-wasm Image to a vtk.js vtkImageData.
|
|
49
47
|
*
|
|
@@ -158,7 +156,7 @@ function convertItkToVtkImage(itkImage) {
|
|
|
158
156
|
break;
|
|
159
157
|
|
|
160
158
|
default:
|
|
161
|
-
vtkErrorMacro("Cannot handle unexpected
|
|
159
|
+
vtkErrorMacro("Cannot handle unexpected ITK.js pixel type ".concat(itkImage.imageType.pixelType));
|
|
162
160
|
return null;
|
|
163
161
|
}
|
|
164
162
|
|
|
@@ -220,352 +218,10 @@ function convertVtkToItkImage(vtkImage) {
|
|
|
220
218
|
|
|
221
219
|
return itkImage;
|
|
222
220
|
}
|
|
223
|
-
/**
|
|
224
|
-
* Converts an itk-wasm PolyData to a vtk.js vtkPolyData.
|
|
225
|
-
*
|
|
226
|
-
* Requires an itk-wasm PolyData as input.
|
|
227
|
-
*/
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
function convertItkToVtkPolyData(itkPolyData) {
|
|
231
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
232
|
-
var pointDataArrays = [];
|
|
233
|
-
|
|
234
|
-
if (itkPolyData.pointData.length) {
|
|
235
|
-
pointDataArrays.push({
|
|
236
|
-
data: {
|
|
237
|
-
vtkClass: 'vtkDataArray',
|
|
238
|
-
name: options.pointDataName || 'PointData',
|
|
239
|
-
numberOfComponents: itkPolyData.polyDataType.pointPixelComponents,
|
|
240
|
-
size: itkPolyData.pointData.length,
|
|
241
|
-
dataType: itkComponentTypeToVtkArrayType.get(itkPolyData.polyDataType.pointPixelComponentType),
|
|
242
|
-
buffer: itkPolyData.pointData.buffer,
|
|
243
|
-
values: itkPolyData.pointData
|
|
244
|
-
}
|
|
245
|
-
});
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
var cellDataArrays = [];
|
|
249
|
-
|
|
250
|
-
if (itkPolyData.cellData.length) {
|
|
251
|
-
cellDataArrays.push({
|
|
252
|
-
data: {
|
|
253
|
-
vtkClass: 'vtkDataArray',
|
|
254
|
-
name: options.cellDataName || 'CellData',
|
|
255
|
-
numberOfComponents: itkPolyData.polyDataType.pointPixelComponents,
|
|
256
|
-
size: itkPolyData.cellData.length,
|
|
257
|
-
dataType: itkComponentTypeToVtkArrayType.get(itkPolyData.polyDataType.pointPixelComponentType),
|
|
258
|
-
buffer: itkPolyData.cellData.buffer,
|
|
259
|
-
values: itkPolyData.cellData
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
var vtkPolyDataModel = {
|
|
265
|
-
points: {
|
|
266
|
-
vtkClass: 'vtkPoints',
|
|
267
|
-
name: '_points',
|
|
268
|
-
numberOfComponents: 3,
|
|
269
|
-
size: itkPolyData.numberOfPoints,
|
|
270
|
-
dataType: 'Float32Array',
|
|
271
|
-
buffer: itkPolyData.points.buffer,
|
|
272
|
-
values: itkPolyData.points
|
|
273
|
-
},
|
|
274
|
-
verts: {
|
|
275
|
-
vtkClass: 'vtkCellArray',
|
|
276
|
-
name: '_verts',
|
|
277
|
-
numberOfComponents: 1,
|
|
278
|
-
size: itkPolyData.verticesBufferSize,
|
|
279
|
-
dataType: 'Uint32Array',
|
|
280
|
-
buffer: itkPolyData.vertices.buffer,
|
|
281
|
-
values: itkPolyData.vertices
|
|
282
|
-
},
|
|
283
|
-
lines: {
|
|
284
|
-
vtkClass: 'vtkCellArray',
|
|
285
|
-
name: '_lines',
|
|
286
|
-
numberOfComponents: 1,
|
|
287
|
-
size: itkPolyData.linesBufferSize,
|
|
288
|
-
dataType: 'Uint32Array',
|
|
289
|
-
buffer: itkPolyData.lines.buffer,
|
|
290
|
-
values: itkPolyData.lines
|
|
291
|
-
},
|
|
292
|
-
polys: {
|
|
293
|
-
vtkClass: 'vtkCellArray',
|
|
294
|
-
name: '_polys',
|
|
295
|
-
numberOfComponents: 1,
|
|
296
|
-
size: itkPolyData.polygonsBufferSize,
|
|
297
|
-
dataType: 'Uint32Array',
|
|
298
|
-
buffer: itkPolyData.polygons.buffer,
|
|
299
|
-
values: itkPolyData.polygons
|
|
300
|
-
},
|
|
301
|
-
strips: {
|
|
302
|
-
vtkClass: 'vtkCellArray',
|
|
303
|
-
name: '_strips',
|
|
304
|
-
numberOfComponents: 1,
|
|
305
|
-
size: itkPolyData.triangleStripsBufferSize,
|
|
306
|
-
dataType: 'Uint32Array',
|
|
307
|
-
buffer: itkPolyData.triangleStrips.buffer,
|
|
308
|
-
values: itkPolyData.triangleStrips
|
|
309
|
-
},
|
|
310
|
-
pointData: {
|
|
311
|
-
vtkClass: 'vtkDataSetAttributes',
|
|
312
|
-
activeGlobalIds: -1,
|
|
313
|
-
activeNormals: -1,
|
|
314
|
-
activePedigreeIds: -1,
|
|
315
|
-
activeScalars: -1,
|
|
316
|
-
activeTCoords: -1,
|
|
317
|
-
activeTensors: -1,
|
|
318
|
-
activeVectors: -1,
|
|
319
|
-
copyFieldFlags: [],
|
|
320
|
-
doCopyAllOff: false,
|
|
321
|
-
doCopyAllOn: true,
|
|
322
|
-
arrays: pointDataArrays
|
|
323
|
-
},
|
|
324
|
-
cellData: {
|
|
325
|
-
vtkClass: 'vtkDataSetAttributes',
|
|
326
|
-
activeGlobalIds: -1,
|
|
327
|
-
activeNormals: -1,
|
|
328
|
-
activePedigreeIds: -1,
|
|
329
|
-
activeScalars: -1,
|
|
330
|
-
activeTCoords: -1,
|
|
331
|
-
activeTensors: -1,
|
|
332
|
-
activeVectors: -1,
|
|
333
|
-
copyFieldFlags: [],
|
|
334
|
-
doCopyAllOff: false,
|
|
335
|
-
doCopyAllOn: true,
|
|
336
|
-
arrays: cellDataArrays
|
|
337
|
-
}
|
|
338
|
-
}; // Create VTK PolyData
|
|
339
|
-
|
|
340
|
-
var polyData = vtkPolyData.newInstance(vtkPolyDataModel);
|
|
341
|
-
var pd = polyData.getPointData();
|
|
342
|
-
var cd = polyData.getCellData();
|
|
343
|
-
|
|
344
|
-
if (itkPolyData.pointData.length) {
|
|
345
|
-
// Associate the point data that are 3D vectors / tensors
|
|
346
|
-
switch (ITKWASMPixelTypes[itkPolyData.polyDataType.pointPixelType]) {
|
|
347
|
-
case ITKWASMPixelTypes.Scalar:
|
|
348
|
-
pd.setScalars(pd.getArrayByIndex(0));
|
|
349
|
-
break;
|
|
350
|
-
|
|
351
|
-
case ITKWASMPixelTypes.RGB:
|
|
352
|
-
break;
|
|
353
|
-
|
|
354
|
-
case ITKWASMPixelTypes.RGBA:
|
|
355
|
-
break;
|
|
356
|
-
|
|
357
|
-
case ITKWASMPixelTypes.Offset:
|
|
358
|
-
break;
|
|
359
|
-
|
|
360
|
-
case ITKWASMPixelTypes.Vector:
|
|
361
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 3) {
|
|
362
|
-
pd.setVectors(pd.getArrayByIndex(0));
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
break;
|
|
366
|
-
|
|
367
|
-
case ITKWASMPixelTypes.Point:
|
|
368
|
-
break;
|
|
369
|
-
|
|
370
|
-
case ITKWASMPixelTypes.CovariantVector:
|
|
371
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 3) {
|
|
372
|
-
pd.setVectors(pd.getArrayByIndex(0));
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
break;
|
|
376
|
-
|
|
377
|
-
case ITKWASMPixelTypes.SymmetricSecondRankTensor:
|
|
378
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 6) {
|
|
379
|
-
pd.setTensors(pd.getArrayByIndex(0));
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
break;
|
|
383
|
-
|
|
384
|
-
case ITKWASMPixelTypes.DiffusionTensor3D:
|
|
385
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 6) {
|
|
386
|
-
pd.setTensors(pd.getArrayByIndex(0));
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
break;
|
|
390
|
-
|
|
391
|
-
case ITKWASMPixelTypes.Complex:
|
|
392
|
-
break;
|
|
393
|
-
|
|
394
|
-
case ITKWASMPixelTypes.FixedArray:
|
|
395
|
-
break;
|
|
396
|
-
|
|
397
|
-
case ITKWASMPixelTypes.Array:
|
|
398
|
-
break;
|
|
399
|
-
|
|
400
|
-
case ITKWASMPixelTypes.Matrix:
|
|
401
|
-
break;
|
|
402
|
-
|
|
403
|
-
case ITKWASMPixelTypes.VariableLengthVector:
|
|
404
|
-
break;
|
|
405
|
-
|
|
406
|
-
case ITKWASMPixelTypes.VariableSizeMatrix:
|
|
407
|
-
break;
|
|
408
|
-
|
|
409
|
-
default:
|
|
410
|
-
vtkErrorMacro("Cannot handle unexpected itk-wasm pixel type ".concat(itkPolyData.polyDataType.pointPixelType));
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
if (itkPolyData.cellData.length) {
|
|
416
|
-
// Associate the cell data that are 3D vectors / tensors
|
|
417
|
-
switch (ITKWASMPixelTypes[itkPolyData.polyDataType.cellPixelType]) {
|
|
418
|
-
case ITKWASMPixelTypes.Scalar:
|
|
419
|
-
cd.setScalars(cd.getArrayByIndex(0));
|
|
420
|
-
break;
|
|
421
|
-
|
|
422
|
-
case ITKWASMPixelTypes.RGB:
|
|
423
|
-
break;
|
|
424
|
-
|
|
425
|
-
case ITKWASMPixelTypes.RGBA:
|
|
426
|
-
break;
|
|
427
|
-
|
|
428
|
-
case ITKWASMPixelTypes.Offset:
|
|
429
|
-
break;
|
|
430
|
-
|
|
431
|
-
case ITKWASMPixelTypes.Vector:
|
|
432
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 3) {
|
|
433
|
-
cd.setVectors(cd.getArrayByIndex(0));
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
break;
|
|
437
|
-
|
|
438
|
-
case ITKWASMPixelTypes.Point:
|
|
439
|
-
break;
|
|
440
|
-
|
|
441
|
-
case ITKWASMPixelTypes.CovariantVector:
|
|
442
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 3) {
|
|
443
|
-
cd.setVectors(cd.getArrayByIndex(0));
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
break;
|
|
447
|
-
|
|
448
|
-
case ITKWASMPixelTypes.SymmetricSecondRankTensor:
|
|
449
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 6) {
|
|
450
|
-
cd.setTensors(cd.getArrayByIndex(0));
|
|
451
|
-
}
|
|
452
|
-
|
|
453
|
-
break;
|
|
454
|
-
|
|
455
|
-
case ITKWASMPixelTypes.DiffusionTensor3D:
|
|
456
|
-
if (itkPolyData.polyDataType.pointPixelComponents === 6) {
|
|
457
|
-
cd.setTensors(cd.getArrayByIndex(0));
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
break;
|
|
461
|
-
|
|
462
|
-
case ITKWASMPixelTypes.Complex:
|
|
463
|
-
break;
|
|
464
|
-
|
|
465
|
-
case ITKWASMPixelTypes.FixedArray:
|
|
466
|
-
break;
|
|
467
|
-
|
|
468
|
-
case ITKWASMPixelTypes.Array:
|
|
469
|
-
break;
|
|
470
|
-
|
|
471
|
-
case ITKWASMPixelTypes.Matrix:
|
|
472
|
-
break;
|
|
473
|
-
|
|
474
|
-
case ITKWASMPixelTypes.VariableLengthVector:
|
|
475
|
-
break;
|
|
476
|
-
|
|
477
|
-
case ITKWASMPixelTypes.VariableSizeMatrix:
|
|
478
|
-
break;
|
|
479
|
-
|
|
480
|
-
default:
|
|
481
|
-
vtkErrorMacro("Cannot handle unexpected itk-wasm pixel type ".concat(itkPolyData.polyDataType.pointPixelType));
|
|
482
|
-
return null;
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
return polyData;
|
|
487
|
-
}
|
|
488
|
-
/**
|
|
489
|
-
* Converts a vtk.js vtkPolyData to an itk-wasm PolyData.
|
|
490
|
-
*
|
|
491
|
-
* Requires a vtk.js vtkPolyData as input.
|
|
492
|
-
*
|
|
493
|
-
*/
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
function convertVtkToItkPolyData(polyData) {
|
|
497
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
498
|
-
var itkPolyData = {
|
|
499
|
-
polyDataType: {
|
|
500
|
-
pointPixelComponentType: 'float32',
|
|
501
|
-
pointPixelComponents: 1,
|
|
502
|
-
pointPixelType: 'Scalar',
|
|
503
|
-
cellPixelComponentType: 'float32',
|
|
504
|
-
cellPixelComponents: 1,
|
|
505
|
-
cellPixelType: 'Scalar'
|
|
506
|
-
},
|
|
507
|
-
numberOfPoints: polyData.getNumberOfPoints(),
|
|
508
|
-
points: polyData.getPoints().getData(),
|
|
509
|
-
verticesBufferSize: polyData.getVerts().getNumberOfValues(),
|
|
510
|
-
vertices: polyData.getVerts().getData(),
|
|
511
|
-
linesBufferSize: polyData.getLines().getNumberOfValues(),
|
|
512
|
-
lines: polyData.getLines().getData(),
|
|
513
|
-
polygonsBufferSize: polyData.getPolys().getNumberOfValues(),
|
|
514
|
-
polygons: polyData.getPolys().getData(),
|
|
515
|
-
triangleStripsBufferSize: polyData.getStrips().getNumberOfValues(),
|
|
516
|
-
triangleStrips: polyData.getStrips().getData(),
|
|
517
|
-
numberOfPointPixels: 0,
|
|
518
|
-
pointData: new Float32Array(),
|
|
519
|
-
numberOfCellPixels: 0,
|
|
520
|
-
cellData: new Float32Array()
|
|
521
|
-
};
|
|
522
|
-
var pd = polyData.getPointData();
|
|
523
|
-
|
|
524
|
-
if (pd.getNumberOfArrays()) {
|
|
525
|
-
var pdArray = options.pointDataName ? pd.getArrayByName(options.pointDataName) : pd.getArrayByIndex(0);
|
|
526
|
-
itkPolyData.numberOfPointPixels = pdArray.getNumberOfTuples();
|
|
527
|
-
itkPolyData.pointData = pdArray.getData();
|
|
528
|
-
itkPolyData.polyDataType.pointPixelComponentType = vtkArrayTypeToItkComponentType.get(pdArray.getDataType()); // default to the same type
|
|
529
|
-
|
|
530
|
-
itkPolyData.polyDataType.cellPixelComponentType = itkPolyData.polyDataType.pointPixelComponentType;
|
|
531
|
-
itkPolyData.polyDataType.pointPixelComponents = pdArray.getNumberOfComponents();
|
|
532
|
-
itkPolyData.polyDataType.cellPixelComponents = itkPolyData.polyDataType.pointPixelComponents;
|
|
533
|
-
|
|
534
|
-
if (pd.getTensors() === pdArray) {
|
|
535
|
-
itkPolyData.polyDataType.pointPixelType = ITKWASMPixelTypes.SymmetricSecondRankTensor;
|
|
536
|
-
} else if (pd.getVectors() === pdArray) {
|
|
537
|
-
itkPolyData.polyDataType.pointPixelType = ITKWASMPixelTypes.Vector;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
itkPolyData.polyDataType.cellPixelType = itkPolyData.polyDataType.pointPixelType;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
var cd = polyData.getCellData();
|
|
544
|
-
|
|
545
|
-
if (cd.getNumberOfArrays()) {
|
|
546
|
-
var cdArray = options.cellDataName ? pd.getArrayByName(options.cellDataName) : pd.getArrayByIndex(0);
|
|
547
|
-
itkPolyData.numberOfCellPixels = cdArray.getNumberOfTuples();
|
|
548
|
-
itkPolyData.cellData = cdArray.getData();
|
|
549
|
-
itkPolyData.polyDataType.cellPixelComponentType = vtkArrayTypeToItkComponentType.get(cdArray.getDataType());
|
|
550
|
-
itkPolyData.polyDataType.cellPixelComponents = cdArray.getNumberOfComponents();
|
|
551
|
-
|
|
552
|
-
if (cd.getTensors() === cdArray) {
|
|
553
|
-
itkPolyData.polyDataType.cellPixelType = ITKWASMPixelTypes.SymmetricSecondRankTensor;
|
|
554
|
-
} else if (cd.getVectors() === cdArray) {
|
|
555
|
-
itkPolyData.polyDataType.cellPixelType = ITKWASMPixelTypes.Vector;
|
|
556
|
-
} else {
|
|
557
|
-
itkPolyData.polyDataType.cellPixelType = ITKWASMPixelTypes.Scalar;
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
return itkPolyData;
|
|
562
|
-
}
|
|
563
221
|
|
|
564
222
|
var ITKHelper = {
|
|
565
223
|
convertItkToVtkImage: convertItkToVtkImage,
|
|
566
|
-
convertVtkToItkImage: convertVtkToItkImage
|
|
567
|
-
convertItkToVtkPolyData: convertItkToVtkPolyData,
|
|
568
|
-
convertVtkToItkPolyData: convertVtkToItkPolyData
|
|
224
|
+
convertVtkToItkImage: convertVtkToItkImage
|
|
569
225
|
};
|
|
570
226
|
|
|
571
227
|
export { ITKHelper as default };
|
|
@@ -69,18 +69,31 @@ export interface vtkImageData extends vtkDataSet {
|
|
|
69
69
|
extentToBounds(ex: Extent): Bounds;
|
|
70
70
|
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Get image extents without translation (i.e. with origin set to [0,0,0]) and under unit spacing
|
|
73
|
+
* (i.e. spacing = [1, 1, 1]).
|
|
74
|
+
* This includes a padding of 0.5 pixel/voxel in each principal direction.
|
|
75
|
+
* The padding is necessary for conventional images (textures, png, bmp)
|
|
76
|
+
* as well as medical images and volumes, since each pixel/voxel has a pre-defined width
|
|
77
|
+
* (based on specified spacing) including the ones on the boundary of the image.
|
|
78
|
+
* @internal
|
|
79
|
+
*/
|
|
80
|
+
getSpatialExtent(): Extent;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Returns the axis-aligned bounds of vtkImageData in world coordinates.
|
|
84
|
+
* The axis-aligned Bounds of a vtkImage are returned as pairs of world coordinates
|
|
73
85
|
* ```[x_min, x_max, y_min, y_max, z_min, z_max]``` these are calculated
|
|
74
86
|
* from the Extent, Origin, and Spacing, defined
|
|
75
87
|
* through
|
|
76
88
|
* ```js
|
|
77
|
-
* bounds[6] =
|
|
78
89
|
* [
|
|
79
|
-
* i_min*Spacing[0] + Origin[0], i_max*Spacing[0] + Origin[0],
|
|
80
|
-
* j_min*Spacing[1] + Origin[1], j_max*Spacing[1] + Origin[1],
|
|
81
|
-
* k_min*Spacing[2] + Origin[2], k_max*Spacing[2] + Origin[2]
|
|
90
|
+
* (i_min - 0.5)*Spacing[0] + Origin[0], (i_max + 0.5)*Spacing[0] + Origin[0],
|
|
91
|
+
* (j_min - 0.5)*Spacing[1] + Origin[1], (j_max + 0.5)*Spacing[1] + Origin[1],
|
|
92
|
+
* (k_min - 0.5)*Spacing[2] + Origin[2], (k_max + 0.5)*Spacing[2] + Origin[2]
|
|
82
93
|
* ];
|
|
83
94
|
* ```
|
|
95
|
+
* Note that this includes a padding of 0.5 voxel spacing in each principal direction,
|
|
96
|
+
* as well as any orientation of the image.
|
|
84
97
|
* You can't directly set the bounds. First you need to decide how many
|
|
85
98
|
* pixels across your image will be (i.e. what the extent should be), and
|
|
86
99
|
* then you must find the origin and spacing that will produce the bounds
|
|
@@ -89,6 +102,8 @@ export interface vtkImageData extends vtkDataSet {
|
|
|
89
102
|
* 9]` for a 10x10x10 image. Calling `setDimensions(10,10,10)` does exactly
|
|
90
103
|
* the same thing as `setExtent(0,9,0,9,0,9)` but you should always do the
|
|
91
104
|
* latter to be explicit about where your extent starts.
|
|
105
|
+
* Such an image of dimensions [10, 10, 10], origin [0, 0, 0] and voxel-spacing of 1.0,
|
|
106
|
+
* will result in bounds equal to [-0.5, 9.5, -0.5, 9.5, -0.5, 9.5].
|
|
92
107
|
* @return {Bounds} The bounds for the mapper.
|
|
93
108
|
*/
|
|
94
109
|
getBounds(): Bounds;
|
|
@@ -217,7 +232,9 @@ export interface vtkImageData extends vtkDataSet {
|
|
|
217
232
|
/**
|
|
218
233
|
* Calculate the corresponding world bounds for the given index bounds
|
|
219
234
|
* `[i_min, i_max, j_min, j_max, k_min, k_max]`. Modifies `out` in place if
|
|
220
|
-
* provided, or returns a new array.
|
|
235
|
+
* provided, or returns a new array. Returned bounds are NOT padded based
|
|
236
|
+
* on voxel spacing (see getBounds). The output is merely a bounding box
|
|
237
|
+
* calculated considering voxels as grid points.
|
|
221
238
|
* @param {Bounds} bin
|
|
222
239
|
* @param {Bounds} [bout]
|
|
223
240
|
*/
|
|
@@ -191,7 +191,7 @@ function vtkImageData(publicAPI, model) {
|
|
|
191
191
|
|
|
192
192
|
|
|
193
193
|
publicAPI.getBounds = function () {
|
|
194
|
-
return publicAPI.extentToBounds(
|
|
194
|
+
return publicAPI.extentToBounds(publicAPI.getSpatialExtent());
|
|
195
195
|
};
|
|
196
196
|
|
|
197
197
|
publicAPI.extentToBounds = function (ex) {
|
|
@@ -232,6 +232,13 @@ function vtkImageData(publicAPI, model) {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
return bounds;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
publicAPI.getSpatialExtent = function () {
|
|
238
|
+
var boundingBox = vtkBoundingBox.newInstance();
|
|
239
|
+
boundingBox.setBounds(model.extent);
|
|
240
|
+
boundingBox.inflate(0.5);
|
|
241
|
+
return boundingBox.getBounds();
|
|
235
242
|
}; // Internal, shouldn't need to call this manually.
|
|
236
243
|
|
|
237
244
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3 } from '../../types';
|
|
1
|
+
import { CellType, Vector3 } from '../../types';
|
|
2
2
|
import vtkCellArray from '../Core/CellArray';
|
|
3
3
|
import vtkPointSet, { IPointSetInitialValues } from './PointSet';
|
|
4
4
|
|
|
@@ -45,6 +45,13 @@ export interface vtkPolyData extends vtkPointSet {
|
|
|
45
45
|
*/
|
|
46
46
|
getCellPoints(cellId: number): object;
|
|
47
47
|
|
|
48
|
+
/**
|
|
49
|
+
* Get the type of the cell
|
|
50
|
+
* @param {Number} cellId The Id of the cell.
|
|
51
|
+
* @return CellType The type of the cell.
|
|
52
|
+
*/
|
|
53
|
+
getCellType(cellId: number): CellType;
|
|
54
|
+
|
|
48
55
|
/**
|
|
49
56
|
* Get the cell array defining cells.
|
|
50
57
|
*/
|
|
@@ -164,12 +164,14 @@ function vtkPolyData(publicAPI, model) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
model.links.buildLinks(publicAPI);
|
|
167
|
-
};
|
|
168
|
-
// the cell points.
|
|
167
|
+
};
|
|
169
168
|
|
|
169
|
+
publicAPI.getCellType = function (cellId) {
|
|
170
|
+
return model.cells.getCellType(cellId);
|
|
171
|
+
};
|
|
170
172
|
|
|
171
173
|
publicAPI.getCellPoints = function (cellId) {
|
|
172
|
-
var cellType =
|
|
174
|
+
var cellType = publicAPI.getCellType(cellId);
|
|
173
175
|
var cells = null;
|
|
174
176
|
|
|
175
177
|
switch (cellType) {
|