@kitware/vtk.js 25.10.0 → 26.0.0-beta.2

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 (197) 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/ColorTransferFunction.d.ts +0 -20
  8. package/Rendering/Core/ColorTransferFunction.js +0 -63
  9. package/Rendering/Core/Prop3D.js +1 -6
  10. package/Rendering/Core/RenderWindow.js +9 -6
  11. package/Rendering/Core/VolumeProperty.js +2 -3
  12. package/Rendering/Misc/CanvasView.js +6 -5
  13. package/Rendering/Misc/GenericRenderWindow.js +12 -7
  14. package/Rendering/OpenGL/Actor.js +4 -4
  15. package/Rendering/OpenGL/Actor2D.js +4 -4
  16. package/Rendering/OpenGL/Camera.js +7 -4
  17. package/Rendering/OpenGL/CubeAxesActor.js +7 -5
  18. package/Rendering/OpenGL/ForwardPass.js +1 -1
  19. package/Rendering/OpenGL/Glyph3DMapper.js +4 -4
  20. package/Rendering/OpenGL/ImageMapper.js +9 -5
  21. package/Rendering/OpenGL/ImageSlice.js +3 -3
  22. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +9 -5
  23. package/Rendering/OpenGL/PolyDataMapper.js +27 -21
  24. package/Rendering/OpenGL/PolyDataMapper2D.js +17 -10
  25. package/Rendering/OpenGL/ScalarBarActor.js +6 -4
  26. package/Rendering/OpenGL/Skybox.js +10 -6
  27. package/Rendering/OpenGL/Texture.js +6 -5
  28. package/Rendering/OpenGL/Volume.js +2 -2
  29. package/Rendering/OpenGL/VolumeMapper.js +11 -11
  30. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  31. package/Rendering/SceneGraph/RenderPass.js +3 -2
  32. package/Rendering/WebGPU/ForwardPass.js +1 -1
  33. package/Rendering/WebGPU/HardwareSelectionPass.js +1 -1
  34. package/Rendering/WebGPU/HardwareSelector.js +14 -13
  35. package/Rendering/WebGPU/OpaquePass.js +1 -1
  36. package/Rendering/WebGPU/OrderIndependentTranslucentPass.js +1 -1
  37. package/Rendering/WebGPU/VolumePass.js +1 -1
  38. package/Utilities/config/rules-tests.js +28 -0
  39. package/Widgets/Core/AbstractWidgetFactory.js +1 -0
  40. package/Widgets/Core/StateBuilder/color3Mixin.js +22 -0
  41. package/Widgets/Core/StateBuilder/colorMixin.js +7 -0
  42. package/Widgets/Core/StateBuilder.js +2 -0
  43. package/Widgets/Core/WidgetManager.js +21 -256
  44. package/Widgets/Representations/ArrowHandleRepresentation.js +28 -110
  45. package/Widgets/Representations/CircleContextRepresentation.js +43 -165
  46. package/Widgets/Representations/ContextRepresentation.js +0 -3
  47. package/Widgets/Representations/ConvexFaceContextRepresentation.js +11 -11
  48. package/Widgets/Representations/CroppingOutlineRepresentation.js +5 -12
  49. package/Widgets/Representations/CubeHandleRepresentation.js +15 -104
  50. package/Widgets/Representations/GlyphRepresentation.js +320 -0
  51. package/Widgets/Representations/HandleRepresentation.js +0 -5
  52. package/Widgets/Representations/ImplicitPlaneRepresentation.js +68 -49
  53. package/Widgets/Representations/LineHandleRepresentation.js +116 -0
  54. package/Widgets/Representations/PolyLineRepresentation.js +52 -49
  55. package/Widgets/Representations/RectangleContextRepresentation.js +16 -21
  56. package/Widgets/Representations/SphereContextRepresentation.js +30 -109
  57. package/Widgets/Representations/SphereHandleRepresentation.js +13 -110
  58. package/Widgets/Representations/SplineContextRepresentation.js +53 -36
  59. package/Widgets/Representations/WidgetRepresentation.d.ts +52 -1
  60. package/Widgets/Representations/WidgetRepresentation.js +140 -78
  61. package/Widgets/Representations.js +6 -0
  62. package/Widgets/Widgets3D/AngleWidget.js +1 -4
  63. package/Widgets/Widgets3D/EllipseWidget/state.js +1 -1
  64. package/Widgets/Widgets3D/EllipseWidget.js +0 -7
  65. package/Widgets/Widgets3D/LabelWidget/behavior.js +0 -7
  66. package/Widgets/Widgets3D/LabelWidget.js +1 -18
  67. package/Widgets/Widgets3D/LineWidget/behavior.js +0 -44
  68. package/Widgets/Widgets3D/LineWidget.js +0 -11
  69. package/Widgets/Widgets3D/PolyLineWidget.js +0 -10
  70. package/Widgets/Widgets3D/RectangleWidget.js +0 -7
  71. package/Widgets/Widgets3D/ResliceCursorWidget/Constants.js +15 -3
  72. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +93 -36
  73. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +75 -82
  74. package/Widgets/Widgets3D/ResliceCursorWidget/state.js +49 -170
  75. package/Widgets/Widgets3D/ResliceCursorWidget.js +61 -23
  76. package/Widgets/Widgets3D/ShapeWidget.js +1 -1
  77. package/index.d.ts +0 -1
  78. package/macros.d.ts +3 -5
  79. package/macros.js +4 -35
  80. package/package.json +3 -2
  81. package/Widgets/Core/WidgetManager/vdom.js +0 -172
  82. package/Widgets/Representations/ResliceCursorContextRepresentation/Constants.js +0 -12
  83. package/Widgets/Representations/ResliceCursorContextRepresentation.d.ts +0 -54
  84. package/Widgets/Representations/ResliceCursorContextRepresentation.js +0 -357
  85. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +0 -28
  86. package/Widgets/SVG/SVGLandmarkRepresentation.js +0 -179
  87. package/Widgets/SVG/SVGRepresentation.js +0 -163
  88. package/_vendor/available-typed-arrays/index.js_commonjs-proxy.js +0 -1
  89. package/_vendor/call-bind/callBound.js_commonjs-proxy.js +0 -1
  90. package/_vendor/call-bind/index.js_commonjs-module.js +0 -3
  91. package/_vendor/call-bind/index.js_commonjs-proxy.js +0 -1
  92. package/_vendor/deep-equal/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  93. package/_vendor/define-properties/index.js_commonjs-proxy.js +0 -1
  94. package/_vendor/es-abstract/helpers/getOwnPropertyDescriptor.js_commonjs-proxy.js +0 -1
  95. package/_vendor/es-get-iterator/index.js_commonjs-module.js +0 -3
  96. package/_vendor/es-get-iterator/index.js_commonjs-proxy.js +0 -1
  97. package/_vendor/es-get-iterator/node_modules/isarray/index.js_commonjs-proxy.js +0 -1
  98. package/_vendor/foreach/index.js_commonjs-proxy.js +0 -1
  99. package/_vendor/function-bind/implementation.js_commonjs-proxy.js +0 -1
  100. package/_vendor/function-bind/index.js_commonjs-proxy.js +0 -1
  101. package/_vendor/get-intrinsic/index.js_commonjs-proxy.js +0 -1
  102. package/_vendor/has/src/index.js_commonjs-proxy.js +0 -1
  103. package/_vendor/has-bigints/index.js_commonjs-proxy.js +0 -1
  104. package/_vendor/has-symbols/index.js_commonjs-proxy.js +0 -1
  105. package/_vendor/has-symbols/shams.js_commonjs-proxy.js +0 -1
  106. package/_vendor/has-tostringtag/shams.js_commonjs-proxy.js +0 -1
  107. package/_vendor/is-arguments/index.js_commonjs-proxy.js +0 -1
  108. package/_vendor/is-bigint/index.js_commonjs-module.js +0 -3
  109. package/_vendor/is-bigint/index.js_commonjs-proxy.js +0 -1
  110. package/_vendor/is-boolean-object/index.js_commonjs-proxy.js +0 -1
  111. package/_vendor/is-date-object/index.js_commonjs-proxy.js +0 -1
  112. package/_vendor/is-map/index.js_commonjs-proxy.js +0 -1
  113. package/_vendor/is-number-object/index.js_commonjs-proxy.js +0 -1
  114. package/_vendor/is-regex/index.js_commonjs-proxy.js +0 -1
  115. package/_vendor/is-set/index.js_commonjs-proxy.js +0 -1
  116. package/_vendor/is-string/index.js_commonjs-proxy.js +0 -1
  117. package/_vendor/is-symbol/index.js_commonjs-module.js +0 -3
  118. package/_vendor/is-symbol/index.js_commonjs-proxy.js +0 -1
  119. package/_vendor/is-typed-array/index.js_commonjs-proxy.js +0 -1
  120. package/_vendor/is-weakmap/index.js_commonjs-proxy.js +0 -1
  121. package/_vendor/is-weakset/index.js_commonjs-proxy.js +0 -1
  122. package/_vendor/object-inspect/index.js_commonjs-proxy.js +0 -1
  123. package/_vendor/object-is/implementation.js_commonjs-proxy.js +0 -1
  124. package/_vendor/object-is/index.js_commonjs-proxy.js +0 -1
  125. package/_vendor/object-is/polyfill.js_commonjs-proxy.js +0 -1
  126. package/_vendor/object-is/shim.js_commonjs-proxy.js +0 -1
  127. package/_vendor/object-keys/implementation.js_commonjs-proxy.js +0 -1
  128. package/_vendor/object-keys/index.js_commonjs-proxy.js +0 -1
  129. package/_vendor/object-keys/isArguments.js_commonjs-proxy.js +0 -1
  130. package/_vendor/object.assign/implementation.js_commonjs-proxy.js +0 -1
  131. package/_vendor/object.assign/index.js_commonjs-proxy.js +0 -1
  132. package/_vendor/object.assign/polyfill.js_commonjs-proxy.js +0 -1
  133. package/_vendor/object.assign/shim.js_commonjs-proxy.js +0 -2
  134. package/_vendor/regexp.prototype.flags/implementation.js_commonjs-proxy.js +0 -1
  135. package/_vendor/regexp.prototype.flags/index.js_commonjs-proxy.js +0 -1
  136. package/_vendor/regexp.prototype.flags/polyfill.js_commonjs-proxy.js +0 -1
  137. package/_vendor/regexp.prototype.flags/shim.js_commonjs-proxy.js +0 -1
  138. package/_vendor/side-channel/index.js_commonjs-proxy.js +0 -1
  139. package/_vendor/which-boxed-primitive/index.js_commonjs-proxy.js +0 -5
  140. package/_vendor/which-collection/index.js_commonjs-proxy.js +0 -4
  141. package/_vendor/which-typed-array/index.js_commonjs-proxy.js +0 -1
  142. package/_virtual/_node-resolve_empty.js_commonjs-proxy.js +0 -6
  143. package/_virtual/commonjsHelpers.js +0 -18
  144. package/_virtual/node-resolve_empty.js +0 -8
  145. package/_virtual/polyfill-node.global.js +0 -5
  146. package/_virtual/polyfill-node.process.js +0 -225
  147. package/vendor/available-typed-arrays/index.js +0 -29
  148. package/vendor/call-bind/callBound.js +0 -19
  149. package/vendor/call-bind/index.js +0 -52
  150. package/vendor/deep-equal/index.js +0 -379
  151. package/vendor/deep-equal/node_modules/isarray/index.js +0 -7
  152. package/vendor/define-properties/index.js +0 -60
  153. package/vendor/es-abstract/helpers/getOwnPropertyDescriptor.js +0 -17
  154. package/vendor/es-get-iterator/index.js +0 -217
  155. package/vendor/es-get-iterator/node_modules/isarray/index.js +0 -7
  156. package/vendor/foreach/index.js +0 -22
  157. package/vendor/function-bind/implementation.js +0 -52
  158. package/vendor/function-bind/index.js +0 -7
  159. package/vendor/get-intrinsic/index.js +0 -334
  160. package/vendor/has/src/index.js +0 -7
  161. package/vendor/has-bigints/index.js +0 -12
  162. package/vendor/has-symbols/index.js +0 -15
  163. package/vendor/has-symbols/shams.js +0 -42
  164. package/vendor/has-tostringtag/shams.js +0 -9
  165. package/vendor/is-arguments/index.js +0 -36
  166. package/vendor/is-bigint/index.js +0 -39
  167. package/vendor/is-boolean-object/index.js +0 -29
  168. package/vendor/is-date-object/index.js +0 -22
  169. package/vendor/is-map/index.js +0 -42
  170. package/vendor/is-number-object/index.js +0 -26
  171. package/vendor/is-regex/index.js +0 -61
  172. package/vendor/is-set/index.js +0 -42
  173. package/vendor/is-string/index.js +0 -26
  174. package/vendor/is-symbol/index.js +0 -36
  175. package/vendor/is-typed-array/index.js +0 -67
  176. package/vendor/is-weakmap/index.js +0 -42
  177. package/vendor/is-weakset/index.js +0 -42
  178. package/vendor/object-inspect/index.js +0 -515
  179. package/vendor/object-is/implementation.js +0 -18
  180. package/vendor/object-is/index.js +0 -25
  181. package/vendor/object-is/polyfill.js +0 -9
  182. package/vendor/object-is/shim.js +0 -17
  183. package/vendor/object-keys/implementation.js +0 -124
  184. package/vendor/object-keys/index.js +0 -35
  185. package/vendor/object-keys/isArguments.js +0 -17
  186. package/vendor/object.assign/implementation.js +0 -46
  187. package/vendor/object.assign/index.js +0 -29
  188. package/vendor/object.assign/polyfill.js +0 -57
  189. package/vendor/object.assign/shim.js +0 -17
  190. package/vendor/regexp.prototype.flags/implementation.js +0 -30
  191. package/vendor/regexp.prototype.flags/index.js +0 -25
  192. package/vendor/regexp.prototype.flags/polyfill.js +0 -23
  193. package/vendor/regexp.prototype.flags/shim.js +0 -29
  194. package/vendor/side-channel/index.js +0 -128
  195. package/vendor/which-boxed-primitive/index.js +0 -38
  196. package/vendor/which-collection/index.js +0 -29
  197. package/vendor/which-typed-array/index.js +0 -63
