@kitware/vtk.js 23.4.3 → 24.0.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 (144) hide show
  1. package/BREAKING_CHANGES.md +33 -0
  2. package/Common/Core/DataArray.js +4 -0
  3. package/Common/Core/Math/index.js +2 -2
  4. package/Common/Core/Math.js +1 -1
  5. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  6. package/Common/DataModel/ImageData.d.ts +23 -6
  7. package/Common/DataModel/ImageData.js +8 -1
  8. package/Common/DataModel/PolyData.d.ts +8 -1
  9. package/Common/DataModel/PolyData.js +5 -3
  10. package/Common/DataModel/Triangle.js +217 -2
  11. package/Common/Transform/LandmarkTransform.js +1 -1
  12. package/Filters/General/OBBTree/OBBNode.js +82 -0
  13. package/Filters/General/OBBTree/helper.js +92 -0
  14. package/Filters/General/OBBTree.js +1249 -0
  15. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  16. package/Filters/General.js +2 -0
  17. package/Filters/Sources/CircleSource.js +1 -1
  18. package/Filters/Sources/PointSource.js +1 -1
  19. package/Filters/Texture/TextureMapToPlane.js +1 -1
  20. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  21. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  22. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  25. package/Interaction/Style/InteractorStyleImage.js +3 -3
  26. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  27. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  28. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  29. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  30. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  31. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  32. package/Interaction/Widgets.js +1 -35
  33. package/Proxy/Core/View2DProxy.js +1 -1
  34. package/Rendering/Core/ColorTransferFunction.js +1 -1
  35. package/Rendering/Core/Coordinate.js +1 -1
  36. package/Rendering/Core/CubeAxesActor.js +1 -1
  37. package/Rendering/Core/Glyph3DMapper.js +1 -1
  38. package/Rendering/Core/ImageMapper.js +1 -1
  39. package/Rendering/Core/InteractorObserver.js +11 -10
  40. package/Rendering/Core/InteractorStyle.js +9 -4
  41. package/Rendering/Core/Mapper.js +1 -1
  42. package/Rendering/Core/Prop.js +6 -4
  43. package/Rendering/Core/Prop3D.js +1 -1
  44. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  45. package/Rendering/Core/Renderer.js +24 -19
  46. package/Rendering/Core/ScalarBarActor.js +1 -1
  47. package/Rendering/Core/Viewport.js +1 -1
  48. package/Rendering/Core/VolumeMapper.js +1 -1
  49. package/Rendering/OpenGL/Actor.js +2 -2
  50. package/Rendering/OpenGL/Actor2D.js +2 -2
  51. package/Rendering/OpenGL/BufferObject.js +6 -5
  52. package/Rendering/OpenGL/Camera.js +3 -3
  53. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  54. package/Rendering/OpenGL/Framebuffer.js +13 -12
  55. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  56. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  57. package/Rendering/OpenGL/ImageMapper.js +51 -45
  58. package/Rendering/OpenGL/ImageSlice.js +2 -2
  59. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  60. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  61. package/Rendering/OpenGL/PolyDataMapper2D.js +7 -6
  62. package/Rendering/OpenGL/Renderer.js +11 -7
  63. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  64. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  65. package/Rendering/OpenGL/ShaderCache.js +7 -5
  66. package/Rendering/OpenGL/Skybox.js +11 -9
  67. package/Rendering/OpenGL/SphereMapper.js +2 -2
  68. package/Rendering/OpenGL/StickMapper.js +2 -2
  69. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  70. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  71. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  72. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  73. package/Rendering/OpenGL/Texture.js +44 -31
  74. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  75. package/Rendering/OpenGL/Volume.js +3 -2
  76. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  77. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  78. package/Rendering/SceneGraph/ViewNode.js +8 -7
  79. package/Rendering/WebGPU/Renderer.js +18 -10
  80. package/Widgets/Core/AbstractWidget.js +5 -4
  81. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  82. package/Widgets/Core/WidgetManager.js +66 -49
  83. package/Widgets/Manipulators/LineManipulator.js +1 -1
  84. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  85. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  86. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  87. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  88. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  89. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  90. package/Widgets/SVG/SVGRepresentation.js +1 -1
  91. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  92. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  93. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  94. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  95. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  96. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  97. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  98. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  99. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  100. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  101. package/Widgets/Widgets3D/LineWidget.js +0 -1
  102. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  103. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  104. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  105. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  106. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  108. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  109. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  110. package/interfaces.d.ts +11 -0
  111. package/macros.d.ts +26 -1
  112. package/macros.js +51 -19
  113. package/package.json +1 -1
  114. package/types.d.ts +1 -0
  115. package/Interaction/Widgets/AbstractWidget.js +0 -104
  116. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  117. package/Interaction/Widgets/DistanceWidget.js +0 -77
  118. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  119. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  120. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  121. package/Interaction/Widgets/HandleWidget.js +0 -194
  122. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  123. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  124. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  125. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  126. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  127. package/Interaction/Widgets/LabelWidget.js +0 -65
  128. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  129. package/Interaction/Widgets/LineRepresentation.js +0 -498
  130. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  131. package/Interaction/Widgets/LineWidget.js +0 -296
  132. package/Interaction/Widgets/PointPlacer.js +0 -51
  133. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  134. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  135. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  143. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  144. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
