@kitware/vtk.js 23.4.1 → 24.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 (145) hide show
  1. package/BREAKING_CHANGES.md +33 -0
  2. package/Common/Core/DataArray.js +4 -0
  3. package/Common/Core/Math/index.js +2 -2
  4. package/Common/Core/Math.js +1 -1
  5. package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
  6. package/Common/DataModel/ImageData.d.ts +23 -6
  7. package/Common/DataModel/ImageData.js +8 -1
  8. package/Common/DataModel/PolyData.d.ts +8 -1
  9. package/Common/DataModel/PolyData.js +5 -3
  10. package/Common/DataModel/Triangle.js +217 -2
  11. package/Common/Transform/LandmarkTransform.js +1 -1
  12. package/Filters/General/OBBTree/OBBNode.js +82 -0
  13. package/Filters/General/OBBTree/helper.js +92 -0
  14. package/Filters/General/OBBTree.js +1249 -0
  15. package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
  16. package/Filters/General.js +2 -0
  17. package/Filters/Sources/CircleSource.js +1 -1
  18. package/Filters/Sources/PointSource.js +1 -1
  19. package/Filters/Texture/TextureMapToPlane.js +1 -1
  20. package/IO/Core/DataAccessHelper.d.ts +6 -0
  21. package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
  22. package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
  23. package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
  24. package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
  25. package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
  26. package/Interaction/Style/InteractorStyleImage.js +3 -3
  27. package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
  28. package/Interaction/Style/InteractorStyleManipulator.js +42 -28
  29. package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
  30. package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
  31. package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
  32. package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
  33. package/Interaction/Widgets.js +1 -35
  34. package/Proxy/Core/View2DProxy.js +1 -1
  35. package/Rendering/Core/ColorTransferFunction.js +1 -1
  36. package/Rendering/Core/Coordinate.js +1 -1
  37. package/Rendering/Core/CubeAxesActor.js +1 -1
  38. package/Rendering/Core/Glyph3DMapper.js +1 -1
  39. package/Rendering/Core/ImageMapper.js +1 -1
  40. package/Rendering/Core/InteractorObserver.js +11 -10
  41. package/Rendering/Core/InteractorStyle.js +9 -4
  42. package/Rendering/Core/Mapper.js +1 -1
  43. package/Rendering/Core/Prop.js +6 -4
  44. package/Rendering/Core/Prop3D.js +1 -1
  45. package/Rendering/Core/RenderWindowInteractor.js +24 -17
  46. package/Rendering/Core/Renderer.js +24 -19
  47. package/Rendering/Core/ScalarBarActor.js +1 -1
  48. package/Rendering/Core/Viewport.js +1 -1
  49. package/Rendering/Core/VolumeMapper.js +1 -1
  50. package/Rendering/OpenGL/Actor.js +2 -2
  51. package/Rendering/OpenGL/Actor2D.js +2 -2
  52. package/Rendering/OpenGL/BufferObject.js +6 -5
  53. package/Rendering/OpenGL/Camera.js +3 -3
  54. package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
  55. package/Rendering/OpenGL/Framebuffer.js +13 -12
  56. package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
  57. package/Rendering/OpenGL/HardwareSelector.js +35 -25
  58. package/Rendering/OpenGL/ImageMapper.js +51 -45
  59. package/Rendering/OpenGL/ImageSlice.js +2 -2
  60. package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
  61. package/Rendering/OpenGL/PolyDataMapper.js +14 -11
  62. package/Rendering/OpenGL/PolyDataMapper2D.js +7 -6
  63. package/Rendering/OpenGL/Renderer.js +11 -7
  64. package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
  65. package/Rendering/OpenGL/ScalarBarActor.js +2 -2
  66. package/Rendering/OpenGL/ShaderCache.js +7 -5
  67. package/Rendering/OpenGL/Skybox.js +11 -9
  68. package/Rendering/OpenGL/SphereMapper.js +2 -2
  69. package/Rendering/OpenGL/StickMapper.js +2 -2
  70. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
  71. package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
  72. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
  73. package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
  74. package/Rendering/OpenGL/Texture.js +44 -31
  75. package/Rendering/OpenGL/VertexArrayObject.js +7 -7
  76. package/Rendering/OpenGL/Volume.js +3 -2
  77. package/Rendering/OpenGL/VolumeMapper.js +30 -26
  78. package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
  79. package/Rendering/SceneGraph/ViewNode.js +8 -7
  80. package/Rendering/WebGPU/Renderer.js +18 -10
  81. package/Widgets/Core/AbstractWidget.js +5 -4
  82. package/Widgets/Core/AbstractWidgetFactory.js +2 -1
  83. package/Widgets/Core/WidgetManager.js +66 -49
  84. package/Widgets/Manipulators/LineManipulator.js +1 -1
  85. package/Widgets/Representations/CircleContextRepresentation.js +1 -1
  86. package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
  87. package/Widgets/Representations/PolyLineRepresentation.js +1 -1
  88. package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
  89. package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
  90. package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
  91. package/Widgets/SVG/SVGRepresentation.js +1 -1
  92. package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
  93. package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
  94. package/Widgets/Widgets3D/EllipseWidget.js +0 -1
  95. package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
  96. package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
  97. package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
  98. package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
  99. package/Widgets/Widgets3D/LabelWidget.js +79 -0
  100. package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
  101. package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
  102. package/Widgets/Widgets3D/LineWidget.js +0 -1
  103. package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
  104. package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
  105. package/Widgets/Widgets3D/RectangleWidget.js +0 -1
  106. package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
  107. package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
  108. package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
  109. package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
  110. package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
  111. package/interfaces.d.ts +11 -0
  112. package/macros.d.ts +26 -1
  113. package/macros.js +51 -19
  114. package/package.json +1 -1
  115. package/types.d.ts +1 -0
  116. package/Interaction/Widgets/AbstractWidget.js +0 -104
  117. package/Interaction/Widgets/DistanceRepresentation.js +0 -116
  118. package/Interaction/Widgets/DistanceWidget.js +0 -77
  119. package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
  120. package/Interaction/Widgets/HandleRepresentation.js +0 -100
  121. package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
  122. package/Interaction/Widgets/HandleWidget.js +0 -194
  123. package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
  124. package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
  125. package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
  126. package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
  127. package/Interaction/Widgets/LabelRepresentation.js +0 -325
  128. package/Interaction/Widgets/LabelWidget.js +0 -65
  129. package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
  130. package/Interaction/Widgets/LineRepresentation.js +0 -498
  131. package/Interaction/Widgets/LineWidget/Constants.js +0 -11
  132. package/Interaction/Widgets/LineWidget.js +0 -296
  133. package/Interaction/Widgets/PointPlacer.js +0 -51
  134. package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
  135. package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
  136. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
  137. package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
  138. package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
  139. package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
  140. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
  141. package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
  142. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
  143. package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
  144. package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
  145. package/Interaction/Widgets/WidgetRepresentation.js +0 -121
