@kitware/vtk.js 25.9.1 → 26.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 (183) hide show
  1. package/Common/Core/CellArray.d.ts +0 -6
  2. package/Common/Core/CellArray.js +21 -12
  3. package/Common/Core/ClassHierarchy.js +11 -6
  4. package/Common/Core/DataArray.d.ts +20 -0
  5. package/Common/Core/DataArray.js +21 -4
  6. package/Proxy/Core/ViewProxy.js +17 -9
  7. package/Rendering/Core/Prop3D.js +1 -6
  8. package/Rendering/Core/RenderWindow.js +9 -6
  9. package/Rendering/Core/VolumeProperty.js +2 -3
  10. package/Rendering/Misc/CanvasView.js +6 -5
  11. package/Rendering/Misc/GenericRenderWindow.js +12 -7
  12. package/Rendering/OpenGL/Actor.js +4 -4
  13. package/Rendering/OpenGL/Actor2D.js +4 -4
  14. package/Rendering/OpenGL/Camera.js +7 -4
  15. package/Rendering/OpenGL/CubeAxesActor.js +7 -5
  16. package/Rendering/OpenGL/ForwardPass.js +1 -1
  17. package/Rendering/OpenGL/Glyph3DMapper.js +4 -4
  18. package/Rendering/OpenGL/ImageMapper.js +9 -5
  19. package/Rendering/OpenGL/ImageSlice.js +3 -3
  20. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +9 -5
  21. package/Rendering/OpenGL/PolyDataMapper.js +22 -14
  22. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -10
  23. package/Rendering/OpenGL/ScalarBarActor.js +6 -4
  24. package/Rendering/OpenGL/Skybox.js +10 -6
  25. package/Rendering/OpenGL/Texture.js +6 -5
  26. package/Rendering/OpenGL/Volume.js +2 -2
  27. package/Rendering/OpenGL/VolumeMapper.js +11 -11
  28. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  29. package/Rendering/SceneGraph/RenderPass.js +3 -2
  30. package/Rendering/WebGPU/ForwardPass.js +1 -1
  31. package/Rendering/WebGPU/HardwareSelectionPass.js +1 -1
  32. package/Rendering/WebGPU/HardwareSelector.js +14 -13
  33. package/Rendering/WebGPU/OpaquePass.js +1 -1
  34. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  35. package/Rendering/WebGPU/VolumePass.js +1 -1
  36. package/Utilities/config/rules-tests.js +28 -0
  37. package/Widgets/Core/AbstractWidgetFactory.js +1 -0
  38. package/Widgets/Core/StateBuilder/color3Mixin.js +22 -0
  39. package/Widgets/Core/StateBuilder/colorMixin.js +7 -0
  40. package/Widgets/Core/StateBuilder.js +2 -0
  41. package/Widgets/Representations/ArrowHandleRepresentation.js +28 -110
  42. package/Widgets/Representations/CircleContextRepresentation.js +43 -165
  43. package/Widgets/Representations/ContextRepresentation.js +0 -3
  44. package/Widgets/Representations/ConvexFaceContextRepresentation.js +11 -11
  45. package/Widgets/Representations/CroppingOutlineRepresentation.js +5 -12
  46. package/Widgets/Representations/CubeHandleRepresentation.js +15 -104
  47. package/Widgets/Representations/GlyphRepresentation.js +320 -0
  48. package/Widgets/Representations/HandleRepresentation.js +0 -5
  49. package/Widgets/Representations/ImplicitPlaneRepresentation.js +68 -49
  50. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  51. package/Widgets/Representations/PolyLineRepresentation.js +52 -49
  52. package/Widgets/Representations/RectangleContextRepresentation.js +16 -21
  53. package/Widgets/Representations/SphereContextRepresentation.js +30 -109
  54. package/Widgets/Representations/SphereHandleRepresentation.js +13 -110
  55. package/Widgets/Representations/SplineContextRepresentation.js +53 -36
  56. package/Widgets/Representations/WidgetRepresentation.d.ts +52 -1
  57. package/Widgets/Representations/WidgetRepresentation.js +140 -78
  58. package/Widgets/Representations.js +6 -0
  59. package/Widgets/SVG/SVGLandmarkRepresentation.js +1 -13
  60. package/Widgets/Widgets3D/AngleWidget.js +1 -4
  61. package/Widgets/Widgets3D/EllipseWidget/state.js +1 -1
  62. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +15 -3
  63. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +93 -36
  64. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +75 -82
  65. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +49 -170
  66. package/Widgets/Widgets3D/ResliceCursorWidget.js +61 -23
  67. package/index.d.ts +0 -1
  68. package/macros.d.ts +3 -5
  69. package/macros.js +4 -35
  70. package/package.json +2 -2
  71. package/Widgets/Representations/ResliceCursorContextRepresentation/Constants.js +0 -12
  72. package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +0 -54
  73. package/Widgets/Representations/ResliceCursorContextRepresentation.js +0 -357
  74. package/_vendor/available-typed-arrays/index.js_commonjs-proxy.js +0 -1
  75. package/_vendor/call-bind/callBound.js_commonjs-proxy.js +0 -1
  76. package/_vendor/call-bind/index.js_commonjs-module.js +0 -3
  77. package/_vendor/call-bind/index.js_commonjs-proxy.js +0 -1
  78. package/_vendor/deep-equal/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  79. package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
  80. package/_vendor/es-abstract/helpers/getOwnPropertyDescriptor.js_commonjs-proxy.js +0 -1
  81. package/_vendor/es-get-iterator/index.js_commonjs-module.js +0 -3
  82. package/_vendor/es-get-iterator/index.js_commonjs-proxy.js +0 -1
  83. package/_vendor/es-get-iterator/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  84. package/_vendor/foreach/index.js_commonjs-proxy.js +0 -1
  85. package/_vendor/function-bind/implementation.js_commonjs-proxy.js +0 -1
  86. package/_vendor/function-bind/index.js_commonjs-proxy.js +0 -1
  87. package/_vendor/get-intrinsic/index.js_commonjs-proxy.js +0 -1
  88. package/_vendor/has/src/index.js_commonjs-proxy.js +0 -1
  89. package/_vendor/has-bigints/index.js_commonjs-proxy.js +0 -1
  90. package/_vendor/has-symbols/index.js_commonjs-proxy.js +0 -1
  91. package/_vendor/has-symbols/shams.js_commonjs-proxy.js +0 -1
  92. package/_vendor/has-tostringtag/shams.js_commonjs-proxy.js +0 -1
  93. package/_vendor/is-arguments/index.js_commonjs-proxy.js +0 -1
  94. package/_vendor/is-bigint/index.js_commonjs-module.js +0 -3
  95. package/_vendor/is-bigint/index.js_commonjs-proxy.js +0 -1
  96. package/_vendor/is-boolean-object/index.js_commonjs-proxy.js +0 -1
  97. package/_vendor/is-date-object/index.js_commonjs-proxy.js +0 -1
  98. package/_vendor/is-map/index.js_commonjs-proxy.js +0 -1
  99. package/_vendor/is-number-object/index.js_commonjs-proxy.js +0 -1
  100. package/_vendor/is-regex/index.js_commonjs-proxy.js +0 -1
  101. package/_vendor/is-set/index.js_commonjs-proxy.js +0 -1
  102. package/_vendor/is-string/index.js_commonjs-proxy.js +0 -1
  103. package/_vendor/is-symbol/index.js_commonjs-module.js +0 -3
  104. package/_vendor/is-symbol/index.js_commonjs-proxy.js +0 -1
  105. package/_vendor/is-typed-array/index.js_commonjs-proxy.js +0 -1
  106. package/_vendor/is-weakmap/index.js_commonjs-proxy.js +0 -1
  107. package/_vendor/is-weakset/index.js_commonjs-proxy.js +0 -1
  108. package/_vendor/object-inspect/index.js_commonjs-proxy.js +0 -1
  109. package/_vendor/object-is/implementation.js_commonjs-proxy.js +0 -1
  110. package/_vendor/object-is/index.js_commonjs-proxy.js +0 -1
  111. package/_vendor/object-is/polyfill.js_commonjs-proxy.js +0 -1
  112. package/_vendor/object-is/shim.js_commonjs-proxy.js +0 -1
  113. package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
  114. package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
  115. package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
  116. package/_vendor/object.assign/implementation.js_commonjs-proxy.js +0 -1
  117. package/_vendor/object.assign/index.js_commonjs-proxy.js +0 -1
  118. package/_vendor/object.assign/polyfill.js_commonjs-proxy.js +0 -1
  119. package/_vendor/object.assign/shim.js_commonjs-proxy.js +0 -2
  120. package/_vendor/regexp.prototype.flags/implementation.js_commonjs-proxy.js +0 -1
  121. package/_vendor/regexp.prototype.flags/index.js_commonjs-proxy.js +0 -1
  122. package/_vendor/regexp.prototype.flags/polyfill.js_commonjs-proxy.js +0 -1
  123. package/_vendor/regexp.prototype.flags/shim.js_commonjs-proxy.js +0 -1
  124. package/_vendor/side-channel/index.js_commonjs-proxy.js +0 -1
  125. package/_vendor/which-boxed-primitive/index.js_commonjs-proxy.js +0 -5
  126. package/_vendor/which-collection/index.js_commonjs-proxy.js +0 -4
  127. package/_vendor/which-typed-array/index.js_commonjs-proxy.js +0 -1
  128. package/_virtual/_node-resolve_empty.js_commonjs-proxy.js +0 -6
  129. package/_virtual/commonjsHelpers.js +0 -18
  130. package/_virtual/node-resolve_empty.js +0 -8
  131. package/_virtual/polyfill-node.global.js +0 -5
  132. package/_virtual/polyfill-node.process.js +0 -225
  133. package/vendor/available-typed-arrays/index.js +0 -29
  134. package/vendor/call-bind/callBound.js +0 -19
  135. package/vendor/call-bind/index.js +0 -52
  136. package/vendor/deep-equal/index.js +0 -379
  137. package/vendor/deep-equal/node_modules/isarray/index.js +0 -7
  138. package/vendor/define-properties/index.js +0 -60
  139. package/vendor/es-abstract/helpers/getOwnPropertyDescriptor.js +0 -17
  140. package/vendor/es-get-iterator/index.js +0 -217
  141. package/vendor/es-get-iterator/node_modules/isarray/index.js +0 -7
  142. package/vendor/foreach/index.js +0 -22
  143. package/vendor/function-bind/implementation.js +0 -52
  144. package/vendor/function-bind/index.js +0 -7
  145. package/vendor/get-intrinsic/index.js +0 -334
  146. package/vendor/has/src/index.js +0 -7
  147. package/vendor/has-bigints/index.js +0 -12
  148. package/vendor/has-symbols/index.js +0 -15
  149. package/vendor/has-symbols/shams.js +0 -42
  150. package/vendor/has-tostringtag/shams.js +0 -9
  151. package/vendor/is-arguments/index.js +0 -36
  152. package/vendor/is-bigint/index.js +0 -39
  153. package/vendor/is-boolean-object/index.js +0 -29
  154. package/vendor/is-date-object/index.js +0 -22
  155. package/vendor/is-map/index.js +0 -42
  156. package/vendor/is-number-object/index.js +0 -26
  157. package/vendor/is-regex/index.js +0 -61
  158. package/vendor/is-set/index.js +0 -42
  159. package/vendor/is-string/index.js +0 -26
  160. package/vendor/is-symbol/index.js +0 -36
  161. package/vendor/is-typed-array/index.js +0 -67
  162. package/vendor/is-weakmap/index.js +0 -42
  163. package/vendor/is-weakset/index.js +0 -42
  164. package/vendor/object-inspect/index.js +0 -515
  165. package/vendor/object-is/implementation.js +0 -18
  166. package/vendor/object-is/index.js +0 -25
  167. package/vendor/object-is/polyfill.js +0 -9
  168. package/vendor/object-is/shim.js +0 -17
  169. package/vendor/object-keys/implementation.js +0 -124
  170. package/vendor/object-keys/index.js +0 -35
  171. package/vendor/object-keys/isArguments.js +0 -17
  172. package/vendor/object.assign/implementation.js +0 -46
  173. package/vendor/object.assign/index.js +0 -29
  174. package/vendor/object.assign/polyfill.js +0 -57
  175. package/vendor/object.assign/shim.js +0 -17
  176. package/vendor/regexp.prototype.flags/implementation.js +0 -30
  177. package/vendor/regexp.prototype.flags/index.js +0 -25
  178. package/vendor/regexp.prototype.flags/polyfill.js +0 -23
  179. package/vendor/regexp.prototype.flags/shim.js +0 -29
  180. package/vendor/side-channel/index.js +0 -128
  181. package/vendor/which-boxed-primitive/index.js +0 -38
  182. package/vendor/which-collection/index.js +0 -29
  183. package/vendor/which-typed-array/index.js +0 -63