@@ -1,233 +0,0 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
- import macro from '../../macros.js';
3
- import { f as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
4
- import vtkCellPicker from '../../Rendering/Core/CellPicker.js';
5
- import vtkActor from '../../Rendering/Core/Actor.js';
6
- import vtkWidgetRepresentation from './WidgetRepresentation.js';
7
- import vtkMapper from '../../Rendering/Core/Mapper.js';
8
- import vtkPolyData from '../../Common/DataModel/PolyData.js';
9
- import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
10
- import Constants from './ImageCroppingRegionsWidget/Constants.js';
11
-
12
- var TOTAL_NUM_HANDLES = Constants.TOTAL_NUM_HANDLES; // prettier-ignore
13
-
14
- var LINE_ARRAY = [2, 0, 1, 2, 2, 3, 2, 4, 5, 2, 6, 7, 2, 0, 2, 2, 1, 3, 2, 4, 6, 2, 5, 7, 2, 0, 4, 2, 1, 5, 2, 2, 6, 2, 3, 7]; // ----------------------------------------------------------------------------
15
- // vtkImageCroppingRegionsRepresentation methods
16
- // ----------------------------------------------------------------------------
17
- // Reorders a bounds array such that each (a,b) pairing is a
18
- // (min,max) pairing.
19
-
20
- function reorderBounds(bounds) {
21
- for (var i = 0; i < 6; i += 2) {
22
- if (bounds[i] > bounds[i + 1]) {
23
- var tmp = bounds[i + 1];
24
- bounds[i + 1] = bounds[i];
25
- bounds[i] = tmp;
26
- }
27
- }
28
- }
29
-
30
- function vtkImageCroppingRegionsRepresentation(publicAPI, model) {
31
- // Set our className
32
- model.classHierarchy.push('vtkImageCroppingRegionsRepresentation'); // set fields from parent classes
33
-
34
- model.placeFactor = 1;
35
- model.picker = vtkCellPicker.newInstance();
36
- model.picker.setPickFromList(1);
37
- model.picker.initializePickList();
38
- model.handles = Array(TOTAL_NUM_HANDLES).fill(null).map(function () {
39
- var source = vtkSphereSource.newInstance();
40
- var mapper = vtkMapper.newInstance();
41
- var actor = vtkActor.newInstance();
42
- mapper.setInputConnection(source.getOutputPort());
43
- actor.setMapper(mapper);
44
- model.picker.addPickList(actor);
45
- return {
46
- source: source,
47
- mapper: mapper,
48
- actor: actor
49
- };
50
- });
51
- model.outline = {
52
- polydata: vtkPolyData.newInstance(),
53
- mapper: vtkMapper.newInstance(),
54
- actor: vtkActor.newInstance()
55
- }; // 8 corners for a box
56
-
57
- model.outline.polydata.getPoints().setData(new Float32Array(8 * 3), 3);
58
- model.outline.polydata.getLines().setData(Uint16Array.from(LINE_ARRAY));
59
- model.outline.mapper.setInputData(model.outline.polydata);
60
- model.outline.actor.setMapper(model.outline.mapper); // methods
61
-
62
- publicAPI.getActors = function () {
63
- var actors = [model.outline.actor];
64
-
65
- for (var i = 0; i < model.handlePositions.length; ++i) {
66
- if (model.handlePositions[i]) {
67
- actors.push(model.handles[i].actor);
68
- }
69
- }
70
-
71
- return actors;
72
- };
73
-
74
- publicAPI.getNestedProps = function () {
75
- return publicAPI.getActors();
76
- }; // outline mapper substitutes for the crop widget rep mapper
77
-
78
-
79
- publicAPI.getMapper = function () {
80
- return model.outline.mapper;
81
- };
82
-
83
- publicAPI.getEventIntersection = function (callData) {
84
- var _callData$position = callData.position,
85
- x = _callData$position.x,
86
- y = _callData$position.y,
87
- z = _callData$position.z;
88
- model.picker.pick([x, y, z], callData.pokedRenderer);
89
- var actors = model.picker.getActors();
90
-
91
- if (actors.length) {
92
- var actorIndex = 0; // get actor closest to camera
93
-
94
- if (actors.length > 1) {
95
- var dists = model.picker.getPickedPositions().map(function (pt) {
96
- var camPos = callData.pokedRenderer.getActiveCamera().getPosition();
97
- return distance2BetweenPoints(camPos, pt);
98
- });
99
- var minDist = Infinity;
100
- dists.forEach(function (d, i) {
101
- if (minDist > d) {
102
- actorIndex = i;
103
- minDist = d;
104
- }
105
- });
106
- }
107
-
108
- var actor = actors[actorIndex];
109
- return model.handles.findIndex(function (h) {
110
- return h.actor === actor;
111
- });
112
- }
113
-
114
- return -1;
115
- };
116
-
117
- publicAPI.placeWidget = function () {
118
- var boundsArray = [];
119
-
120
- for (var i = 0; i < arguments.length; i++) {
121
- boundsArray.push(i < 0 || arguments.length <= i ? undefined : arguments[i]);
122
- }
123
-
124
- if (boundsArray.length !== 6) {
125
- return;
126
- } // make sure each bounds pairing is monotonic
127
-
128
-
129
- reorderBounds(boundsArray);
130
- var newBounds = [];
131
- var center = [];
132
- publicAPI.adjustBounds(boundsArray, newBounds, center);
133
-
134
- for (var _i = 0; _i < 6; _i++) {
135
- model.initialBounds[_i] = newBounds[_i];
136
- }
137
-
138
- model.initialLength = Math.sqrt((newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0]) + (newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2]) + (newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4]));
139
- publicAPI.modified();
140
- }; // Force update the geometry
141
-
142
-
143
- publicAPI.updateGeometry = function () {
144
- var _model$outline$actor$;
145
-
146
- var outlinePoints = model.outline.polydata.getPoints().getData();
147
-
148
- for (var i = 0; i < model.handles.length; ++i) {
149
- if (model.handlePositions[i]) {
150
- var _model$handles$i = model.handles[i],
151
- actor = _model$handles$i.actor,
152
- source = _model$handles$i.source;
153
- source.setRadius(model.handleSizes[i]);
154
- source.setCenter(model.handlePositions[i]);
155
-
156
- if (model.activeHandleIndex === i) {
157
- actor.getProperty().setColor(0, 1, 0);
158
- } else {
159
- actor.getProperty().setColor(1, 1, 1);
160
- }
161
- }
162
- }
163
-
164
- for (var _i2 = 0; _i2 < model.bboxCorners.length; ++_i2) {
165
- outlinePoints.set(model.bboxCorners[_i2], _i2 * 3);
166
- }
167
-
168
- (_model$outline$actor$ = model.outline.actor.getProperty()).setEdgeColor.apply(_model$outline$actor$, _toConsumableArray(model.edgeColor));
169
-
170
- model.outline.polydata.getPoints().modified();
171
- model.outline.polydata.modified(); // FIXME: Ken we need your feedback
172
- // Move our mtime without triggering a modified()
173
- // model.mtime = model.outline.polydata.getMTime();
174
- }; // FIXME: Ken we need your feedback
175
- // model.outline.polydata.getPoints().getBounds();
176
-
177
-
178
- publicAPI.getBounds = function () {
179
- return model.initialBounds;
180
- };
181
-
182
- publicAPI.buildRepresentation = function () {
183
- if (model.renderer) {
184
- if (!model.placed) {
185
- model.validPick = 1;
186
- model.placed = 1;
187
- }
188
-
189
- publicAPI.updateGeometry();
190
- }
191
- };
192
-
193
- publicAPI.setProperty = function (property) {
194
- model.actor.setProperty(property);
195
- }; // modifications will result in geometry updates
196
-
197
-
198
- publicAPI.onModified(publicAPI.updateGeometry);
199
- } // ----------------------------------------------------------------------------
200
- // Object factory
201
- // ----------------------------------------------------------------------------
202
-
203
-
204
- var DEFAULT_VALUES = {
205
- activeHandleIndex: -1,
206
- handlePositions: Array(TOTAL_NUM_HANDLES).fill(null),
207
- handleSizes: Array(TOTAL_NUM_HANDLES).fill(0),
208
- bboxCorners: Array(8).fill([0, 0, 0]),
209
- edgeColor: [1.0, 1.0, 1.0]
210
- }; // ----------------------------------------------------------------------------
211
-
212
- function extend(publicAPI, model) {
213
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
214
- Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
215
-
216
- vtkWidgetRepresentation.extend(publicAPI, model, initialValues);
217
- macro.setGet(publicAPI, model, ['activeHandleIndex']);
218
- macro.setGetArray(publicAPI, model, ['edgeColor'], 3);
219
- macro.setGetArray(publicAPI, model, ['handlePositions'], TOTAL_NUM_HANDLES);
220
- macro.setGetArray(publicAPI, model, ['handleSizes'], TOTAL_NUM_HANDLES);
221
- macro.setGetArray(publicAPI, model, ['bboxCorners'], 8); // Object methods
222
-
223
- vtkImageCroppingRegionsRepresentation(publicAPI, model);
224
- } // ----------------------------------------------------------------------------
225
-
226
- var newInstance = macro.newInstance(extend, 'vtkImageCroppingRegionsRepresentation'); // ----------------------------------------------------------------------------
227
-
228
- var vtkImageCroppingRegionsRepresentation$1 = {
229
- newInstance: newInstance,
230
- extend: extend
231
- };
232
-
233
- export { vtkImageCroppingRegionsRepresentation$1 as default, extend, newInstance };
@@ -1,16 +0,0 @@
1
- var WidgetState = {
2
- IDLE: 0,
3
- CROPPING: 1
4
- };
5
- var CropWidgetEvents = ['CroppingPlanesChanged']; // first 6 are face handles,
6
- // next 12 are edge handles,
7
- // last 8 are corner handles.
8
-
9
- var TOTAL_NUM_HANDLES = 26;
10
- var Constants = {
11
- TOTAL_NUM_HANDLES: TOTAL_NUM_HANDLES,
12
- WidgetState: WidgetState,
13
- CropWidgetEvents: CropWidgetEvents
14
- };
15
-
16
- export { Constants as default };