@@ -1,12 +1,7 @@
1
1
  import macro from '../../macros.js';
2
2
  import vtkActor from '../../Rendering/Core/Actor.js';
3
- import vtkDataArray from '../../Common/Core/DataArray.js';
4
- import vtkGlyph3DMapper from '../../Rendering/Core/Glyph3DMapper.js';
5
- import vtkHandleRepresentation from './HandleRepresentation.js';
3
+ import vtkGlyphRepresentation from './GlyphRepresentation.js';
6
4
  import vtkPixelSpaceCallbackMapper from '../../Rendering/Core/PixelSpaceCallbackMapper.js';
7
- import vtkPolyData from '../../Common/DataModel/PolyData.js';
8
- import vtkSphereSource from '../../Filters/Sources/SphereSource.js';
9
- import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
10
5
 
11
6
  // vtkSphereHandleRepresentation methods
12
7
  // ----------------------------------------------------------------------------
@@ -14,27 +9,6 @@ import { ScalarMode } from '../../Rendering/Core/Mapper/Constants.js';
14
9
  function vtkSphereHandleRepresentation(publicAPI, model) {
15
10
  // Set our className
16
11
  model.classHierarchy.push('vtkSphereHandleRepresentation'); // --------------------------------------------------------------------------
17
- // Internal polydata dataset
18
- // --------------------------------------------------------------------------
19
-
20
- model.internalPolyData = vtkPolyData.newInstance({
21
- mtime: 0
22
- });
23
- model.internalArrays = {
24
- points: model.internalPolyData.getPoints(),
25
- scale: vtkDataArray.newInstance({
26
- name: 'scale',
27
- numberOfComponents: 1,
28
- empty: true
29
- }),
30
- color: vtkDataArray.newInstance({
31
- name: 'color',
32
- numberOfComponents: 1,
33
- empty: true
34
- })
35
- };
36
- model.internalPolyData.getPointData().addArray(model.internalArrays.scale);
37
- model.internalPolyData.getPointData().addArray(model.internalArrays.color); // --------------------------------------------------------------------------
38
12
  // Generic rendering pipeline
39
13
  // --------------------------------------------------------------------------
40
14
 
@@ -51,27 +25,16 @@ function vtkSphereHandleRepresentation(publicAPI, model) {
51
25
  model.displayActor.setMapper(model.displayMapper);
52
26
  model.displayMapper.setInputConnection(publicAPI.getOutputPort());
53
27
  publicAPI.addActor(model.displayActor);
54
- model.alwaysVisibleActors = [model.displayActor];
55
- model.mapper = vtkGlyph3DMapper.newInstance({
56
- scaleArray: 'scale',
57
- colorByArrayName: 'color',
58
- scalarMode: ScalarMode.USE_POINT_FIELD_DATA
59
- });
60
- model.actor = vtkActor.newInstance({
61
- parentProp: publicAPI
62
- });
63
- model.glyph = vtkSphereSource.newInstance({
64
- phiResolution: model.glyphResolution,
65
- thetaResolution: model.glyphResolution
66
- });
67
- model.mapper.setInputConnection(publicAPI.getOutputPort(), 0);
68
- model.mapper.setInputConnection(model.glyph.getOutputPort(), 1);
69
- model.actor.setMapper(model.mapper);
70
- publicAPI.addActor(model.actor); // --------------------------------------------------------------------------
71
-
72
- publicAPI.setGlyphResolution = macro.chain(publicAPI.setGlyphResolution, function (r) {
73
- return model.glyph.setPhiResolution(r) && model.glyph.setThetaResolution(r);
74
- }); // --------------------------------------------------------------------------
28
+ model.alwaysVisibleActors = [model.displayActor]; // --------------------------------------------------------------------------
29
+
30
+ publicAPI.getGlyphResolution = function () {
31
+ return model._pipeline.glyph.getPhiResolution();
32
+ };
33
+
34
+ publicAPI.setGlyphResolution = function (resolution) {
35
+ return model._pipeline.glyph.setPhiResolution(resolution) || model._pipeline.glyph.setThetaResolution(resolution);
36
+ }; // --------------------------------------------------------------------------
37
+
75
38
 
76
39
  function callbackProxy(coords) {
77
40
  if (model.displayCallback) {
@@ -97,75 +60,15 @@ function vtkSphereHandleRepresentation(publicAPI, model) {
97
60
  model.displayCallback = callback;
98
61
  model.displayMapper.setCallback(callback ? callbackProxy : null);
99
62
  };
100
-
101
- var superGetRepresentationStates = publicAPI.getRepresentationStates;
102
-
103
- publicAPI.getRepresentationStates = function () {
104
- var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
105
- return superGetRepresentationStates(input).filter(function (state) {
106
- var _state$getOrigin, _state$isVisible;
107
-
108
- return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
109
- });
110
- }; // --------------------------------------------------------------------------
111
-
112
-
113
- publicAPI.requestData = function (inData, outData) {
114
- var _model$internalArrays = model.internalArrays,
115
- points = _model$internalArrays.points,
116
- scale = _model$internalArrays.scale,
117
- color = _model$internalArrays.color;
118
- var list = publicAPI.getRepresentationStates(inData[0]);
119
- var totalCount = list.length;
120
-
121
- if (color.getNumberOfValues() !== totalCount) {
122
- // Need to resize dataset
123
- points.setData(new Float32Array(3 * totalCount), 3);
124
- scale.setData(new Float32Array(totalCount));
125
- color.setData(new Float32Array(totalCount));
126
- }
127
-
128
- var typedArray = {
129
- points: points.getData(),
130
- scale: scale.getData(),
131
- color: color.getData()
132
- };
133
-
134
- for (var i = 0; i < totalCount; i++) {
135
- var state = list[i];
136
- var isActive = state.getActive();
137
- var scaleFactor = isActive ? model.activeScaleFactor : 1;
138
- var coord = state.getOrigin();
139
- typedArray.points[i * 3 + 0] = coord[0];
140
- typedArray.points[i * 3 + 1] = coord[1];
141
- typedArray.points[i * 3 + 2] = coord[2];
142
- typedArray.scale[i] = scaleFactor * (state.getScale1 ? state.getScale1() : model.defaultScale);
143
-
144
- if (publicAPI.getScaleInPixels()) {
145
- typedArray.scale[i] *= publicAPI.getPixelWorldHeightAtCoord(coord);
146
- }
147
-
148
- typedArray.color[i] = model.useActiveColor && isActive ? model.activeColor : state.getColor();
149
- }
150
-
151
- model.internalPolyData.modified();
152
- outData[0] = model.internalPolyData;
153
- };
154
63
  } // ----------------------------------------------------------------------------
155
64
  // Object factory
156
65
  // ----------------------------------------------------------------------------
66
+ // ----------------------------------------------------------------------------
157
67
 
158
68
 
159
- var DEFAULT_VALUES = {
160
- glyphResolution: 8,
161
- defaultScale: 1
162
- }; // ----------------------------------------------------------------------------
163
-
164
69
  function extend(publicAPI, model) {
165
70
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
166
- Object.assign(model, DEFAULT_VALUES, initialValues);
167
- vtkHandleRepresentation.extend(publicAPI, model, initialValues);
168
- macro.get(publicAPI, model, ['glyph', 'mapper', 'actor']); // Object specific methods
71
+ vtkGlyphRepresentation.extend(publicAPI, model, initialValues); // Object specific methods
169
72
 
170
73
  vtkSphereHandleRepresentation(publicAPI, model);
171
74
  } // ----------------------------------------------------------------------------
@@ -7,6 +7,7 @@ import vtkPolyData from '../../Common/DataModel/PolyData.js';
7
7
  import vtkSpline3D from '../../Common/DataModel/Spline3D.js';
8
8
  import vtkTriangleFilter from '../../Filters/General/TriangleFilter.js';
9
9
  import vtkLineFilter from '../../Filters/General/LineFilter.js';
10
+ import vtkWidgetRepresentation, { allocateArray } from './WidgetRepresentation.js';
10
11
 
11
12
  // vtkSplineContextRepresentation methods
12
13
  // ----------------------------------------------------------------------------
@@ -17,55 +18,71 @@ function vtkSplineContextRepresentation(publicAPI, model) {
17
18
  // Generic rendering pipeline
18
19
  // --------------------------------------------------------------------------
19
20
 
20
- model.pipelines = {
21
+ model.internalPolyData = vtkPolyData.newInstance({
22
+ mtime: 0
23
+ });
24
+ model._pipelines = {
21
25
  area: {
26
+ source: publicAPI,
27
+ filter: vtkTriangleFilter.newInstance(),
28
+ mapper: vtkMapper.newInstance(),
22
29
  actor: vtkActor.newInstance({
23
30
  parentProp: publicAPI
24
- }),
25
- mapper: vtkMapper.newInstance(),
26
- triangleFilter: vtkTriangleFilter.newInstance()
31
+ })
27
32
  },
28
33
  border: {
34
+ source: publicAPI,
35
+ filter: vtkLineFilter.newInstance(),
36
+ mapper: vtkMapper.newInstance(),
29
37
  actor: vtkActor.newInstance({
30
38
  parentProp: publicAPI
31
- }),
32
- mapper: vtkMapper.newInstance(),
33
- lineFilter: vtkLineFilter.newInstance()
39
+ })
34
40
  }
35
41
  };
36
- model.pipelines.area.triangleFilter.setInputConnection(publicAPI.getOutputPort());
37
- model.pipelines.area.mapper.setInputConnection(model.pipelines.area.triangleFilter.getOutputPort());
38
- model.pipelines.area.actor.setMapper(model.pipelines.area.mapper);
39
- model.pipelines.area.actor.getProperty().setOpacity(0.2);
40
- model.pipelines.area.actor.getProperty().setColor(0, 1, 0);
41
- publicAPI.addActor(model.pipelines.area.actor);
42
- model.pipelines.border.lineFilter.setInputConnection(publicAPI.getOutputPort());
43
- model.pipelines.border.mapper.setInputConnection(model.pipelines.border.lineFilter.getOutputPort());
44
- model.pipelines.border.actor.setMapper(model.pipelines.border.mapper);
45
- model.pipelines.border.actor.getProperty().setOpacity(1);
46
- model.pipelines.border.actor.getProperty().setColor(0.1, 1, 0.1);
47
- model.pipelines.border.actor.setVisibility(model.outputBorder);
48
- publicAPI.addActor(model.pipelines.border.actor); // --------------------------------------------------------------------------
42
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.area);
43
+
44
+ model._pipelines.area.actor.getProperty().setOpacity(0.2);
45
+
46
+ model._pipelines.area.actor.getProperty().setColor(0, 1, 0);
47
+
48
+ publicAPI.addActor(model._pipelines.area.actor);
49
+ vtkWidgetRepresentation.connectPipeline(model._pipelines.border);
50
+
51
+ model._pipelines.border.actor.getProperty().setOpacity(1);
52
+
53
+ model._pipelines.border.actor.getProperty().setColor(0.1, 1, 0.1);
54
+
55
+ model._pipelines.border.actor.setVisibility(model.outputBorder);
56
+
57
+ publicAPI.addActor(model._pipelines.border.actor); // --------------------------------------------------------------------------
58
+
59
+ var superGetRepresentationStates = publicAPI.getRepresentationStates;
60
+
61
+ publicAPI.getRepresentationStates = function () {
62
+ var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : model.inputData[0];
63
+ return superGetRepresentationStates(input).filter(function (state) {
64
+ var _state$getOrigin, _state$isVisible;
65
+
66
+ return ((_state$getOrigin = state.getOrigin) === null || _state$getOrigin === void 0 ? void 0 : _state$getOrigin.call(state)) && ((_state$isVisible = state.isVisible) === null || _state$isVisible === void 0 ? void 0 : _state$isVisible.call(state));
67
+ });
68
+ };
49
69
 
