@kitware/vtk.js 24.7.1 → 24.10.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 (92) hide show
  1. package/Common/Core/Math/index.js +1 -1
  2. package/Common/Core/Math.js +1 -1
  3. package/Common/Core/ScalarsToColors/Constants.d.ts +18 -0
  4. package/Common/Core/ScalarsToColors.d.ts +6 -16
  5. package/Common/DataModel/Box.d.ts +4 -4
  6. package/Common/DataModel/CardinalSpline1D.d.ts +8 -4
  7. package/Common/DataModel/CardinalSpline1D.js +133 -4
  8. package/Common/DataModel/Cell.js +3 -1
  9. package/Common/DataModel/CellTypes.js +6 -1
  10. package/Common/DataModel/ITKHelper.d.ts +54 -0
  11. package/Common/DataModel/KochanekSpline1D.d.ts +8 -4
  12. package/Common/DataModel/KochanekSpline1D.js +103 -2
  13. package/Common/DataModel/Line.d.ts +8 -3
  14. package/Common/DataModel/Line.js +16 -11
  15. package/Common/DataModel/Plane.js +1 -1
  16. package/Common/DataModel/PolyData/Constants.d.ts +6 -0
  17. package/Common/DataModel/PolyLine.d.ts +63 -0
  18. package/Common/DataModel/PolyLine.js +84 -0
  19. package/Common/DataModel/Polygon.js +1 -1
  20. package/Common/DataModel/Spline1D/Constants.js +17 -0
  21. package/Common/DataModel/Spline1D.d.ts +20 -2
  22. package/Common/DataModel/Spline3D/Constants.d.ts +9 -0
  23. package/Common/DataModel/Spline3D.d.ts +4 -9
  24. package/Common/DataModel/Spline3D.js +20 -15
  25. package/Filters/General/ImageCropFilter.d.ts +9 -6
  26. package/Filters/Sources/LineSource.js +1 -1
  27. package/Filters/Sources/PlaneSource.js +1 -1
  28. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  29. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  30. package/Interaction/Manipulators/MouseRangeManipulator.js +23 -6
  31. package/Interaction/Widgets/OrientationMarkerWidget/Constants.d.ts +11 -0
  32. package/Interaction/Widgets/OrientationMarkerWidget.d.ts +2 -6
  33. package/Rendering/Core/CellPicker.js +53 -32
  34. package/Rendering/Core/Mapper/Constants.d.ts +26 -0
  35. package/Rendering/Core/Mapper.d.ts +5 -21
  36. package/Rendering/Core/Property/Constants.d.ts +24 -0
  37. package/Rendering/Core/Property.d.ts +6 -20
  38. package/Rendering/Core/RenderWindowInteractor/Constants.d.ts +31 -0
  39. package/Rendering/Core/RenderWindowInteractor.d.ts +223 -121
  40. package/Rendering/Core/Viewport.d.ts +2 -4
  41. package/Rendering/Core/VolumeMapper/Constants.d.ts +19 -0
  42. package/Rendering/Core/VolumeMapper.d.ts +5 -9
  43. package/Rendering/Core/VolumeProperty.d.ts +5 -13
  44. package/Rendering/Misc/FullScreenRenderWindow.d.ts +3 -2
  45. package/Rendering/OpenGL/RenderWindow.d.ts +28 -10
  46. package/Widgets/Core/StateBuilder/manipulatorMixin.js +15 -15
  47. package/Widgets/Manipulators/AbstractManipulator.d.ts +221 -0
  48. package/Widgets/Manipulators/AbstractManipulator.js +57 -0
  49. package/Widgets/Manipulators/LineManipulator.d.ts +8 -74
  50. package/Widgets/Manipulators/LineManipulator.js +14 -11
  51. package/Widgets/Manipulators/PlaneManipulator.d.ts +8 -74
  52. package/Widgets/Manipulators/PlaneManipulator.js +12 -9
  53. package/Widgets/Manipulators/TrackballManipulator.d.ts +8 -44
  54. package/Widgets/Manipulators/TrackballManipulator.js +13 -10
  55. package/Widgets/Representations/ResliceCursorContextRepresentation.js +1 -1
  56. package/Widgets/Representations/SplineContextRepresentation.js +28 -9
  57. package/Widgets/Representations/WidgetRepresentation.js +1 -1
  58. package/Widgets/Widgets3D/AngleWidget/behavior.js +7 -4
  59. package/Widgets/Widgets3D/AngleWidget/state.js +2 -2
  60. package/Widgets/Widgets3D/AngleWidget.js +20 -3
  61. package/Widgets/Widgets3D/DistanceWidget/behavior.js +7 -2
  62. package/Widgets/Widgets3D/DistanceWidget/state.js +2 -2
  63. package/Widgets/Widgets3D/DistanceWidget.js +19 -2
  64. package/Widgets/Widgets3D/EllipseWidget.js +4 -3
  65. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +3 -4
  66. package/Widgets/Widgets3D/ImageCroppingWidget.js +42 -13
  67. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +5 -5
  68. package/Widgets/Widgets3D/LabelWidget/behavior.js +6 -2
  69. package/Widgets/Widgets3D/LabelWidget/state.js +2 -2
  70. package/Widgets/Widgets3D/LabelWidget.js +18 -3
  71. package/Widgets/Widgets3D/LineWidget/behavior.js +11 -4
  72. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  73. package/Widgets/Widgets3D/LineWidget/state.js +1 -1
  74. package/Widgets/Widgets3D/LineWidget.js +18 -1
  75. package/Widgets/Widgets3D/PaintWidget/behavior.js +12 -9
  76. package/Widgets/Widgets3D/PaintWidget.js +24 -8
  77. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +11 -4
  78. package/Widgets/Widgets3D/PolyLineWidget/state.js +2 -2
  79. package/Widgets/Widgets3D/PolyLineWidget.js +21 -2
  80. package/Widgets/Widgets3D/RectangleWidget.js +6 -5
  81. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +5 -5
  82. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  83. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  84. package/Widgets/Widgets3D/ShapeWidget/behavior.js +9 -5
  85. package/Widgets/Widgets3D/ShapeWidget.js +12 -2
  86. package/Widgets/Widgets3D/SphereWidget/behavior.js +4 -3
  87. package/Widgets/Widgets3D/SphereWidget.js +23 -2
  88. package/Widgets/Widgets3D/SplineWidget/behavior.js +7 -3
  89. package/Widgets/Widgets3D/SplineWidget/state.js +12 -2
  90. package/Widgets/Widgets3D/SplineWidget.js +22 -3
  91. package/index.d.ts +12 -1
  92. package/package.json +1 -1
