@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.
Files changed (153) 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/BoundingBox.js +3 -8
  6. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  7. package/Common/DataModel/ITKHelper.js +2 -346
  8. package/Common/DataModel/ImageData.d.ts +23 -6
  9. package/Common/DataModel/ImageData.js +8 -1
  10. package/Common/DataModel/PolyData.d.ts +8 -1
  11. package/Common/DataModel/PolyData.js +5 -3
  12. package/Common/DataModel/Triangle.js +217 -2
  13. package/Common/Transform/LandmarkTransform.js +1 -1
  14. package/Filters/General/OBBTree/OBBNode.js +82 -0
  15. package/Filters/General/OBBTree/helper.js +92 -0
  16. package/Filters/General/OBBTree.js +1249 -0
  17. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  18. package/Filters/General.js +2 -0
  19. package/Filters/Sources/CircleSource.js +1 -1
  20. package/Filters/Sources/PointSource.js +1 -1
  21. package/Filters/Texture/TextureMapToPlane.js +1 -1
  22. package/IO/Core/DataAccessHelper.d.ts +0 -6
  23. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  25. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  26. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  27. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  28. package/Interaction/Style/InteractorStyleImage.js +3 -3
  29. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  30. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  31. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  32. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  33. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  34. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  35. package/Interaction/Widgets.js +1 -35
  36. package/Proxy/Core/View2DProxy.js +1 -1
  37. package/Rendering/Core/ColorTransferFunction.js +1 -1
  38. package/Rendering/Core/Coordinate.js +1 -1
  39. package/Rendering/Core/CubeAxesActor.js +1 -1
  40. package/Rendering/Core/Glyph3DMapper.js +1 -1
  41. package/Rendering/Core/ImageMapper.js +1 -1
  42. package/Rendering/Core/InteractorObserver.js +11 -10
  43. package/Rendering/Core/InteractorStyle.js +9 -4
  44. package/Rendering/Core/Mapper.js +1 -1
  45. package/Rendering/Core/Prop.js +6 -4
  46. package/Rendering/Core/Prop3D.js +1 -1
  47. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  48. package/Rendering/Core/Renderer.js +24 -19
  49. package/Rendering/Core/ScalarBarActor.js +1 -1
  50. package/Rendering/Core/Viewport.js +1 -1
  51. package/Rendering/Core/VolumeMapper.js +1 -1
  52. package/Rendering/OpenGL/Actor.js +2 -2
  53. package/Rendering/OpenGL/Actor2D.js +2 -2
  54. package/Rendering/OpenGL/BufferObject.js +6 -5
  55. package/Rendering/OpenGL/Camera.js +3 -3
  56. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  57. package/Rendering/OpenGL/Framebuffer.js +13 -12
  58. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  59. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  60. package/Rendering/OpenGL/ImageMapper.js +51 -45
  61. package/Rendering/OpenGL/ImageSlice.js +2 -2
  62. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  63. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  64. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
  65. package/Rendering/OpenGL/Renderer.js +11 -7
  66. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  67. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  68. package/Rendering/OpenGL/ShaderCache.js +7 -5
  69. package/Rendering/OpenGL/Skybox.js +11 -9
  70. package/Rendering/OpenGL/SphereMapper.js +2 -2
  71. package/Rendering/OpenGL/StickMapper.js +2 -2
  72. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  73. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  74. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  75. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  76. package/Rendering/OpenGL/Texture.js +44 -31
  77. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  78. package/Rendering/OpenGL/Volume.js +3 -2
  79. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  80. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  81. package/Rendering/SceneGraph/ViewNode.js +8 -7
  82. package/Rendering/WebGPU/Renderer.js +18 -10
  83. package/Widgets/Core/AbstractWidget.js +5 -4
  84. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  85. package/Widgets/Core/WidgetManager.js +66 -49
  86. package/Widgets/Manipulators/LineManipulator.js +1 -1
  87. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  88. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  89. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  90. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  91. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  92. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  93. package/Widgets/SVG/SVGRepresentation.js +1 -1
  94. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  95. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  96. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  97. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  98. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  99. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  100. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  101. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  102. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  103. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  104. package/Widgets/Widgets3D/LineWidget.js +0 -1
  105. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  106. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  107. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  108. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  109. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  110. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  111. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  112. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  113. package/index.d.ts +1 -2
  114. package/interfaces.d.ts +16 -3
  115. package/macros.d.ts +26 -1
  116. package/macros.js +51 -19
  117. package/package.json +1 -1
  118. package/types.d.ts +1 -0
  119. package/Interaction/Widgets/AbstractWidget.js +0 -104
  120. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  121. package/Interaction/Widgets/DistanceWidget.js +0 -77
  122. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  123. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  124. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  125. package/Interaction/Widgets/HandleWidget.js +0 -194
  126. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  127. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  128. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  129. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  130. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  131. package/Interaction/Widgets/LabelWidget.js +0 -65
  132. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  133. package/Interaction/Widgets/LineRepresentation.js +0 -498
  134. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  135. package/Interaction/Widgets/LineWidget.js +0 -296
  136. package/Interaction/Widgets/PointPlacer.js +0 -51
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  143. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  144. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  145. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  146. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  147. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  148. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
  149. package/Widgets/Representations/SphereContextRepresentation.js +0 -131
  150. package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
  151. package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
  152. package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
  153. package/Widgets/Widgets3D/SphereWidget.js +0 -62
@@ -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 };