50
70
  publicAPI.requestData = function (inData, outData) {
51
- var _model$pipelines$bord;
71
+ var _model$_pipelines$bor;
52
72
 
53
73
  if (model.deleted) {
54
74
  return;
55
75
  }
56
76
 
57
- var polydata = vtkPolyData.newInstance();
58
77
  var widgetState = inData[0];
59
78
  var closed = widgetState.getSplineClosed();
60
- var list = publicAPI.getRepresentationStates(widgetState).filter(function (state) {
61
- return state.getVisible && state.getVisible() && state.getOrigin && state.getOrigin();
62
- });
79
+ var list = publicAPI.getRepresentationStates(widgetState);
63
80
  var inPoints = list.map(function (state) {
64
81
  return state.getOrigin();
65
82
  });
66
83
 
67
84
  if (inPoints.length <= 1) {
68
- outData[0] = polydata;
85
+ outData[0] = model.internalPolyData;
69
86
  return;
70
87
  }
71
88
 
@@ -87,7 +104,7 @@ function vtkSplineContextRepresentation(publicAPI, model) {
87
104
  boundaryConditionValues: widgetState.getSplineBoundaryConditionValues()
88
105
  });
89
106
  spline.computeCoefficients(inPoints);
90
- var outPoints = new Float32Array(3 * ((numVertices + !closed) * model.resolution));
107
+ var outPoints = allocateArray(model.internalPolyData, 'points', (numVertices + !closed) * model.resolution).getData();
91
108
  var outCells = new Uint32Array(numVertices * model.resolution + 2);