@@ -1,9 +1,12 @@
1
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
2
  import macro from '../../macros.js';
3
- import { l as normalize } from '../../Common/Core/Math/index.js';
3
+ import vtkCellTypes from '../../Common/DataModel/CellTypes.js';
4
+ import vtkLine from '../../Common/DataModel/Line.js';
4
5
  import vtkPicker from './Picker.js';
5
- import vtkPoints from '../../Common/Core/Points.js';
6
+ import vtkPolyLine from '../../Common/DataModel/PolyLine.js';
6
7
  import vtkTriangle from '../../Common/DataModel/Triangle.js';
8
+ import { l as normalize } from '../../Common/Core/Math/index.js';
9
+ import { CellType } from '../../Common/DataModel/CellTypes/Constants.js';
7
10
  import { vec3 } from 'gl-matrix';
8
11
 
9
12
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
@@ -12,6 +15,12 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
12
15
  // Global methods
13
16
  // ----------------------------------------------------------------------------
14
17
 
18
+ function createCellMap() {
19
+ var _ref;
20
+
21
+ return _ref = {}, _defineProperty(_ref, CellType.VTK_LINE, vtkLine.newInstance()), _defineProperty(_ref, CellType.VTK_POLY_LINE, vtkPolyLine.newInstance()), _defineProperty(_ref, CellType.VTK_TRIANGLE, vtkTriangle.newInstance()), _ref;
22
+ }
23
+
15
24
  function clipLineWithPlane(mapper, matrix, p1, p2) {
16
25
  var outObj = {
17
26
  planeId: -1,
@@ -214,8 +223,10 @@ function vtkCellPicker(publicAPI, model) {
214
223
  var minXYZ = [0, 0, 0];
215
224
  var pDistMin = Number.MAX_VALUE;
216
225
  var minPCoords = [0, 0, 0];
217
- var minCellId = -1;
218
- var minCell = vtkTriangle.newInstance();
226
+ var minCellId = null;
227
+ var minCell = null;
228
+ var minCellType = null;
229
+ var subId = null;
219
230
  var x = [];
220
231
  var data = mapper.getInputData();
221
232
 
@@ -235,30 +246,35 @@ function vtkCellPicker(publicAPI, model) {
235
246
  }
236
247
  }
237
248
 
238
- if (data.getPolys) {
239
- var cellObject = data.getPolys();
240
- var points = data.getPoints();
241
- var cellData = cellObject.getData();
242
- var cellId = 0;
243
- var pointsIdList = [-1, -1, -1];
244
- var cell = vtkTriangle.newInstance();
245
- var cellPoints = vtkPoints.newInstance(); // cross all cells
249
+ if (data.getCells) {
250
+ if (!data.getCells()) {
251
+ data.buildLinks();
252
+ }
246
253
 
247
- for (var i = 0; i < cellData.length; cellId++) {
248
- var pCoords = [0, 0, 0];
249
- var nbPointsInCell = cellData[i++];
250
- cellPoints.setNumberOfPoints(nbPointsInCell); // Extract cell points
254
+ var tempCellMap = createCellMap();
255
+ var minCellMap = createCellMap();
256
+ var numberOfCells = data.getNumberOfCells();
251
257
 
252
- for (var _j = 0; _j < nbPointsInCell; _j++) {
253
- pointsIdList[_j] = cellData[i++];
254
- } // Create cell from points
258
+ for (var cellId = 0; cellId < numberOfCells; cellId++) {
259
+ var pCoords = [0, 0, 0];
260
+ minCellType = data.getCellType(cellId);
261
+ var cell = tempCellMap[minCellType];
255
262
 
263
+ if (cell == null) {
264
+ // eslint-disable-next-line no-continue
265
+ continue;
266
+ }
256
267
 
257
- cell.initialize(points, pointsIdList);
268
+ minCell = minCellMap[minCellType];
269
+ data.getCell(cellId, cell);
258
270
  var cellPicked = void 0;
259
271
 
260
272
  {
261
- cellPicked = cell.intersectWithLine(p1, p2, tol, x, pCoords);
273
+ if (vtkCellTypes.hasSubCells(minCellType)) {
274
+ cellPicked = cell.intersectWithLine(t1, t2, p1, p2, tol, x, pCoords);
275
+ } else {
276
+ cellPicked = cell.intersectWithLine(p1, p2, tol, x, pCoords);
277
+ }
262
278
  }
263
279
 
264
280
  if (cellPicked.intersect === 1 && cellPicked.t <= tMin + model.tolerance && cellPicked.t >= t1 && cellPicked.t <= t2) {
@@ -267,6 +283,7 @@ function vtkCellPicker(publicAPI, model) {
267
283
  if (pDist < pDistMin || pDist === pDistMin && cellPicked.t < tMin) {
268
284
  tMin = cellPicked.t;
269
285
  pDistMin = pDist;
286
+ subId = cellPicked.subId;
270
287
  minCellId = cellId;
271
288
  cell.deepCopy(minCell);
272
289
 
@@ -281,17 +298,21 @@ function vtkCellPicker(publicAPI, model) {
281
298
 
282
299
  if (minCellId >= 0 && tMin < model.globalTMin) {
283
300
  resetPickInfo();
301
+ var nbPointsInCell = minCell.getNumberOfPoints();
302
+ var weights = new Array(nbPointsInCell);
284
303
 
285
- var _nbPointsInCell = minCell.getNumberOfPoints();
286
-
287
- var weights = new Array(_nbPointsInCell);
288
-
289
- for (var _i = 0; _i < _nbPointsInCell; _i++) {
290
- weights[_i] = 0.0;
304
+ for (var i = 0; i < nbPointsInCell; i++) {
305
+ weights[i] = 0.0;
291
306
  }
292
307
 
293
308
  var point = [];
294
- minCell.evaluateLocation(minPCoords, point, weights); // Return the polydata to the user
309
+
310
+ if (vtkCellTypes.hasSubCells(minCellType)) {
311
+ minCell.evaluateLocation(subId, minPCoords, point, weights);
312
+ } else {
313
+ minCell.evaluateLocation(minPCoords, point, weights);
314
+ } // Return the polydata to the user
315
+
295
316
 
296
317
  model.dataSet = data;
297
318
  model.cellId = minCellId;
@@ -302,10 +323,10 @@ function vtkCellPicker(publicAPI, model) {
302
323
  var maxWeight = 0;
303
324
  var iMaxWeight = -1;
304
325
 
305
- for (var _i2 = 0; _i2 < _nbPointsInCell; _i2++) {
306
- if (weights[_i2] > maxWeight) {
307
- iMaxWeight = _i2;
308
- maxWeight = weights[_i2];
326
+ for (var _i = 0; _i < nbPointsInCell; _i++) {
327
+ if (weights[_i] > maxWeight) {
328
+ iMaxWeight = _i;
329
+ maxWeight = weights[_i];
309
330
  }
310
331
  } // If maximum weight is found, use it to get the PointId
311
332
 
@@ -0,0 +1,26 @@
1
+ export declare enum ColorMode {
2
+ DEFAULT = 0,
3
+ MAP_SCALARS = 1,
4
+ DIRECT_SCALARS = 2,
5
+ }
6
+
7
+ export declare enum ScalarMode {
8
+ DEFAULT = 0,
9
+ USE_POINT_DATA = 1,
10
+ USE_CELL_DATA = 2,
11
+ USE_POINT_FIELD_DATA = 3,
12
+ USE_CELL_FIELD_DATA = 4,
13
+ USE_FIELD_DATA = 5,
14
+ }
15
+
16
+ export declare enum GetArray {
17
+ BY_ID = 0,
18
+ BY_NAME = 1,
19
+ }
20
+
21
+ declare const _default: {
22
+ ColorMode: typeof ColorMode;
23
+ ScalarMode: typeof ScalarMode;
24
+ GetArray: typeof GetArray;
25
+ };
26
+ export default _default;
@@ -1,25 +1,6 @@
1
1
  import { Bounds, Nullable, Range } from './../../types';
2
2
  import vtkAbstractMapper3D, { IAbstractMapper3DInitialValues } from './AbstractMapper3D';
3
-
4
- export enum ColorMode {
5
- DEFAULT,
6
- MAP_SCALARS,
7
- DIRECT_SCALARS,
8
- }
9
-
10
- export enum ScalarMode {
11
- DEFAULT,
12
- USE_POINT_DATA,
13
- USE_CELL_DATA,
14
- USE_POINT_FIELD_DATA,
15
- USE_CELL_FIELD_DATA,
16
- USE_FIELD_DATA,
17
- }
18
-
19
- export enum GetArray {
20
- BY_ID,
21
- BY_NAME,
22
- }
3
+ import { ColorMode, GetArray, ScalarMode } from './Mapper/Constants';
23
4
 
24
5
  interface IPrimitiveCount {
25
6
  points: number;
@@ -166,7 +147,7 @@ export interface vtkMapper extends vtkAbstractMapper3D {
166
147
  /**
167
148
  * Return the method of coloring scalar data.
168
149
  */
169
- getColorMode(): number;
150
+ getColorMode(): ColorMode;
170
151
 
171
152
  /**
172
153
  * Return the method of coloring scalar data.
@@ -643,5 +624,8 @@ export declare const vtkMapper: {
643
624
  getResolveCoincidentTopologyLineOffsetParameters: typeof getResolveCoincidentTopologyLineOffsetParameters;
644
625
  getResolveCoincidentTopologyPointOffsetParameters: typeof getResolveCoincidentTopologyPointOffsetParameters;
645
626
  getResolveCoincidentTopologyPolygonOffsetParameters: typeof getResolveCoincidentTopologyPolygonOffsetParameters;
627
+ ColorMode: typeof ColorMode;
628
+ ScalarMode: typeof ScalarMode;
629
+ GetArray: typeof GetArray;
646
630
  }
647
631
  export default vtkMapper;
@@ -0,0 +1,24 @@
1
+ export declare enum Shading {
2
+ FLAT = 0,
3
+ GOURAUD = 1,
4
+ PHONG = 2,
5
+ }
6
+
7
+ export declare enum Representation {
8
+ POINTS = 0,
9
+ WIREFRAME = 1,
10
+ SURFACE = 2,
11
+ }
12
+
13
+ export declare enum Interpolation {
14
+ FLAT = 0,
15
+ GOURAUD = 1,
16
+ PHONG = 2,
17
+ }
18
+
19
+ declare const _default: {
20
+ Shading: typeof Shading;
21
+ Representation: typeof Representation;
22
+ Interpolation: typeof Interpolation;
23
+ };
24
+ export default _default;
@@ -1,23 +1,6 @@
1
1
  import { vtkObject } from './../../interfaces';
2
2
  import { RGBColor } from './../../types';
3
-
4
- export enum Shading {
5
- FLAT,
6
- GOURAUD,
7
- PHONG,
8
- }
9
-
10
- export enum Representation {
11
- POINTS,
12
- WIREFRAME,
13
- SURFACE,
14
- }
15
-
16
- export enum Interpolation {
17
- FLAT,
18
- GOURAUD,
19
- PHONG,
20
- }
3
+ import { Interpolation, Representation, Shading } from './Property/Constants';
21
4
 
22
5
  export interface IPropertyInitialValues {
23
6
  color?: RGBColor;
@@ -457,7 +440,10 @@ export function newInstance(initialValues?: IPropertyInitialValues): vtkProperty
457
440
  * manipulated with this object.
458
441
  */
459
442
  export declare const vtkProperty: {
460
- newInstance: typeof newInstance,
461
- extend: typeof extend,
443
+ newInstance: typeof newInstance;
444
+ extend: typeof extend;
445
+ Shading: typeof Shading;
446
+ Representation: typeof Representation;
447
+ Interpolation: typeof Interpolation;
462
448
  };
463
449
  export default vtkProperty;
@@ -0,0 +1,31 @@
1
+ export declare enum Device {
2
+ Unknown = 0,
3
+ LeftController = 1,
4
+ RightController = 2,
5
+ }
6
+
7
+ export declare enum Input {
8
+ Unknown = 0,
9
+ Trigger = 1,
10
+ TrackPad = 2,
11
+ Grip = 3,
12
+ Thumbstick = 4,
13
+ A = 5,
14
+ B = 6,
15
+ ApplicationMenu = 7, // Not exposed in WebXR API
16
+ }
17
+
18
+ export declare enum Axis {
19
+ Unknown = 0,
20
+ TouchpadX = 1,
21
+ TouchpadY = 2,
22
+ ThumbstickX = 3,
23
+ ThumbstickY = 4,
24
+ }
25
+
26
+ declare const _default: {
27
+ Device: typeof Device;
28
+ Input: typeof Input;
29
+ Axis: typeof Axis;
30
+ };
31
+ export default _default;