@@ -1,146 +0,0 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
3
- import macro from '../../../macros.js';
4
- import vtkActor from '../../../Rendering/Core/Actor.js';
5
- import vtkBoundingBox from '../../../Common/DataModel/BoundingBox.js';
6
- import vtkMapper from '../../../Rendering/Core/Mapper.js';
7
- import { u as uninitializeBounds } from '../../../Common/Core/Math/index.js';
8
- import vtkProp3D from '../../../Rendering/Core/Prop3D.js';
9
- import vtkProperty from '../../../Rendering/Core/Property.js';
10
- import vtkResliceCursorPolyDataAlgorithm from './ResliceCursorPolyDataAlgorithm.js';
11
-
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
-
14
- 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; }
15
- // vtkResliceCursorActor methods
16
- // ----------------------------------------------------------------------------
17
-
18
- function vtkResliceCursorActor(publicAPI, model) {
19
- // Set our className
20
- model.classHierarchy.push('vtkResliceCursorActor');
21
-
22
- var superClass = _objectSpread({}, publicAPI);
23
-
24
- publicAPI.getActors = function () {
25
- if (model.cursorAlgorithm.getResliceCursor()) {
26
- publicAPI.updateViewProps();
27
- }
28
-
29
- return _toConsumableArray(model.cursorCenterlineActor);
30
- };
31
-
32
- publicAPI.getNestedProps = function () {
33
- return publicAPI.getActors();
34
- };
35
-
36
- publicAPI.updateViewProps = function () {
37
- if (!model.cursorAlgorithm.getResliceCursor()) {
38
- return;
39
- }
40
-
41
- model.cursorAlgorithm.update();
42
- var axisNormal = model.cursorAlgorithm.getReslicePlaneNormal();
43
- var axis1 = model.cursorAlgorithm.getPlaneAxis1();
44
- var axis2 = model.cursorAlgorithm.getPlaneAxis2();
45
- model.cursorCenterlineMapper[axis1].setInputData(model.cursorAlgorithm.getOutputData(0));
46
- model.cursorCenterlineMapper[axis2].setInputData(model.cursorAlgorithm.getOutputData(1));
47
- model.cursorCenterlineActor[axis1].setVisibility(model.visibility);
48
- model.cursorCenterlineActor[axis2].setVisibility(model.visibility);
49
- model.cursorCenterlineActor[axisNormal].setVisibility(0);
50
- };
51
-
52
- publicAPI.getBounds = function () {
53
- uninitializeBounds(model.bounds);
54
- publicAPI.updateViewProps();
55
-
56
- var boundingBox = _toConsumableArray(vtkBoundingBox.INIT_BOUNDS);
57
-
58
- var bounds = [];
59
-
60
- for (var i = 0; i < 3; i++) {
61
- if (model.cursorCenterlineActor[i].getVisibility() && model.cursorCenterlineActor[i].getUseBounds()) {
62
- bounds = model.cursorCenterlineActor[i].getBounds();
63
- vtkBoundingBox.addBounds(boundingBox, bounds[0], bounds[1], bounds[2], bounds[3], bounds[4], bounds[5]);
64
- }
65
- }
66
-
67
- model.bounds = boundingBox;
68
- return model.bounds;
69
- };
70
-
71
- publicAPI.getMTime = function () {
72
- var mTime = superClass.getMTime();
73
-
74
- if (model.cursorAlgorithm) {
75
- var time = model.cursorAlgorithm.getMTime();
76
-
77
- if (time > mTime) {
78
- mTime = time;
79
- }
80
- }
81
-
82
- return mTime;
83
- };
84
-
85
- publicAPI.getCenterlineProperty = function (i) {
86
- return model.centerlineProperty[i];
87
- };
88
-
89
- publicAPI.getCenterlineActor = function (i) {
90
- return model.cursorCenterlineActor[i];
91
- };
92
-
93
- publicAPI.setUserMatrix = function (matrix) {
94
- model.cursorCenterlineActor[0].setUserMatrix(matrix);
95
- model.cursorCenterlineActor[1].setUserMatrix(matrix);
96
- model.cursorCenterlineActor[2].setUserMatrix(matrix);
97
- superClass.setUserMatrix(matrix);
98
- }; //----------------------------------------------------------------------------
99
- // Public API methods
100
- //----------------------------------------------------------------------------
101
-
102
- } // ----------------------------------------------------------------------------
103
- // Object factory
104
- // ----------------------------------------------------------------------------
105
-
106
-
107
- var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
108
-
109
- function extend(publicAPI, model) {
110
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
111
- Object.assign(model, DEFAULT_VALUES, initialValues);
112
- vtkProp3D.extend(publicAPI, model, initialValues);
113
- model.cursorAlgorithm = vtkResliceCursorPolyDataAlgorithm.newInstance();
114
- model.cursorCenterlineMapper = [];
115
- model.cursorCenterlineActor = [];
116
- model.centerlineProperty = [];
117
-
118
- for (var i = 0; i < 3; i++) {
119
- model.cursorCenterlineMapper[i] = vtkMapper.newInstance();
120
- model.cursorCenterlineMapper[i].setScalarVisibility(false);
121
- model.cursorCenterlineMapper[i].setResolveCoincidentTopologyToPolygonOffset();
122
- model.cursorCenterlineMapper[i].setResolveCoincidentTopologyLineOffsetParameters(-1.0, -1.0);
123
- model.cursorCenterlineActor[i] = vtkActor.newInstance({
124
- parentProp: publicAPI
125
- });
126
- model.cursorCenterlineActor[i].setMapper(model.cursorCenterlineMapper[i]);
127
- model.centerlineProperty[i] = vtkProperty.newInstance();
128
- model.cursorCenterlineActor[i].setProperty(model.centerlineProperty[i]);
129
- }
130
-
131
- model.centerlineProperty[0].setColor(1, 0, 0);
132
- model.centerlineProperty[1].setColor(0, 1, 0);
133
- model.centerlineProperty[2].setColor(0, 0, 1);
134
- macro.get(publicAPI, model, ['cursorAlgorithm']); // Object methods
135
-
136
- vtkResliceCursorActor(publicAPI, model);
137
- } // ----------------------------------------------------------------------------
138
-
139
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorActor'); // ----------------------------------------------------------------------------
140
-
141
- var vtkResliceCursorActor$1 = {
142
- newInstance: newInstance,
143
- extend: extend
144
- };
145
-
146
- export { vtkResliceCursorActor$1 as default, extend, newInstance };
@@ -1,332 +0,0 @@
1
- import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
2
- import macro from '../../../macros.js';
3
- import vtkInteractorObserver from '../../../Rendering/Core/InteractorObserver.js';
4
- import vtkLine from '../../../Common/DataModel/Line.js';
5
- import { f as distance2BetweenPoints, l as normalize, d as dot, j as cross, u as uninitializeBounds } from '../../../Common/Core/Math/index.js';
6
- import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
7
- import vtkPlane from '../../../Common/DataModel/Plane.js';
8
- import vtkResliceCursorActor from './ResliceCursorActor.js';
9
- import vtkResliceCursorRepresentation from './ResliceCursorRepresentation.js';
10
- import { InteractionState } from './ResliceCursorRepresentation/Constants.js';
11
-
12
- // ResliceCursorLineRepresentation methods
13
- // ----------------------------------------------------------------------------
14
-
15
- function isAxisPicked(renderer, tolerance, axisPolyData, pickedPosition) {
16
- var points = axisPolyData.getPoints();
17
- var worldP1 = [];
18
- points.getPoint(0, worldP1);
19
- var displayP1 = vtkInteractorObserver.computeWorldToDisplay(renderer, worldP1[0], worldP1[1], worldP1[2]);
20
- var worldP2 = [];
21
- points.getPoint(points.getNumberOfPoints() - 1, worldP2);
22
- var displayP2 = vtkInteractorObserver.computeWorldToDisplay(renderer, worldP2[0], worldP2[1], worldP2[2]);
23
- var xyz = [pickedPosition[0], pickedPosition[1], 0];
24
- var p1 = [displayP1[0], displayP1[1], 0];
25
- var p2 = [displayP2[0], displayP2[1], 0];
26
- var output = vtkLine.distanceToLine(xyz, p1, p2);
27
- return output.distance <= tolerance * tolerance && output.t < 1.0 && output.t > 0.0;
28
- }
29
-
30
- function displayToWorld(displayPosition, renderer) {
31
- var activeCamera = renderer.getActiveCamera();
32
- var focalPoint = activeCamera.getFocalPoint();
33
- var displayFocalPoint = vtkInteractorObserver.computeWorldToDisplay(renderer, focalPoint[0], focalPoint[1], focalPoint[2]);
34
- var worldEventPosition = vtkInteractorObserver.computeDisplayToWorld(renderer, displayPosition[0], displayPosition[1], displayFocalPoint[2]);
35
- return worldEventPosition;
36
- }
37
-
38
- function vtkResliceCursorLineRepresentation(publicAPI, model) {
39
- // Set our className
40
- model.classHierarchy.push('vtkResliceCursorLineRepresentation'); //----------------------------------------------------------------------------
41
- // Public API methods
42
- //----------------------------------------------------------------------------
43
-
44
- publicAPI.getResliceCursor = function () {
45
- return model.resliceCursorActor.getCursorAlgorithm().getResliceCursor();
46
- };
47
-
48
- publicAPI.getCursorAlgorithm = function () {
49
- return model.resliceCursorActor.getCursorAlgorithm();
50
- };
51
-
52
- publicAPI.displayToReslicePlaneIntersection = function (displayPosition) {
53
- var activeCamera = model.renderer.getActiveCamera();
54
- var cameraPosition = activeCamera.getPosition();
55
- var resliceCursor = publicAPI.getResliceCursor();
56
- var worldEventPosition = displayToWorld(displayPosition, model.renderer);
57
-
58
- if (!resliceCursor) {
59
- return null;
60
- }
61
-
62
- var axisNormal = model.resliceCursorActor.getCursorAlgorithm().getReslicePlaneNormal();
63
- var plane = resliceCursor.getPlane(axisNormal);
64
- var intersection = vtkPlane.intersectWithLine(worldEventPosition, cameraPosition, plane.getOrigin(), plane.getNormal());
65
- return intersection.x;
66
- };
67
-
68
- publicAPI.computeInteractionState = function (displayPos) {
69
- model.interactionState = InteractionState.OUTSIDE;
70
-
71
- if (!model.renderer || !model.resliceCursorActor.getVisibility()) {
72
- return model.interactionState;
73
- }
74
-
75
- var resliceCursor = publicAPI.getResliceCursor();
76
-
77
- if (!resliceCursor) {
78
- return model.interactionState;
79
- }
80
-
81
- var axis1 = model.resliceCursorActor.getCursorAlgorithm().getAxis1();
82
- var bounds = model.resliceCursorActor.getCenterlineActor(axis1).getBounds();
83
-
84
- if (bounds[1] < bounds[0]) {
85
- return model.interactionState;
86
- } // Picking Axis1 interaction:
87
-
88
-
89
- var axis1PolyData = resliceCursor.getCenterlineAxisPolyData(axis1);
90
- var isAxis1Picked = isAxisPicked(model.renderer, model.tolerance, axis1PolyData, displayPos); // Picking Axis2 interaction:
91
-
92
- var axis2 = model.resliceCursorActor.getCursorAlgorithm().getAxis2();
93
- var axis2PolyData = resliceCursor.getCenterlineAxisPolyData(axis2);
94
- var isAxis2Picked = isAxisPicked(model.renderer, model.tolerance, axis2PolyData, displayPos); // Picking center interaction:
95
-
96
- var isCenterPicked = isAxis1Picked && isAxis2Picked;
97
-
98
- if (isCenterPicked) {
99
- var displayCenterPosition = vtkInteractorObserver.computeWorldToDisplay(model.renderer, resliceCursor.getCenter()[0], resliceCursor.getCenter()[1], resliceCursor.getCenter()[2]);
100
- var distance = distance2BetweenPoints([displayCenterPosition[0], displayCenterPosition[1], 0], [displayPos[0], displayPos[1], 0]);
101
-
102
- if (distance <= model.tolerance * model.tolerance) {
103
- model.interactionState = InteractionState.ON_CENTER;
104
- } else {
105
- model.interactionState = InteractionState.ON_AXIS1;
106
- }
107
- } else if (isAxis1Picked) {
108
- model.interactionState = InteractionState.ON_AXIS1;
109
- } else if (isAxis2Picked) {
110
- model.interactionState = InteractionState.ON_AXIS2;
111
- }
112
-
113
- model.startPickPosition = publicAPI.displayToReslicePlaneIntersection(displayPos);
114
-
115
- if (model.startPickPosition === null) {
116
- model.startPickPosition = [0, 0, 0];
117
- }
118
-
119
- return model.interactionState;
120
- };
121
-
122
- publicAPI.startComplexWidgetInteraction = function (startEventPos) {
123
- model.startEventPosition[0] = startEventPos[0];
124
- model.startEventPosition[1] = startEventPos[1];
125
- model.startEventPosition[2] = 0.0;
126
- var resliceCursor = publicAPI.getResliceCursor();
127
-
128
- if (resliceCursor) {
129
- model.startCenterPosition = resliceCursor.getCenter();
130
- }
131
-
132
- model.lastEventPosition[0] = startEventPos[0];
133
- model.lastEventPosition[1] = startEventPos[1];
134
- model.lastEventPosition[2] = 0.0;
135
- };
136
-
137
- publicAPI.complexWidgetInteraction = function (displayPosition) {
138
- var resliceCursor = publicAPI.getResliceCursor();
139
-
140
- if (model.interactionState === InteractionState.OUTSIDE || !model.renderer || !resliceCursor) {
141
- model.lastEventPosition[0] = displayPosition[0];
142
- model.lastEventPosition[1] = displayPosition[1];
143
- return;
144
- } // Depending on the state, perform different operations
145
-
146
-
147
- if (model.interactionState === InteractionState.ON_CENTER) {
148
- var intersectionPos = publicAPI.displayToReslicePlaneIntersection(displayPosition);
149
-
150
- if (intersectionPos !== null) {
151
- var newCenter = [];
152
-
153
- for (var i = 0; i < 3; i++) {
154
- newCenter[i] = model.startCenterPosition[i] + intersectionPos[i] - model.startPickPosition[i];
155
- }
156
-
157
- resliceCursor.setCenter(newCenter);
158
- }
159
- }
160
-
161
- if (model.interactionState === InteractionState.ON_AXIS1) {
162
- publicAPI.rotateAxis(displayPosition, model.resliceCursorActor.getCursorAlgorithm().getPlaneAxis1());
163
- }
164
-
165
- if (model.interactionState === InteractionState.ON_AXIS2) {
166
- publicAPI.rotateAxis(displayPosition, model.resliceCursorActor.getCursorAlgorithm().getPlaneAxis2());
167
- }
168
-
169
- model.lastEventPosition = [].concat(_toConsumableArray(displayPosition), [0]);
170
- };
171
-
172
- publicAPI.rotateAxis = function (displayPos, axis) {
173
- var resliceCursor = publicAPI.getResliceCursor();
174
-
175
- if (!resliceCursor) {
176
- return 0;
177
- }
178
-
179
- var center = resliceCursor.getCenter(); // Intersect with the viewing vector. We will use this point and the
180
- // start event point to compute the rotation angle
181
-
182
- var currentIntersectionPos = publicAPI.displayToReslicePlaneIntersection(displayPos);
183
- var lastIntersectionPos = publicAPI.displayToReslicePlaneIntersection(model.lastEventPosition);
184
-
185
- if (lastIntersectionPos[0] === currentIntersectionPos[0] && lastIntersectionPos[1] === currentIntersectionPos[1] && lastIntersectionPos[2] === currentIntersectionPos[2]) {
186
- return 0;
187
- }
188
-
189
- var lastVector = [];
190
- var currVector = [];
191
-
192
- for (var i = 0; i < 3; i++) {
193
- lastVector[i] = lastIntersectionPos[i] - center[i];
194
- currVector[i] = currentIntersectionPos[i] - center[i];
195
- }
196
-
197
- normalize(lastVector);
198
- normalize(currVector); // Compute the angle between both vectors. This is the amount to
199
- // rotate by.
200
-
201
- var angle = Math.acos(dot(lastVector, currVector));
202
- var crossVector = [];
203
- cross(lastVector, currVector, crossVector);
204
- var resliceCursorPlaneId = model.resliceCursorActor.getCursorAlgorithm().getReslicePlaneNormal();
205
- var normalPlane = resliceCursor.getPlane(resliceCursorPlaneId);
206
- var aboutAxis = normalPlane.getNormal();
207
- var align = dot(aboutAxis, crossVector);
208
- var sign = align > 0 ? 1.0 : -1.0;
209
- angle *= sign;
210
-
211
- if (angle === 0) {
212
- return 0;
213
- }
214
-
215
- publicAPI.applyRotation(axis, angle);
216
- return angle;
217
- };
218
-
219
- publicAPI.applyRotation = function (axis, angle) {
220
- var resliceCursor = publicAPI.getResliceCursor();
221
- var resliceCursorPlaneId = model.resliceCursorActor.getCursorAlgorithm().getReslicePlaneNormal();
222
- var planeToBeRotated = resliceCursor.getPlane(axis);
223
- var viewUp = resliceCursor.getViewUp(axis);
224
- var vectorToBeRotated = planeToBeRotated.getNormal();
225
- var normalPlane = resliceCursor.getPlane(resliceCursorPlaneId);
226
- var aboutAxis = normalPlane.getNormal();
227
-
228
- var rotatedVector = _toConsumableArray(vectorToBeRotated);
229
-
230
- vtkMatrixBuilder.buildFromRadian().rotate(angle, aboutAxis).apply(rotatedVector);
231
- vtkMatrixBuilder.buildFromRadian().rotate(angle, aboutAxis).apply(viewUp);
232
- planeToBeRotated.setNormal(rotatedVector);
233
- };
234
-
235
- publicAPI.getBounds = function () {
236
- var bounds = [];
237
- uninitializeBounds(bounds);
238
- var resliceCursor = publicAPI.getResliceCursor();
239
-
240
- if (resliceCursor) {
241
- if (resliceCursor.getImage()) {
242
- bounds = resliceCursor.getImage().getBounds();
243
- }
244
- }
245
-
246
- return bounds;
247
- };
248
-
249
- publicAPI.getActors = function () {
250
- // Update representation
251
- publicAPI.buildRepresentation(); // Update CameraPosition
252
-
253
- publicAPI.updateCamera();
254
- return [model.imageActor].concat(_toConsumableArray(model.resliceCursorActor.getActors()));
255
- };
256
-
257
- publicAPI.updateCamera = function () {
258
- var normalAxis = model.resliceCursorActor.getCursorAlgorithm().getReslicePlaneNormal(); // When the reslice plane is changed, update the camera to look at the
259
- // normal to the reslice plane always.
260
-
261
- var focalPoint = model.renderer.getActiveCamera().getFocalPoint();
262
- var position = model.renderer.getActiveCamera().getPosition();
263
- var normalPlane = publicAPI.getResliceCursor().getPlane(normalAxis);
264
- var normal = normalPlane.getNormal();
265
- var distance = Math.sqrt(distance2BetweenPoints(position, focalPoint));
266
- var estimatedCameraPosition = [focalPoint[0] + distance * normal[0], focalPoint[1] + distance * normal[1], focalPoint[2] + distance * normal[2]]; // intersect with the plane to get updated focal point
267
-
268
- var intersection = vtkPlane.intersectWithLine(focalPoint, estimatedCameraPosition, normalPlane.getOrigin(), normalPlane.getNormal());
269
- var newFocalPoint = intersection.x;
270
- model.renderer.getActiveCamera().setFocalPoint(newFocalPoint[0], newFocalPoint[1], newFocalPoint[2]);
271
- var newCameraPosition = [newFocalPoint[0] + distance * normal[0], newFocalPoint[1] + distance * normal[1], newFocalPoint[2] + distance * normal[2]];
272
- model.renderer.getActiveCamera().setPosition(newCameraPosition[0], newCameraPosition[1], newCameraPosition[2]); // Renderer may not have yet actor bounds
273
-
274
- var rendererBounds = model.renderer.computeVisiblePropBounds();
275
- var bounds = publicAPI.getBounds();
276
- rendererBounds[0] = Math.min(bounds[0], rendererBounds[0]);
277
- rendererBounds[1] = Math.max(bounds[1], rendererBounds[1]);
278
- rendererBounds[2] = Math.min(bounds[2], rendererBounds[2]);
279
- rendererBounds[3] = Math.max(bounds[3], rendererBounds[3]);
280
- rendererBounds[4] = Math.min(bounds[4], rendererBounds[4]);
281
- rendererBounds[5] = Math.max(bounds[5], rendererBounds[5]); // Don't clip away any part of the data.
282
-
283
- model.renderer.resetCameraClippingRange(rendererBounds);
284
- };
285
- /**
286
- * Reimplemented to look at image center instead of reslice cursor.
287
- */
288
-
289
-
290
- publicAPI.resetCamera = function () {
291
- if (model.renderer) {
292
- var normalAxis = publicAPI.getCursorAlgorithm().getReslicePlaneNormal();
293
- var normal = publicAPI.getResliceCursor().getPlane(normalAxis).getNormal();
294
- var viewUp = publicAPI.getResliceCursor().getViewUp(normalAxis);
295
- var focalPoint = model.renderer.getActiveCamera().getFocalPoint();
296
- var position = model.renderer.getActiveCamera().getPosition(); // Distance is preserved
297
-
298
- var distance = Math.sqrt(distance2BetweenPoints(position, focalPoint));
299
- var newCameraPosition = [focalPoint[0] + distance * normal[0], focalPoint[1] + distance * normal[1], focalPoint[2] + distance * normal[2]];
300
- model.renderer.getActiveCamera().setPosition(newCameraPosition[0], newCameraPosition[1], newCameraPosition[2]);
301
- model.renderer.getActiveCamera().setViewUp(viewUp[0], viewUp[1], viewUp[2]);
302
- }
303
- };
304
- } // ----------------------------------------------------------------------------
305
- // Object factory
306
- // ----------------------------------------------------------------------------
307
-
308
-
309
- var DEFAULT_VALUES = {}; // ----------------------------------------------------------------------------
310
-
311
- function extend(publicAPI, model) {
312
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
313
- Object.assign(model, DEFAULT_VALUES, initialValues);
314
- vtkResliceCursorRepresentation.extend(publicAPI, model, DEFAULT_VALUES, initialValues);
315
- model.resliceCursorActor = vtkResliceCursorActor.newInstance({
316
- parentProp: publicAPI
317
- });
318
- model.startPickPosition = null;
319
- model.startCenterPosition = null;
320
- macro.get(publicAPI, model, ['resliceCursorActor']); // Object methods
321
-
322
- vtkResliceCursorLineRepresentation(publicAPI, model);
323
- } // ----------------------------------------------------------------------------
324
-
325
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorLineRepresentation'); // ----------------------------------------------------------------------------
326
-
327
- var vtkResliceCursorLineRepresentation$1 = {
328
- newInstance: newInstance,
329
- extend: extend
330
- };
331
-
332
- export { vtkResliceCursorLineRepresentation$1 as default, extend, newInstance };
@@ -1,134 +0,0 @@
1
- import _defineProperty from '@babel/runtime/helpers/defineProperty';
2
- import macro from '../../../macros.js';
3
- import { PlaneNormal } from './ResliceCursorActor/Constants.js';
4
-
5
- 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; }
6
-
7
- 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; }
8
- // vtkResliceCursorPolyDataAlgorithm methods
9
- // ----------------------------------------------------------------------------
10
-
11
- function vtkResliceCursorPolyDataAlgorithm(publicAPI, model) {
12
- // Set our className
13
- model.classHierarchy.push('vtkResliceCursorPolyDataAlgorithm');
14
-
15
- var superClass = _objectSpread({}, publicAPI);
16
-
17
- publicAPI.setReslicePlaneNormalToXAxis = function () {
18
- publicAPI.setReslicePlaneNormal(PlaneNormal.XAxis);
19
- };
20
-
21
- publicAPI.setReslicePlaneNormalToYAxis = function () {
22
- publicAPI.setReslicePlaneNormal(PlaneNormal.YAxis);
23
- };
24
-
25
- publicAPI.setReslicePlaneNormalToZAxis = function () {
26
- publicAPI.setReslicePlaneNormal(PlaneNormal.ZAxis);
27
- };
28
-
29
- publicAPI.getCenterlineAxis1 = function () {
30
- return publicAPI.getOutputData(0);
31
- };
32
-
33
- publicAPI.getCenterlineAxis2 = function () {
34
- return publicAPI.getOutputData(1);
35
- };
36
-
37
- publicAPI.getAxis1 = function () {
38
- if (model.reslicePlaneNormal === PlaneNormal.ZAxis) {
39
- return 1;
40
- }
41
-
42
- return 2;
43
- };
44
-
45
- publicAPI.getAxis2 = function () {
46
- if (model.reslicePlaneNormal === PlaneNormal.XAxis) {
47
- return 1;
48
- }
49
-
50
- return 0;
51
- };
52
-
53
- publicAPI.getPlaneAxis1 = function () {
54
- if (model.reslicePlaneNormal === PlaneNormal.XAxis) {
55
- return 1;
56
- }
57
-
58
- return 0;
59
- };
60
-
61
- publicAPI.getPlaneAxis2 = function () {
62
- if (model.reslicePlaneNormal === PlaneNormal.ZAxis) {
63
- return 1;
64
- }
65
-
66
- return 2;
67
- };
68
-
69
- publicAPI.getOtherPlaneForAxis = function (p) {
70
- for (var i = 0; i < 3; i++) {
71
- if (i !== p && i !== model.reslicePlaneNormal) {
72
- return i;
73
- }
74
- }
75
-
76
- return -1;
77
- };
78
-
79
- publicAPI.getMTime = function () {
80
- var mTime = superClass.getMTime();
81
-
82
- if (model.resliceCursor) {
83
- var time = model.resliceCursor.getMTime();
84
-
85
- if (time > mTime) {
86
- mTime = time;
87
- }
88
- }
89
-
90
- return mTime;
91
- };
92
-
93
- publicAPI.requestData = function (inData, outData) {
94
- if (!model.resliceCursor) {
95
- return;
96
- } // Cut the reslice cursor with the plane on which we are viewing.
97
-
98
-
99
- var axis1 = publicAPI.getAxis1();
100
- outData[0] = model.resliceCursor.getCenterlineAxisPolyData(axis1);
101
- var axis2 = publicAPI.getAxis2();
102
- outData[1] = model.resliceCursor.getCenterlineAxisPolyData(axis2);
103
- }; //----------------------------------------------------------------------------
104
- // Public API methods
105
- //----------------------------------------------------------------------------
106
-
107
- } // ----------------------------------------------------------------------------
108
- // Object factory
109
- // ----------------------------------------------------------------------------
110
-
111
-
112
- var DEFAULT_VALUES = {
113
- reslicePlaneNormal: PlaneNormal.XAxis
114
- }; // ----------------------------------------------------------------------------
115
-
116
- function extend(publicAPI, model) {
117
- var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
118
- Object.assign(model, DEFAULT_VALUES, initialValues);
119
- model.resliceCursor = null;
120
- macro.obj(publicAPI, model);
121
- macro.algo(publicAPI, model, 0, 2);
122
- macro.setGet(publicAPI, model, ['reslicePlaneNormal', 'resliceCursor']); // Object methods
123
-
124
- vtkResliceCursorPolyDataAlgorithm(publicAPI, model);
125
- } // ----------------------------------------------------------------------------
126
-
127
- var newInstance = macro.newInstance(extend, 'vtkResliceCursorPolyDataAlgorithm'); // ----------------------------------------------------------------------------
128
-
129
- var vtkResliceCursorPolyDataAlgorithm$1 = {
130
- newInstance: newInstance,
131
- extend: extend
132
- };
133
-
134
- export { vtkResliceCursorPolyDataAlgorithm$1 as default, extend, newInstance };
@@ -1,16 +0,0 @@
1
- var InteractionState = {
2
- OUTSIDE: 0,
3
- NEAR_CENTER: 1,
4
- NEAR_AXIS1: 2,
5
- NEAR_AXIS2: 3,
6
- ON_CENTER: 4,
7
- ON_AXIS1: 5,
8
- ON_AXIS2: 6
9
- };
10
- var ManipulationMode = {
11
- NONE: 0,
12
- PAN_AND_ROTATE: 1,
13
- ROTATE_BOTH_AXES: 2
14
- };
15
-
16
- export { InteractionState, ManipulationMode };