92
109
  outCells[0] = numVertices * model.resolution + 1;
93
110
  outCells[numVertices * model.resolution + 1] = 0;
@@ -114,17 +131,17 @@ function vtkSplineContextRepresentation(publicAPI, model) {
114
131
  outCells[numVertices * model.resolution + 1] = lastPointIndex;
115
132
  }
116
133
 
117
- polydata.getPoints().setData(outPoints);
118
-
119
134
  if (model.fill) {
120
- polydata.getPolys().setData(outCells);
135
+ model.internalPolyData.getPolys().setData(outCells);
121
136
  }
122
137
 
123
- polydata.getLines().setData(model.outputBorder ? outCells : []);
124
- outData[0] = polydata;
125
- model.pipelines.area.triangleFilter.update();
138
+ model.internalPolyData.getLines().setData(model.outputBorder ? outCells : []);
139
+ model.internalPolyData.modified();
140
+ outData[0] = model.internalPolyData;
141
+
142
+ model._pipelines.area.filter.update();
126
143
 
127
- (_model$pipelines$bord = model.pipelines.border.actor.getProperty()).setColor.apply(_model$pipelines$bord, _toConsumableArray(inPoints.length <= 3 || model.pipelines.area.triangleFilter.getErrorCount() === 0 ? model.borderColor : model.errorBorderColor));
144
+ (_model$_pipelines$bor = model._pipelines.border.actor.getProperty()).setColor.apply(_model$_pipelines$bor, _toConsumableArray(inPoints.length <= 3 || model._pipelines.area.filter.getErrorCount() === 0 ? model.borderColor : model.errorBorderColor));
128
145
  };