@@ -11,7 +11,7 @@ import vtkPlane from '../../Common/DataModel/Plane.js';
11
11
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
12
12
  import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
13
13
  import vtkStateBuilder from '../Core/StateBuilder.js';
14
- import vtkWidgetRepresentation from './WidgetRepresentation.js';
14
+ import vtkWidgetRepresentation, { getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
15
15
  import WidgetManagerConst from '../Core/WidgetManager/Constants.js';
16
16
  import PropertyConst from '../../Rendering/Core/Property/Constants.js';
17
17
 
@@ -92,8 +92,8 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
92
92
 
93
93
  model.plane = vtkPlane.newInstance();
94
94
  model.matrix = vtkMatrixBuilder.buildFromDegree();
95
- model.pipelines = {};
96
- model.pipelines.outline = {
95
+ model._pipelines = {};
96
+ model._pipelines.outline = {
97
97
  source: vtkCubeSource.newInstance(),
98
98
  mapper: vtkMapper.newInstance(),
99
99
  actor: vtkActor.newInstance({
@@ -101,15 +101,18 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
101
101
  _parentProp: publicAPI
102
102
  })
103
103
  };
104
- model.pipelines.plane = {
105
- source: vtkClosedPolyLineToSurfaceFilter.newInstance(),
104
+ model._pipelines.plane = {
105
+ source: vtkCutter.newInstance({
106
+ cutFunction: model.plane
107
+ }),
108
+ filter: vtkClosedPolyLineToSurfaceFilter.newInstance(),
106
109
  mapper: vtkMapper.newInstance(),
107
110
  actor: vtkActor.newInstance({
108
111
  pickable: true,
109
112
  _parentProp: publicAPI
110
113
  })
111
114
  };
112
- model.pipelines.origin = {
115
+ model._pipelines.origin = {
113
116
  source: vtkSphereSource.newInstance(),
114
117
  mapper: vtkMapper.newInstance(),
115
118
  actor: vtkActor.newInstance({
@@ -117,7 +120,7 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
117
120
  _parentProp: publicAPI
118
121
  })
119
122
  };
120
- model.pipelines.normal = {
123
+ model._pipelines.normal = {
121
124
  source: vtkCylinderSource.newInstance(),
122
125
  mapper: vtkMapper.newInstance(),
123
126
  actor: vtkActor.newInstance({
@@ -125,7 +128,7 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
125
128
  _parentProp: publicAPI
126
129
  })
127
130
  };
128
- model.pipelines.display2D = {
131
+ model._pipelines.display2D = {
129
132
  source: publicAPI,
130
133
  mapper: vtkPixelSpaceCallbackMapper.newInstance(),
131
134
  actor: vtkActor.newInstance({
@@ -134,21 +137,18 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
134
137
  })
135
138
  }; // Plane generation pipeline
136
139
 
137
- var cutter = vtkCutter.newInstance({
138
- cutFunction: model.plane
139
- });
140
- cutter.setInputConnection(model.pipelines.outline.source.getOutputPort());
141
- model.pipelines.plane.source.setInputConnection(cutter.getOutputPort());
142
- vtkWidgetRepresentation.connectPipeline(model.pipelines.outline);
143
- vtkWidgetRepresentation.connectPipeline(model.pipelines.plane);
144
- vtkWidgetRepresentation.connectPipeline(model.pipelines.origin);
145
- vtkWidgetRepresentation.connectPipeline(model.pipelines.normal);
146
- vtkWidgetRepresentation.connectPipeline(model.pipelines.display2D);
147
- publicAPI.addActor(model.pipelines.outline.actor);
148
- publicAPI.addActor(model.pipelines.plane.actor);
149
- publicAPI.addActor(model.pipelines.origin.actor);
150
- publicAPI.addActor(model.pipelines.normal.actor);
151
- publicAPI.addActor(model.pipelines.display2D.actor); // --------------------------------------------------------------------------
140
+ model._pipelines.plane.source.setInputConnection(model._pipelines.outline.source.getOutputPort());
141
+
142
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.outline);
143
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.plane);
144
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.origin);
145
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.normal);
146
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.display2D);
147
+ publicAPI.addActor(model._pipelines.outline.actor);
148
+ publicAPI.addActor(model._pipelines.plane.actor);
149
+ publicAPI.addActor(model._pipelines.origin.actor);
150
+ publicAPI.addActor(model._pipelines.normal.actor);
151
+ publicAPI.addActor(model._pipelines.display2D.actor); // --------------------------------------------------------------------------
152
152
 
153
153
  publicAPI.requestData = function (inData, outData) {
154
154
  var state = inData[0];
@@ -165,46 +165,58 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
165
165
  // Update cube parameters
166
166
  // --------------------------------
167
167
 
168
- model.pipelines.outline.source.setCenter((bounds[0] + bounds[1]) * 0.5, (bounds[2] + bounds[3]) * 0.5, (bounds[4] + bounds[5]) * 0.5);
168
+ model._pipelines.outline.source.setCenter((bounds[0] + bounds[1]) * 0.5, (bounds[2] + bounds[3]) * 0.5, (bounds[4] + bounds[5]) * 0.5);
169
+
169
170
  var xRange = bounds[1] - bounds[0];
170
171
  var yRange = bounds[3] - bounds[2];
171
172
  var zRange = bounds[5] - bounds[4];
172
- model.pipelines.outline.source.setXLength(xRange);
173
- model.pipelines.outline.source.setYLength(yRange);
174
- model.pipelines.outline.source.setZLength(zRange); // --------------------------------
173
+
174
+ model._pipelines.outline.source.setXLength(xRange);
175
+
176
+ model._pipelines.outline.source.setYLength(yRange);
177
+
178
+ model._pipelines.outline.source.setZLength(zRange); // --------------------------------
175
179
  // Update normal parameters
176
180
  // --------------------------------
177
181
 
182
+
178
183
  var pixelScale = 1;
179
184
 
180
185
  if (model.scaleInPixels) {
181
- pixelScale = publicAPI.getPixelWorldHeightAtCoord(origin);
186
+ pixelScale = getPixelWorldHeightAtCoord(origin, model.displayScaleParams);
182
187
  }
183
188
 
184
- model.pipelines.normal.source.set({
189
+ model._pipelines.normal.source.set({
185
190
  height: Math.max(xRange, yRange, zRange),
186
191
  radius: model.handleSizeRatio * Math.min(xRange, yRange, zRange) * model.axisScale * pixelScale,
187
192
  resolution: model.sphereResolution
188
193
  });
189
- var yAxis = model.pipelines.normal.source.getOutputData();
194
+
195
+ var yAxis = model._pipelines.normal.source.getOutputData();
196
+
190
197
  var newAxis = vtkPolyData.newInstance();
191
198
  newAxis.shallowCopy(yAxis);
192
199
  newAxis.getPoints().setData(Float32Array.from(yAxis.getPoints().getData()), 3);
193
200
  newAxis.getPointData().removeAllArrays();
194
201
  model.matrix.identity().translate(origin[0], origin[1], origin[2]).rotateFromDirections([0, 1, 0], normal).apply(newAxis.getPoints().getData());
195
- model.pipelines.normal.mapper.setInputData(newAxis); // --------------------------------
202
+
203
+ model._pipelines.normal.mapper.setInputData(newAxis); // --------------------------------
196
204
  // Update origin parameters
197
205
  // --------------------------------
198
206
 
199
- model.pipelines.origin.actor.setPosition(origin);
207
+
208
+ model._pipelines.origin.actor.setPosition(origin);
209
+
200
210
  var handleScale = model.handleSizeRatio * Math.min(xRange, yRange, zRange) * pixelScale;
201
- model.pipelines.origin.actor.setScale(handleScale, handleScale, handleScale); // --------------------------------
211
+
212
+ model._pipelines.origin.actor.setScale(handleScale, handleScale, handleScale); // --------------------------------
202
213
  // Update style since state changed
203
214
  // --------------------------------
204
215
 
205
- vtkWidgetRepresentation.applyStyles(model.pipelines, model.representationStyle, state.getActive() && state.getActiveHandle());
216
+
217
+ vtkWidgetRepresentation.applyStyles(model._pipelines, model.representationStyle, state.getActive() && state.getActiveHandle());
206
218
  var output = vtkPolyData.newInstance();
207
- output.shallowCopy(model.pipelines.plane.source.getOutputData());
219
+ output.shallowCopy(model._pipelines.plane.filter.getOutputData());
208
220
  outData[0] = output;
209
221
  }; // --------------------------------------------------------------------------
210
222
  // Set/Get Forwarding
@@ -213,13 +225,13 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
213
225
 
214
226
  publicAPI.setSphereResolution = function (res) {
215
227
  model.sphereResolution = res;
216
- return model.pipelines.origin.source.setPhiResolution(res) && model.pipelines.origin.source.setThetaResolution(res);
228
+ return model._pipelines.origin.source.setPhiResolution(res) && model._pipelines.origin.source.setThetaResolution(res);
217
229
  };
218
230
 
219
231
  publicAPI.setRepresentationStyle = function (style) {
220
232
  model.representationStyle = vtkWidgetRepresentation.mergeStyles(STYLE_PIPELINE_NAMES, model.representationStyle, style); // Apply static and inactive
221
233
 
222
- vtkWidgetRepresentation.applyStyles(model.pipelines, model.representationStyle); // Force requestData to execute
234
+ vtkWidgetRepresentation.applyStyles(model._pipelines, model.representationStyle); // Force requestData to execute
223
235
 
224
236
  publicAPI.modified();
225
237
  }; // --------------------------------------------------------------------------
@@ -234,21 +246,28 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
234
246
  outlineVisible = model.outlineVisible;
235
247
 
236
248
  if (renderingType === RenderingTypes.PICKING_BUFFER) {
237
- model.pipelines.plane.actor.setVisibility(planeVisible);
238
- model.pipelines.origin.actor.setVisibility(originVisible);
239
- model.pipelines.normal.actor.setVisibility(normalVisible); //
249
+ model._pipelines.plane.actor.setVisibility(planeVisible);
250
+
251
+ model._pipelines.origin.actor.setVisibility(originVisible);
252
+
253
+ model._pipelines.normal.actor.setVisibility(normalVisible); //
240
254
 
241
- model.pipelines.plane.actor.getProperty().setOpacity(1);
255
+
256
+ model._pipelines.plane.actor.getProperty().setOpacity(1);
242
257
  } else {
243
- model.pipelines.outline.actor.setVisibility(outlineVisible && ctxVisible);
244
- model.pipelines.plane.actor.setVisibility(planeVisible && hVisible);
245
- model.pipelines.origin.actor.setVisibility(originVisible && hVisible);
246
- model.pipelines.normal.actor.setVisibility(normalVisible && hVisible); //
258
+ model._pipelines.outline.actor.setVisibility(outlineVisible && ctxVisible);
259
+
260
+ model._pipelines.plane.actor.setVisibility(planeVisible && hVisible);
261
+
262
+ model._pipelines.origin.actor.setVisibility(originVisible && hVisible);
263
+
264
+ model._pipelines.normal.actor.setVisibility(normalVisible && hVisible); //
265
+
247
266
 
248
267
  var state = model.inputData[0];
249
268
 
250
269
  if (state) {
251
- vtkWidgetRepresentation.applyStyles(model.pipelines, model.representationStyle, state.getActive() && state.getActiveHandle());
270
+ vtkWidgetRepresentation.applyStyles(model._pipelines, model.representationStyle, state.getActive() && state.getActiveHandle());
252
271
  }
253
272
  }
254
273
  }; // --------------------------------------------------------------------------
@@ -262,15 +281,15 @@ function vtkImplicitPlaneRepresentation(publicAPI, model) {
262
281
  state.setActiveHandle(prop);
263
282
 
264
283
  switch (prop) {
265
- case model.pipelines.plane.actor:
284
+ case model._pipelines.plane.actor:
266
285
  state.setUpdateMethodName('updateFromPlane');
267
286
  break;
268
287
 
269
- case model.pipelines.origin.actor:
288
+ case model._pipelines.origin.actor:
270
289
  state.setUpdateMethodName('updateFromOrigin');
271
290
  break;
272
291
 
273
- case model.pipelines.normal.actor:
292
+ case model._pipelines.normal.actor:
274
293
  state.setUpdateMethodName('updateFromNormal');
275
294
  break;
276
295
 
@@ -0,0 +1,116 @@
1
+ import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import macro from '../../macros.js';
3
+ import vtkActor from '../../Rendering/Core/Actor.js';
4
+ import vtkGlyphRepresentation from './GlyphRepresentation.js';
5
+ import vtkPixelSpaceCallbackMapper from '../../Rendering/Core/PixelSpaceCallbackMapper.js';
6
+ import vtkCylinderSource from '../../Filters/Sources/CylinderSource.js';
7
+ import { allocateArray } from './WidgetRepresentation.js';
8
+
9
+ 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; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ var INFINITE_RATIO = 100000; // ----------------------------------------------------------------------------
13
+ // vtkLineHandleRepresentation methods
14
+ // ----------------------------------------------------------------------------
15
+
16
+ function vtkLineHandleRepresentation(publicAPI, model) {
17
+ // Set our className
18
+ model.classHierarchy.push('vtkLineHandleRepresentation'); // --------------------------------------------------------------------------
19
+ // Generic rendering pipeline
20
+ // --------------------------------------------------------------------------
21
+
22
+ /*
23
+ * displayActors and displayMappers are used to render objects in HTML, allowing objects
24
+ * to be 'rendered' internally in a VTK scene without being visible on the final output
25
+ */
26
+
27
+ model.displayMapper = vtkPixelSpaceCallbackMapper.newInstance();
28
+ model.displayActor = vtkActor.newInstance({
29
+ parentProp: publicAPI
30
+ }); // model.displayActor.getProperty().setOpacity(0); // don't show in 3D
31
+
32
+ model.displayActor.setMapper(model.displayMapper);
33
+ model.displayMapper.setInputConnection(publicAPI.getOutputPort());
34
+ publicAPI.addActor(model.displayActor);
35
+ model.alwaysVisibleActors = [model.displayActor]; // --------------------------------------------------------------------------
36
+
37
+ publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, model._pipeline.glyph.setThetaResolution, model._pipeline.glyph.setPhiResolution); // --------------------------------------------------------------------------
38
+
39
+ function callbackProxy(coords) {
40
+ if (model.displayCallback) {
41
+ var filteredList = [];
42
+ var states = publicAPI.getRepresentationStates();
43
+
44
+ for (var i = 0; i < states.length; i++) {
45
+ if (states[i].getActive()) {
46
+ filteredList.push(coords[i]);
47
+ }
48
+ }
49
+
50
+ if (filteredList.length) {
51
+ model.displayCallback(filteredList);
52
+ return;
53
+ }
54
+ }
55
+
56
+ model.displayCallback();
57
+ }
58
+
59
+ publicAPI.setDisplayCallback = function (callback) {
60
+ model.displayCallback = callback;
61
+ model.displayMapper.setCallback(callback ? callbackProxy : null);
62
+ };
63
+ /**
64
+ * Overwrite scale3 to optionally make lines infinite
65
+ */
66
+
67
+
68
+ var superScale3 = publicAPI.getScale3();
69
+ publicAPI.setScale3(function (polyData, states) {
70
+ superScale3(polyData, states);
71
+
72
+ if (model.infiniteLine) {
73
+ var scales = allocateArray(polyData, 'scale', states.length, 'Float32Array', 3).getData();
74
+
75
+ for (var i = 0; i < states.length; ++i) {
76
+ scales[3 * i + 2] = INFINITE_RATIO;
77
+ }
78
+ }
79
+ });
80
+ } // ----------------------------------------------------------------------------
81
+ // Object factory
82
+ // ----------------------------------------------------------------------------
83
+
84
+
85
+ function defaultValues(initialValues) {
86
+ var _initialValues$glyphR;
87
+
88
+ return _objectSpread({
89
+ infiniteLine: true,
90
+ glyphResolution: 4,
91
+ _pipeline: {
92
+ glyph: vtkCylinderSource.newInstance({
93
+ resolution: (_initialValues$glyphR = initialValues.glyphResolution) !== null && _initialValues$glyphR !== void 0 ? _initialValues$glyphR : 4,
94
+ direction: [0, 0, 1]
95
+ })
96
+ }
97
+ }, initialValues);
98
+ } // ----------------------------------------------------------------------------
99
+
100
+
101
+ function extend(publicAPI, model) {
102
+ var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
103
+ vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
104
+ macro.setGet(publicAPI, model, ['infiniteLine', 'glyphResolution']); // Object specific methods
105
+
106
+ vtkLineHandleRepresentation(publicAPI, model);
107
+ } // ----------------------------------------------------------------------------
108
+
109
+ var newInstance = macro.newInstance(extend, 'vtkLineHandleRepresentation'); // ----------------------------------------------------------------------------
110
+
111
+ var vtkLineHandleRepresentation$1 = {
112
+ newInstance: newInstance,
113
+ extend: extend
114
+ };
115
+
116
+ export { vtkLineHandleRepresentation$1 as default, extend, newInstance };
@@ -4,10 +4,10 @@ import vtkActor from '../../Rendering/Core/Actor.js';
4
4
  import vtkMapper from '../../Rendering/Core/Mapper.js';
5
5
  import { C as areEquals } from '../../Common/Core/Math/index.js';
6
6
  import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
7
- import vtkPolyData from '../../Common/DataModel/PolyData.js';
8
7
  import vtkTubeFilter from '../../Filters/General/TubeFilter.js';
9
- import vtkWidgetRepresentation from './WidgetRepresentation.js';
8
+ import vtkWidgetRepresentation, { allocateArray, getPixelWorldHeightAtCoord } from './WidgetRepresentation.js';
10
9
  import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
10
+ import vtkPolyData from '../../Common/DataModel/PolyData.js';
11
11
 
12
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; }
13
13
 
@@ -24,36 +24,35 @@ function vtkPolyLineRepresentation(publicAPI, model) {
24
24
  // --------------------------------------------------------------------------
25
25
 
26
26
 
27
- model.internalPolyData = vtkPolyData.newInstance({
27
+ var internalPolyData = vtkPolyData.newInstance({
28
28
  mtime: 0
29
29
  });
30
- model.cells = [];
31
30
 
32
- function allocateSize(size) {
33
- var closePolyLine = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
31
+ function allocateSize(polyData, size) {
32
+ var closePolyLine = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
33
+ var points = null;
34
34
 
35
35
  if (size < 2) {
36
- model.internalPolyData.getPoints().setData(new Float32Array([0, 0, 0]));
37
- model.internalPolyData.getLines().setData(new Uint8Array(0));
38
- } else if (!model.points || model.points.length !== size * 3) {
39
- model.points = new Float32Array(size * 3);
40
- model.cells = new Uint8Array(size + 1 + (closePolyLine ? 1 : 0));
41
- model.cells[0] = model.cells.length - 1;
42
-
43
- for (var i = 1; i < model.cells.length; i++) {
44
- model.cells[i] = i - 1;
36
+ // FIXME: Why 1 point and not 0 ?
37
+ points = allocateArray(polyData, 'points', 1).getData();
38
+ points.set([0, 0, 0]);
39
+ allocateArray(polyData, 'lines', 0).getData();
40
+ } else if (!polyData.getPoints() || polyData.getPoints().length !== size * 3) {
41
+ points = allocateArray(polyData, 'points', size).getData();
42
+ var cellSize = size + 1 + (closePolyLine ? 1 : 0);
43
+ var cells = allocateArray(polyData, 'lines', cellSize).getData();
44
+ cells[0] = cells.length - 1;
45
+
46
+ for (var i = 1; i < cells.length; i++) {
47
+ cells[i] = i - 1;
45
48
  }
46
49
 
47
50
  if (closePolyLine) {
48
- model.cells[model.cells.length - 1] = 0;
49
- console.log('closePolyLine', closePolyLine, model.cells);
51
+ cells[cells.length - 1] = 0;
50
52
  }
51
-
52
- model.internalPolyData.getPoints().setData(model.points, 3);
53
- model.internalPolyData.getLines().setData(model.cells);
54
53
  }
55
54
 
56
- return model.points;
55
+ return points;
57
56
  }
58
57
  /**
59
58
  * Change the line/tube thickness.
@@ -64,34 +63,39 @@ function vtkPolyLineRepresentation(publicAPI, model) {
64
63
  function applyLineThickness(lineThickness) {
65
64
  var scaledLineThickness = lineThickness;
66
65
 
67
- if (publicAPI.getScaleInPixels()) {
68
- var center = vtkBoundingBox.getCenter(model.internalPolyData.getBounds());
69
- scaledLineThickness *= publicAPI.getPixelWorldHeightAtCoord(center);
66
+ if (publicAPI.getScaleInPixels() && internalPolyData) {
67
+ var center = vtkBoundingBox.getCenter(internalPolyData.getBounds());
68
+ scaledLineThickness *= getPixelWorldHeightAtCoord(center, model.displayScaleParams);
70
69
  }
71
70
 
72
- model.tubes.setRadius(scaledLineThickness);
71
+ model._pipelines.tubes.filter.setRadius(scaledLineThickness);
73
72
  } // --------------------------------------------------------------------------
74
73
  // Generic rendering pipeline
75
74
  // --------------------------------------------------------------------------
76
75
 
77
76
 
78
- model.mapper = vtkMapper.newInstance();
79
- model.actor = vtkActor.newInstance({
80
- parentProp: publicAPI
81
- });
82
- model.tubes = vtkTubeFilter.newInstance({
83
- radius: model.lineThickness,
84
- numberOfSides: 12,
85
- capping: false
86
- });
87
- model.tubes.setInputConnection(publicAPI.getOutputPort());
88
- model.mapper.setInputConnection(model.tubes.getOutputPort()); // model.mapper.setInputConnection(publicAPI.getOutputPort());
89
-
90
- model.actor.setMapper(model.mapper);
91
- publicAPI.addActor(model.actor); // --------------------------------------------------------------------------
77
+ model._pipelines = {
78
+ tubes: {
79
+ source: publicAPI,
80
+ filter: vtkTubeFilter.newInstance({
81
+ radius: model.lineThickness,
82
+ numberOfSides: 12,
83
+ capping: false
84
+ }),
85
+ mapper: vtkMapper.newInstance(),
86
+ actor: vtkActor.newInstance({
87
+ parentProp: publicAPI
88
+ })
89
+ }
90
+ };
91
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.tubes);
92
+ publicAPI.addActor(model._pipelines.tubes.actor); // --------------------------------------------------------------------------
92
93
 
93
94
  publicAPI.requestData = function (inData, outData) {
94
- var state = inData[0]; // Remove invalid and coincident points for tube filter.
95
+ var _state$getLineThickne, _state$getLineThickne2;
96
+
97
+ var state = inData[0];
98
+ outData[0] = internalPolyData; // Remove invalid and coincident points for tube filter.
95
99
 
96
100
  var list = publicAPI.getRepresentationStates(state).reduce(function (subStates, subState) {
97
101
  var subStateOrigin = subState.getOrigin && subState.getOrigin() ? subState.getOrigin() : null;
@@ -105,7 +109,7 @@ function vtkPolyLineRepresentation(publicAPI, model) {
105
109
  return subStates;
106
110
  }, []);
107
111
  var size = list.length;
108
- var points = allocateSize(size, model.closePolyLine && size > 2);
112
+ var points = allocateSize(outData[0], size, model.closePolyLine && size > 2);
109
113
 
110
114
  if (points) {
111
115
  for (var i = 0; i < size; i++) {
@@ -116,10 +120,9 @@ function vtkPolyLineRepresentation(publicAPI, model) {
116
120
  }
117
121
  }
118
122
 
119
- model.internalPolyData.modified();
120
- var lineThickness = state.getLineThickness ? state.getLineThickness() : null;
121
- applyLineThickness(lineThickness || model.lineThickness);
122
- outData[0] = model.internalPolyData;
123
+ outData[0].modified();
124
+ var lineThickness = (_state$getLineThickne = (_state$getLineThickne2 = state.getLineThickness) === null || _state$getLineThickne2 === void 0 ? void 0 : _state$getLineThickne2.call(state)) !== null && _state$getLineThickne !== void 0 ? _state$getLineThickne : model.lineThickness;
125
+ applyLineThickness(lineThickness);
123
126
  };
124
127
  /**
125
128
  * When mousing over the line, if behavior != CONTEXT,
@@ -135,18 +138,18 @@ function vtkPolyLineRepresentation(publicAPI, model) {
135
138
  };
136
139
 
137
140
  publicAPI.updateActorVisibility = function (renderingType, ctxVisible, hVisible) {
141
+ var _state$getLineThickne3, _state$getLineThickne4;
142
+
138
143
  var state = model.inputData[0]; // Make lines/tubes thicker for picking
139
144
 
140
- var lineThickness = state.getLineThickness ? state.getLineThickness() : null;
141
- lineThickness = lineThickness || model.lineThickness;
145
+ var lineThickness = (_state$getLineThickne3 = (_state$getLineThickne4 = state.getLineThickness) === null || _state$getLineThickne4 === void 0 ? void 0 : _state$getLineThickne4.call(state)) !== null && _state$getLineThickne3 !== void 0 ? _state$getLineThickne3 : model.lineThickness;
142
146
 
143
147
  if (renderingType === RenderingTypes.PICKING_BUFFER) {
144
148
  lineThickness = Math.max(4, lineThickness);
145
149
  }
146
150
 
147
151
  applyLineThickness(lineThickness);
148
- var isValid = model.points && model.points.length > 3;
149
- return superClass.updateActorVisibility(renderingType, ctxVisible && isValid, hVisible && isValid);
152
+ return superClass.updateActorVisibility(renderingType, ctxVisible, hVisible);
150
153
  };
151
154
  } // ----------------------------------------------------------------------------
152
155
  // Object factory
@@ -3,6 +3,7 @@ import vtkActor from '../../Rendering/Core/Actor.js';
3
3
  import vtkContextRepresentation from './ContextRepresentation.js';
4
4
  import vtkMapper from '../../Rendering/Core/Mapper.js';
5
5
  import vtkPolyData from '../../Common/DataModel/PolyData.js';
6
+ import { allocateArray } from './WidgetRepresentation.js';
6
7
  import { vec3 } from 'gl-matrix';
7
8
 
8
9
  // vtkRectangleContextRepresentation methods
@@ -14,6 +15,9 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
14
15
  // Generic rendering pipeline
15
16
  // --------------------------------------------------------------------------
16
17
 
18
+ model.internalPolyData = vtkPolyData.newInstance({
19
+ mtime: 0
20
+ });
17
21
  model.mapper = vtkMapper.newInstance();
18
22
  model.actor = vtkActor.newInstance({
19
23
  parentProp: publicAPI
@@ -24,16 +28,6 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
24
28
  model.actor.getProperty().setColor(0, 1, 0);
25
29
  publicAPI.addActor(model.actor); // --------------------------------------------------------------------------
26
30
 
27
- publicAPI.setDrawBorder = function (draw) {
28
- model.drawBorder = draw;
29
- }; // --------------------------------------------------------------------------
30
-
31
-
32
- publicAPI.setDrawFace = function (draw) {
33
- model.drawFace = draw;
34
- }; // --------------------------------------------------------------------------
35
-
36
-
37
31
  publicAPI.setOpacity = function (opacity) {
38
32
  model.actor.getProperty().setOpacity(opacity);
39
33
  }; // --------------------------------------------------------------------------
@@ -44,18 +38,18 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
44
38
  return;
45
39
  }
46
40
 
47
- var list = publicAPI.getRepresentationStates(inData[0]);
41
+ var list = publicAPI.getRepresentationStates(inData[0]); // FIXME: support list > 1.
42
+
48
43
  var state = list[0];
49
- var dataset = vtkPolyData.newInstance();
50
44
 
51
- if (state.getVisible() && state.getOrigin()) {
45
+ if (state !== null && state !== void 0 && state.getVisible() && state !== null && state !== void 0 && state.getOrigin()) {
52
46
  var point1 = state.getOrigin();
53
47
  var point2 = state.getCorner();
54
48
  var diagonal = [0, 0, 0];
55
49
  vec3.subtract(diagonal, point2, point1);
56
50
  var up = state.getUp();
57
51
  var upComponent = vec3.dot(diagonal, up);
58
- var points = new Float32Array(4 * 3);
52
+ var points = allocateArray(model.internalPolyData, 'points', 4).getData();
59
53
  points[0] = point1[0];
60
54
  points[1] = point1[1];
61
55
  points[2] = point1[2];
@@ -68,24 +62,24 @@ function vtkRectangleContextRepresentation(publicAPI, model) {
68
62
  points[9] = point2[0] - upComponent * up[0];
69
63
  points[10] = point2[1] - upComponent * up[1];
70
64
  points[11] = point2[2] - upComponent * up[2];
71
- dataset.getPoints().setData(points, 3);
72
65
 
73
66
  if (model.drawFace) {
74
67
  var polys = new Uint32Array([4, 0, 1, 2, 3]);
75
- dataset.getPolys().setData(polys, 1);
68
+ model.internalPolyData.getPolys().setData(polys, 1);
76
69
  }
77
70
 
78
71
  if (model.drawBorder) {
79
72
  var line = new Uint32Array([5, 0, 1, 2, 3, 0]);
80
- dataset.getLines().setData(line, 1);
73
+ model.internalPolyData.getLines().setData(line, 1);
81
74
  }
82
75
  } else {
83
- dataset.getPoints().setData([], 0);
84
- dataset.getPolys().setData([], 0);
85
- dataset.getLines().setData([], 0);
76
+ model.internalPolyData.getPoints().setData([], 0);
77
+ model.internalPolyData.getPolys().setData([], 0);
78
+ model.internalPolyData.getLines().setData([], 0);
86
79
  }
87
80
 
88
- outData[0] = dataset;
81
+ model.internalPolyData.modified();
82
+ outData[0] = model.internalPolyData;
89
83
  };
90
84
 
91
85
  publicAPI.getSelectedState = function (prop, compositeID) {
@@ -106,6 +100,7 @@ function extend(publicAPI, model) {
106
100
  Object.assign(model, DEFAULT_VALUES, initialValues);
107
101
  vtkContextRepresentation.extend(publicAPI, model, initialValues);
108
102
  macro.setGetArray(publicAPI, model, ['color'], 1);
103
+ macro.setGet(publicAPI, model, ['drawBorder', 'drawFace']);
109
104
  macro.get(publicAPI, model, ['mapper', 'actor']); // Object specific methods
110
105
 
111
106
  vtkRectangleContextRepresentation(publicAPI, model);