129
146
 
130
147
  publicAPI.getSelectedState = function (prop, compositeID) {
@@ -132,12 +149,12 @@ function vtkSplineContextRepresentation(publicAPI, model) {
132
149
  };
133
150
 
134
151
  function updateAreaVisibility() {
135
- model.pipelines.area.actor.setVisibility(model.fill);
152
+ model._pipelines.area.actor.setVisibility(model.fill);
136
153
  }
137
154
 
138
155
  publicAPI.setFill = macro.chain(publicAPI.setFill, updateAreaVisibility);
139
156
  publicAPI.setOutputBorder = macro.chain(publicAPI.setOutputBorder, function (v) {
140
- return model.pipelines.border.actor.setVisibility(v);
157
+ return model._pipelines.border.actor.setVisibility(v);
141
158
  });
142
159
  } // ----------------------------------------------------------------------------
143
160
  // Object factory
@@ -1,9 +1,19 @@
1
+ import vtkDataArray from './../../Common/Core/DataArray';
2
+ import vtkPolyData from './../../Common/DataModel/PolyData';
3
+ import { vtkObject } from './../../interfaces';
1
4
  import vtkProp from './../../Rendering/Core/Prop';
5
+ export interface IDisplayScaleParams {
6
+ dispHeightFactor: number,
7
+ cameraPosition: number[],
8
+ cameraDir: number[],
9
+ isParallel: boolean,
10
+ rendererPixelDims: number[],
11
+ }
2
12
 
3
13
  export interface IWidgetRepresentationInitialValues {
4
14
  labels?: Array<any>,
5
15
  coincidentTopologyParameters?: object,
6
- displayScaleParams?: object,
16
+ displayScaleParams?: IDisplayScaleParams,
7
17
  scaleInPixels?: boolean
8
18
  }
9
19
 
@@ -55,6 +65,47 @@ export function extend(publicAPI: object, model: object, initialValues?: IWidget
55
65
  */
56
66
  export function newInstance(initialValues?: IWidgetRepresentationInitialValues): vtkWidgetRepresentation;
57
67
 
68
+ /**
69
+ * Static function to get the pixel size of a 3D point.
70
+ * @param {Number[]} worldCoord 3D point in world coordinates
71
+ * @param {IDisplayScaleParams} displayScaleParams Display and camera information
72
+ */
73
+ export function getPixelWorldHeightAtCoord(worldCoord: number[], displayScaleParams: IDisplayScaleParams): number[];
74
+
75
+ export interface IWidgetPipeline {
76
+ source?: object,
77
+ filter?: object,
78
+ glyph?: object,
79
+ mapper: object,
80
+ actor: object
81
+ }
82
+ /**
83
+ * If provided, connects `source` (dataset or filter) to `filter`.
84
+ * If provided, connects `filter` (otherwise `source`) to mapper
85
+ * If provided, connects glyph as 2nd input to mapper. This is typically for the glyph mapper.
86
+ * Connects mapper to actor.
87
+ * @param {IWidgetPipeline} pipeline of source, filter, mapper and actor to connect
88
+ */
89
+ export function connectPipeline(pipeline: IWidgetPipeline): void;
90
+
91
+ /**
92
+ * Allocate or resize a vtkPoint(name='point'), vtkCellArray (name=
93
+ * 'line'|'poly') or vtkDataArray (name=any) and add it to the vtkPolyData.
94
+ * If allocated, the array is automatically added to the polydata
95
+ * Connects mapper to actor.
96
+ * @param {vtkPolyData} polyData The polydata to add array to
97
+ * @param {string} name The name of the array to add (special handling for
98
+ * 'point', 'line, 'poly')
99
+ * @param {Number} numberOfTuples The number of tuples to (re)allocate.
100
+ * @param {String} dataType The typed array type name.
101
+ * @param {Number} numberOfComponents The number of components of the array.
102
+ */
103
+ export function allocateArray(polyData: vtkPolyData,
104
+ name: string,
105
+ numberOfTuples: number,
106
+ dataType?: string,
107
+ numberOfComponents?: number): vtkDataArray|null;
108
+
58
109
  export declare const vtkWidgetRepresentation: {
59
110
  newInstance: typeof newInstance;
60
111
  extend: typeof extend;
@@ -1,11 +1,15 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
1
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
+ import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
3
3
  import macro from '../../macros.js';
4
4
  import vtkProp from '../../Rendering/Core/Prop.js';
5
- import { s as subtract, d as dot } from '../../Common/Core/Math/index.js';
5
+ import { g as vtkMath } from '../../Common/Core/Math/index.js';
6
+ import vtkCellArray from '../../Common/Core/CellArray.js';
7
+ import vtkDataArray from '../../Common/Core/DataArray.js';
8
+ import vtkPoints from '../../Common/Core/Points.js';
6
9
  import { Behavior } from './WidgetRepresentation/Constants.js';
7
10
  import { RenderingTypes } from '../Core/WidgetManager/Constants.js';
8
11
  import { CATEGORIES } from '../../Rendering/Core/Mapper/CoincidentTopologyHelper.js';
12
+ import { POLYDATA_FIELDS } from '../../Common/DataModel/PolyData/Constants.js';
9
13
 
10
14
  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; }
11
15
 
@@ -67,10 +71,24 @@ function applyStyles(pipelines, styles, activeActor) {
67
71
  } // ----------------------------------------------------------------------------
68
72
 
69
73
  function connectPipeline(pipeline) {
70
- if (pipeline.source.isA('vtkDataSet')) {
71
- pipeline.mapper.setInputData(pipeline.source);
72
- } else {
73
- pipeline.mapper.setInputConnection(pipeline.source.getOutputPort());
74
+ var source = pipeline.source;
75
+
76
+ if (pipeline.filter) {
77
+ if (source.isA('vtkDataSet')) {
78
+ pipeline.filter.setInputData(source);
79
+ } else {
80
+ pipeline.filter.setInputConnection(source.getOutputPort());
81
+ }
82
+
83
+ source = pipeline.filter;
84
+ }
85
+
86
+ if (source) {
87
+ if (source.isA('vtkDataSet')) {
88
+ pipeline.mapper.setInputData(source);
89
+ } else {
90
+ pipeline.mapper.setInputConnection(source.getOutputPort());
91
+ }
74
92
  }
75
93
 
76
94
  if (pipeline.glyph) {
@@ -78,16 +96,84 @@ function connectPipeline(pipeline) {
78
96
  }
79
97
 
80
98
  pipeline.actor.setMapper(pipeline.mapper);
99
+ }
100
+ function getPixelWorldHeightAtCoord(worldCoord, displayScaleParams) {
101
+ var dispHeightFactor = displayScaleParams.dispHeightFactor,
102
+ cameraPosition = displayScaleParams.cameraPosition,
103
+ cameraDir = displayScaleParams.cameraDir,
104
+ isParallel = displayScaleParams.isParallel,
105
+ rendererPixelDims = displayScaleParams.rendererPixelDims;
106
+ var scale = 1;
107
+
108
+ if (isParallel) {
109
+ scale = dispHeightFactor;
110
+ } else {
111
+ var worldCoordToCamera = _toConsumableArray(worldCoord);
112
+
113
+ vtkMath.subtract(worldCoordToCamera, cameraPosition, worldCoordToCamera);
114
+ scale = vtkMath.dot(worldCoordToCamera, cameraDir) * dispHeightFactor;
115
+ }
116
+
117
+ var rHeight = rendererPixelDims[1];
118
+ return scale / rHeight;
119
+ } // Internal convenient function to create a data array:
120
+
121
+ function allocateArray(polyData, name, numberOfTuples, dataType, numberOfComponents) {
122
+ var _polyData$;
123
+
124
+ // Check first whether name is points, verts, lines, polys, otherwise it is a point data array.
125
+ var dataArray = ((_polyData$ = polyData["get".concat(macro.capitalize(name))]) === null || _polyData$ === void 0 ? void 0 : _polyData$.call(polyData)) || polyData.getPointData().getArrayByName(name);
126
+
127
+ if (!dataArray || dataType !== undefined && dataArray.getDataType() !== dataType || numberOfComponents !== undefined && dataArray.getNumberOfComponents() !== numberOfComponents) {
128
+ var arrayType = vtkDataArray;
129
+ var arrayDataType = dataType;
130
+ var arrayNumberOfComponents = numberOfComponents;
131
+
132
+ if (name === 'points') {
133
+ var _arrayDataType;
134
+
135
+ arrayType = vtkPoints;
136
+ arrayDataType = (_arrayDataType = arrayDataType) !== null && _arrayDataType !== void 0 ? _arrayDataType : 'Float32Array';
137
+ arrayNumberOfComponents = numberOfComponents !== null && numberOfComponents !== void 0 ? numberOfComponents : 3;
138
+ } else if (POLYDATA_FIELDS.includes(name)) {
139
+ var _arrayDataType2;
140
+
141
+ arrayType = vtkCellArray;
142
+ arrayDataType = (_arrayDataType2 = arrayDataType) !== null && _arrayDataType2 !== void 0 ? _arrayDataType2 : 'Uint16Array';
143
+ arrayNumberOfComponents = numberOfComponents !== null && numberOfComponents !== void 0 ? numberOfComponents : 1;
144
+ } else {
145
+ var _arrayDataType3;
146
+
147
+ // data array
148
+ arrayDataType = (_arrayDataType3 = arrayDataType) !== null && _arrayDataType3 !== void 0 ? _arrayDataType3 : 'Float32Array';
149
+ arrayNumberOfComponents = numberOfComponents !== null && numberOfComponents !== void 0 ? numberOfComponents : 1;
150
+ }
151
+
152
+ dataArray = arrayType.newInstance({
153
+ name: name,
154
+ dataType: arrayDataType,
155
+ numberOfComponents: arrayNumberOfComponents,
156
+ size: arrayNumberOfComponents * numberOfTuples,
157
+ empty: numberOfTuples === 0
158
+ });
159
+
160
+ if (name === 'points' || POLYDATA_FIELDS.includes(name)) {
161
+ polyData["set".concat(macro.capitalize(name))](dataArray);
162
+ } else {
163
+ polyData.getPointData().addArray(dataArray);
164
+ }
165
+ } else if (dataArray.getNumberOfTuples() !== numberOfTuples) {
166
+ dataArray.resize(numberOfTuples);
167
+ }
168
+
169
+ return dataArray;
81
170
  } // ----------------------------------------------------------------------------
82
171
  // vtkWidgetRepresentation
83
172
  // ----------------------------------------------------------------------------
84
173
 
85
174
  function vtkWidgetRepresentation(publicAPI, model) {
86
175
  // Set our className
87
- model.classHierarchy.push('vtkWidgetRepresentation');
88
-
89
- var superclass = _objectSpread({}, publicAPI); // Internal cache
90
-
176
+ model.classHierarchy.push('vtkWidgetRepresentation'); // Internal cache
91
177
 
92
178
  var cache = {
93
179
  mtimes: {},
@@ -217,35 +303,10 @@ function vtkWidgetRepresentation(publicAPI, model) {
217
303
  };
218
304
 
219
305
  publicAPI.setCoincidentTopologyParameters = function (parameters) {
220
- var modified = superclass.setCoincidentTopologyParameters(parameters);
221
-
222
- if (modified) {
223
- publicAPI.getActors().forEach(function (actor) {
224
- applyCoincidentTopologyParametersToMapper(actor.getMapper(), model.coincidentTopologyParameters);
225
- });
226
- }
227
- };
228
-
229
- publicAPI.getPixelWorldHeightAtCoord = function (worldCoord) {
230
- var _model$displayScalePa = model.displayScaleParams,
231
- dispHeightFactor = _model$displayScalePa.dispHeightFactor,
232
- cameraPosition = _model$displayScalePa.cameraPosition,
233
- cameraDir = _model$displayScalePa.cameraDir,
234
- isParallel = _model$displayScalePa.isParallel,
235
- rendererPixelDims = _model$displayScalePa.rendererPixelDims;
236
- var scale = 1;
237
-
238
- if (isParallel) {
239
- scale = dispHeightFactor;
240
- } else {
241
- var worldCoordToCamera = _toConsumableArray(worldCoord);
242
-
243
- subtract(worldCoordToCamera, cameraPosition, worldCoordToCamera);
244
- scale = dot(worldCoordToCamera, cameraDir) * dispHeightFactor;
245
- }
246
-
247
- var rHeight = rendererPixelDims[1];
248
- return scale / rHeight;
306
+ model.coincidentTopologyParameters = parameters;
307
+ publicAPI.getActors().forEach(function (actor) {
308
+ applyCoincidentTopologyParametersToMapper(actor.getMapper(), model.coincidentTopologyParameters);
309
+ });
249
310
  }; // Make sure setting the labels at build time works with string/array...
250
311
 
251
312
 
@@ -255,49 +316,49 @@ function vtkWidgetRepresentation(publicAPI, model) {
255
316
  // ----------------------------------------------------------------------------
256
317
 
257
318
 
258
- var DEFAULT_VALUES = {
259
- actors: [],
260
- labels: [],
261
- behavior: Behavior.CONTEXT,
262
- coincidentTopologyParameters: {
263
- Point: {
264
- factor: -1.0,
265
- offset: -1.0
319
+ function defaultValues(initialValues) {
320
+ return _objectSpread({
321
+ activeScaleFactor: 1.2,
322
+ activeColor: 1,
323
+ useActiveColor: true,
324
+ actors: [],
325
+ labels: [],
326
+ behavior: Behavior.CONTEXT,
327
+ coincidentTopologyParameters: {
328
+ Point: {
329
+ factor: -1.0,
330
+ offset: -1.0
331
+ },
332
+ Line: {
333
+ factor: -1.0,
334
+ offset: -1.0
335
+ },
336
+ Polygon: {
337
+ factor: -1.0,
338
+ offset: -1.0
339
+ }
266
340
  },
267
- Line: {
268
- factor: -1.0,
269
- offset: -1.0
341
+ scaleInPixels: false,
342
+ displayScaleParams: {
343
+ dispHeightFactor: 1,
344
+ cameraPosition: [0, 0, 0],
345
+ cameraDir: [1, 0, 0],
346
+ isParallel: false,
347
+ rendererPixelDims: [1, 1]
270
348
  },
271
- Polygon: {
272
- factor: -1.0,
273
- offset: -1.0
274
- }
275
- },
276
- scaleInPixels: false,
277
- displayScaleParams: {
278
- dispHeightFactor: 1,
279
- cameraPosition: [0, 0, 0],
280
- cameraDir: [1, 0, 0],
281
- isParallel: false,
282
- rendererPixelDims: [1, 1]
283
- }
284
- }; // ----------------------------------------------------------------------------
349
+ _internalArrays: {}
350
+ }, initialValues);
351
+ } // ----------------------------------------------------------------------------
352
+
285
353
 
286
354
  function extend(publicAPI, model) {
287
355
  var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
288
- Object.assign(model, DEFAULT_VALUES, initialValues); // Object methods
289
-
290
- vtkProp.extend(publicAPI, model, initialValues);
356
+ // Object methods
357
+ vtkProp.extend(publicAPI, model, defaultValues(initialValues));
291
358
  macro.algo(publicAPI, model, 1, 1);
292
- macro.get(publicAPI, model, ['labels']);
293
- macro.set(publicAPI, model, [{
294
- type: 'object',
295
- name: 'displayScaleParams'
296
- }, {
297
- type: 'object',
298
- name: 'coincidentTopologyParameters'
299
- }]);
300
- macro.setGet(publicAPI, model, ['scaleInPixels']); // Object specific methods
359
+ macro.get(publicAPI, model, ['labels', 'coincidentTopologyParameters']);
360
+ macro.set(publicAPI, model, ['displayScaleParams']);
361
+ macro.setGet(publicAPI, model, ['scaleInPixels', 'activeScaleFactor', 'activeColor', 'useActiveColor']); // Object specific methods
301
362
 
302
363
  vtkWidgetRepresentation(publicAPI, model);
303
364
  } // ----------------------------------------------------------------------------
@@ -306,7 +367,8 @@ var vtkWidgetRepresentation$1 = {
306
367
  extend: extend,
307
368
  mergeStyles: mergeStyles,
308
369
  applyStyles: applyStyles,
309
- connectPipeline: connectPipeline
370
+ connectPipeline: connectPipeline,
371
+ getPixelWorldHeightAtCoord: getPixelWorldHeightAtCoord
310
372
  };
311
373
 
312
- export { applyStyles, connectPipeline, vtkWidgetRepresentation$1 as default, extend, mergeStyles };
374
+ export { allocateArray, applyStyles, connectPipeline, vtkWidgetRepresentation$1 as default, extend, getPixelWorldHeightAtCoord, mergeStyles };