@kitware/vtk.js 23.4.0 → 24.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BREAKING_CHANGES.md +33 -0
- package/Common/Core/DataArray.js +4 -0
- package/Common/Core/Math/index.js +2 -2
- package/Common/Core/Math.js +1 -1
- package/Common/DataModel/BoundingBox.js +3 -8
- package/Common/DataModel/DataSetAttributes/FieldData.js +9 -5
- package/Common/DataModel/ITKHelper.js +2 -346
- package/Common/DataModel/ImageData.d.ts +23 -6
- package/Common/DataModel/ImageData.js +8 -1
- package/Common/DataModel/PolyData.d.ts +8 -1
- package/Common/DataModel/PolyData.js +5 -3
- package/Common/DataModel/Triangle.js +217 -2
- package/Common/Transform/LandmarkTransform.js +1 -1
- package/Filters/General/OBBTree/OBBNode.js +82 -0
- package/Filters/General/OBBTree/helper.js +92 -0
- package/Filters/General/OBBTree.js +1249 -0
- package/Filters/General/WindowedSincPolyDataFilter.js +1 -1
- package/Filters/General.js +2 -0
- package/Filters/Sources/CircleSource.js +1 -1
- package/Filters/Sources/PointSource.js +1 -1
- package/Filters/Texture/TextureMapToPlane.js +1 -1
- package/Interaction/Manipulators/KeyboardCameraManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRollManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraTrackballRotateManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamManipulator.js +1 -1
- package/Interaction/Manipulators/MouseCameraUnicamRotateManipulator.js +1 -1
- package/Interaction/Style/InteractorStyleImage.js +3 -3
- package/Interaction/Style/InteractorStyleMPRSlice.js +12 -6
- package/Interaction/Style/InteractorStyleManipulator.js +42 -28
- package/Interaction/Style/InteractorStyleRemoteMouse.js +32 -14
- package/Interaction/Style/InteractorStyleTrackballCamera.js +7 -7
- package/Interaction/Widgets/OrientationMarkerWidget.js +18 -13
- package/Interaction/Widgets/PiecewiseGaussianWidget.js +1 -1
- package/Interaction/Widgets.js +1 -35
- package/Proxy/Core/View2DProxy.js +1 -1
- package/Rendering/Core/ColorTransferFunction.js +1 -1
- package/Rendering/Core/Coordinate.js +1 -1
- package/Rendering/Core/CubeAxesActor.js +1 -1
- package/Rendering/Core/Glyph3DMapper.js +1 -1
- package/Rendering/Core/ImageMapper.js +1 -1
- package/Rendering/Core/InteractorObserver.js +11 -10
- package/Rendering/Core/InteractorStyle.js +9 -4
- package/Rendering/Core/Mapper.js +1 -1
- package/Rendering/Core/Prop.js +6 -4
- package/Rendering/Core/Prop3D.js +1 -1
- package/Rendering/Core/RenderWindowInteractor.js +24 -17
- package/Rendering/Core/Renderer.js +24 -19
- package/Rendering/Core/ScalarBarActor.js +1 -1
- package/Rendering/Core/Viewport.js +1 -1
- package/Rendering/Core/VolumeMapper.js +1 -1
- package/Rendering/OpenGL/Actor.js +2 -2
- package/Rendering/OpenGL/Actor2D.js +2 -2
- package/Rendering/OpenGL/BufferObject.js +6 -5
- package/Rendering/OpenGL/Camera.js +3 -3
- package/Rendering/OpenGL/CellArrayBufferObject.js +1 -1
- package/Rendering/OpenGL/Framebuffer.js +13 -12
- package/Rendering/OpenGL/Glyph3DMapper.js +10 -8
- package/Rendering/OpenGL/HardwareSelector.js +35 -25
- package/Rendering/OpenGL/ImageMapper.js +51 -45
- package/Rendering/OpenGL/ImageSlice.js +2 -2
- package/Rendering/OpenGL/PixelSpaceCallbackMapper.js +4 -2
- package/Rendering/OpenGL/PolyDataMapper.js +14 -11
- package/Rendering/OpenGL/PolyDataMapper2D.js +17 -16
- package/Rendering/OpenGL/Renderer.js +11 -7
- package/Rendering/OpenGL/ReplacementShaderMapper.js +1 -1
- package/Rendering/OpenGL/ScalarBarActor.js +2 -2
- package/Rendering/OpenGL/ShaderCache.js +7 -5
- package/Rendering/OpenGL/Skybox.js +11 -9
- package/Rendering/OpenGL/SphereMapper.js +2 -2
- package/Rendering/OpenGL/StickMapper.js +2 -2
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D/pingpong.js +13 -12
- package/Rendering/OpenGL/SurfaceLIC/LineIntegralConvolution2D.js +11 -9
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICInterface.js +19 -12
- package/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper.js +9 -6
- package/Rendering/OpenGL/Texture.js +44 -31
- package/Rendering/OpenGL/VertexArrayObject.js +7 -7
- package/Rendering/OpenGL/Volume.js +3 -2
- package/Rendering/OpenGL/VolumeMapper.js +30 -26
- package/Rendering/OpenGL/glsl/vtkVolumeFS.glsl.js +1 -1
- package/Rendering/SceneGraph/ViewNode.js +8 -7
- package/Rendering/WebGPU/Renderer.js +18 -10
- package/Widgets/Core/AbstractWidget.js +5 -4
- package/Widgets/Core/AbstractWidgetFactory.js +2 -1
- package/Widgets/Core/WidgetManager.js +66 -49
- package/Widgets/Manipulators/LineManipulator.js +1 -1
- package/Widgets/Representations/CircleContextRepresentation.js +1 -1
- package/Widgets/Representations/ImplicitPlaneRepresentation.js +5 -5
- package/Widgets/Representations/PolyLineRepresentation.js +1 -1
- package/Widgets/Representations/ResliceCursorContextRepresentation.js +7 -7
- package/Widgets/SVG/SVGLandmarkRepresentation/Constants.js +2 -2
- package/Widgets/SVG/SVGLandmarkRepresentation.js +21 -8
- package/Widgets/SVG/SVGRepresentation.js +1 -1
- package/Widgets/Widgets3D/AngleWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/DistanceWidget/behavior.js +14 -6
- package/Widgets/Widgets3D/EllipseWidget.js +0 -1
- package/Widgets/Widgets3D/ImageCroppingWidget/behavior.js +6 -2
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +4 -2
- package/Widgets/Widgets3D/LabelWidget/behavior.js +138 -0
- package/Widgets/Widgets3D/LabelWidget/state.js +22 -0
- package/Widgets/Widgets3D/LabelWidget.js +79 -0
- package/Widgets/Widgets3D/LineWidget/behavior.js +18 -9
- package/Widgets/Widgets3D/LineWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/LineWidget.js +0 -1
- package/Widgets/Widgets3D/PaintWidget/behavior.js +5 -3
- package/Widgets/Widgets3D/PolyLineWidget/behavior.js +18 -8
- package/Widgets/Widgets3D/RectangleWidget.js +0 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/behavior.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget/helpers.js +1 -1
- package/Widgets/Widgets3D/ResliceCursorWidget.js +1 -1
- package/Widgets/Widgets3D/ShapeWidget/behavior.js +18 -11
- package/Widgets/Widgets3D/SplineWidget/behavior.js +33 -21
- package/index.d.ts +3 -4
- package/interfaces.d.ts +11 -0
- package/macros.d.ts +26 -1
- package/macros.js +51 -19
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/Interaction/Widgets/AbstractWidget.js +0 -104
- package/Interaction/Widgets/DistanceRepresentation.js +0 -116
- package/Interaction/Widgets/DistanceWidget.js +0 -77
- package/Interaction/Widgets/HandleRepresentation/Constants.js +0 -12
- package/Interaction/Widgets/HandleRepresentation.js +0 -100
- package/Interaction/Widgets/HandleWidget/Constants.js +0 -9
- package/Interaction/Widgets/HandleWidget.js +0 -194
- package/Interaction/Widgets/ImageCroppingRegionsRepresentation.js +0 -233
- package/Interaction/Widgets/ImageCroppingRegionsWidget/Constants.js +0 -16
- package/Interaction/Widgets/ImageCroppingRegionsWidget.js +0 -573
- package/Interaction/Widgets/LabelRepresentation/Constants.js +0 -17
- package/Interaction/Widgets/LabelRepresentation.js +0 -325
- package/Interaction/Widgets/LabelWidget.js +0 -65
- package/Interaction/Widgets/LineRepresentation/Constants.js +0 -21
- package/Interaction/Widgets/LineRepresentation.js +0 -498
- package/Interaction/Widgets/LineWidget/Constants.js +0 -11
- package/Interaction/Widgets/LineWidget.js +0 -296
- package/Interaction/Widgets/PointPlacer.js +0 -51
- package/Interaction/Widgets/ResliceCursor/ResliceCursor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursor.js +0 -269
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorActor.js +0 -146
- package/Interaction/Widgets/ResliceCursor/ResliceCursorLineRepresentation.js +0 -332
- package/Interaction/Widgets/ResliceCursor/ResliceCursorPolyDataAlgorithm.js +0 -134
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation/Constants.js +0 -16
- package/Interaction/Widgets/ResliceCursor/ResliceCursorRepresentation.js +0 -371
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget/Constants.js +0 -10
- package/Interaction/Widgets/ResliceCursor/ResliceCursorWidget.js +0 -157
- package/Interaction/Widgets/SphereHandleRepresentation.js +0 -370
- package/Interaction/Widgets/WidgetRepresentation.js +0 -121
- package/Widgets/Representations/SphereContextRepresentation.js +0 -131
- package/Widgets/Widgets3D/SphereWidget/behavior.js +0 -177
- package/Widgets/Widgets3D/SphereWidget/state.js +0 -45
- package/Widgets/Widgets3D/SphereWidget.d.ts +0 -50
- package/Widgets/Widgets3D/SphereWidget.js +0 -62
|
@@ -1,498 +0,0 @@
|
|
|
1
|
-
import _toConsumableArray from '@babel/runtime/helpers/toConsumableArray';
|
|
2
|
-
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
|
-
import Constants from './LineRepresentation/Constants.js';
|
|
4
|
-
import macro from '../../macros.js';
|
|
5
|
-
import vtkActor from '../../Rendering/Core/Actor.js';
|
|
6
|
-
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
7
|
-
import vtkBox from '../../Common/DataModel/Box.js';
|
|
8
|
-
import vtkLine from '../../Common/DataModel/Line.js';
|
|
9
|
-
import vtkLineSource from '../../Filters/Sources/LineSource.js';
|
|
10
|
-
import vtkMapper from '../../Rendering/Core/Mapper.js';
|
|
11
|
-
import vtkProperty from '../../Rendering/Core/Property.js';
|
|
12
|
-
import vtkSphereHandleRepresentation from './SphereHandleRepresentation.js';
|
|
13
|
-
import vtkWidgetRepresentation from './WidgetRepresentation.js';
|
|
14
|
-
import { InteractionState } from './HandleRepresentation/Constants.js';
|
|
15
|
-
|
|
16
|
-
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; }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
var State = Constants.State,
|
|
20
|
-
Restrict = Constants.Restrict; // ----------------------------------------------------------------------------
|
|
21
|
-
// vtkLineRepresentation methods
|
|
22
|
-
// ----------------------------------------------------------------------------
|
|
23
|
-
|
|
24
|
-
function vtkLineRepresentation(publicAPI, model) {
|
|
25
|
-
// Set our className
|
|
26
|
-
model.classHierarchy.push('vtkLineRepresentation');
|
|
27
|
-
|
|
28
|
-
var superClass = _objectSpread({}, publicAPI);
|
|
29
|
-
|
|
30
|
-
publicAPI.setResolution = function (res) {
|
|
31
|
-
model.lineSource.setResolution(res);
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
publicAPI.setLineVisibility = function (visibility) {
|
|
35
|
-
model.lineActor.setVisibility(visibility);
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
publicAPI.setPoint1Visibility = function (visibility) {
|
|
39
|
-
model.point1Representation.getActors()[0].setVisibility(visibility);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
publicAPI.setPoint2Visibility = function (visibility) {
|
|
43
|
-
model.point2Representation.getActors()[0].setVisibility(visibility);
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
publicAPI.getResolution = function () {
|
|
47
|
-
return model.lineSource.getResolution();
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
publicAPI.getPoint1WorldPosition = function () {
|
|
51
|
-
return model.point1Representation.getWorldPosition();
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
publicAPI.getPoint2WorldPosition = function () {
|
|
55
|
-
return model.point2Representation.getWorldPosition();
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
publicAPI.getPoint1DisplayPosition = function () {
|
|
59
|
-
return model.point1Representation.getDisplayPosition();
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
publicAPI.getPoint2DisplayPosition = function () {
|
|
63
|
-
return model.point2Representation.getDisplayPosition();
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
publicAPI.setPoint1WorldPosition = function (pos) {
|
|
67
|
-
var _model$lineSource;
|
|
68
|
-
|
|
69
|
-
model.point1Representation.setWorldPosition(pos);
|
|
70
|
-
|
|
71
|
-
(_model$lineSource = model.lineSource).setPoint1.apply(_model$lineSource, _toConsumableArray(pos));
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
publicAPI.setPoint2WorldPosition = function (pos) {
|
|
75
|
-
var _model$lineSource2;
|
|
76
|
-
|
|
77
|
-
model.point2Representation.setWorldPosition(pos);
|
|
78
|
-
|
|
79
|
-
(_model$lineSource2 = model.lineSource).setPoint2.apply(_model$lineSource2, _toConsumableArray(pos));
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
publicAPI.setPoint1DisplayPosition = function (pos) {
|
|
83
|
-
model.point1Representation.setDisplayPosition(pos);
|
|
84
|
-
var p = model.point1Representation.getWorldPosition();
|
|
85
|
-
model.point1Representation.setWorldPosition(p);
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
publicAPI.setPoint2DisplayPosition = function (pos) {
|
|
89
|
-
model.point2Representation.setDisplayPosition(pos);
|
|
90
|
-
var p = model.point2Representation.getWorldPosition();
|
|
91
|
-
model.point2Representation.setWorldPosition(p);
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
publicAPI.setRenderer = function (renderer) {
|
|
95
|
-
model.point1Representation.setRenderer(renderer);
|
|
96
|
-
model.point2Representation.setRenderer(renderer);
|
|
97
|
-
superClass.setRenderer(renderer);
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
publicAPI.startComplexWidgetInteraction = function (startEventPos) {
|
|
101
|
-
// Store the start position
|
|
102
|
-
model.startEventPosition[0] = startEventPos[0];
|
|
103
|
-
model.startEventPosition[1] = startEventPos[1];
|
|
104
|
-
model.startEventPosition[2] = 0.0;
|
|
105
|
-
model.lastEventPosition[0] = startEventPos[0];
|
|
106
|
-
model.lastEventPosition[1] = startEventPos[1];
|
|
107
|
-
model.lastEventPosition[2] = 0.0;
|
|
108
|
-
model.startP1 = model.point1Representation.getWorldPosition();
|
|
109
|
-
model.startP2 = model.point2Representation.getWorldPosition();
|
|
110
|
-
|
|
111
|
-
if (model.interactionState === State.SCALING) {
|
|
112
|
-
var dp1 = model.point1Representation.getDisplayPosition();
|
|
113
|
-
var dp2 = model.point2Representation.getDisplayPosition();
|
|
114
|
-
model.length = Math.sqrt((dp1[0] - dp2[0]) * (dp1[0] - dp2[0]) + (dp1[1] - dp2[1]) * (dp1[1] - dp2[1]));
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
publicAPI.complexWidgetInteraction = function (e) {
|
|
119
|
-
if (model.interactionState === State.ONP1) {
|
|
120
|
-
if (model.restrictFlag !== 0) {
|
|
121
|
-
var x = model.point1Representation.getWorldPosition();
|
|
122
|
-
|
|
123
|
-
for (var i = 0; i < 3; i++) {
|
|
124
|
-
x[i] = model.restrictFlag === i + 1 ? x[i] : model.startP1[i];
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
model.point1Representation.setWorldPosition(x);
|
|
128
|
-
}
|
|
129
|
-
} else if (model.interactionState === State.ONP2) {
|
|
130
|
-
if (model.restrictFlag !== 0) {
|
|
131
|
-
var _x = model.point2Representation.getWorldPosition();
|
|
132
|
-
|
|
133
|
-
for (var _i = 0; _i < 3; _i++) {
|
|
134
|
-
_x[_i] = model.restrictFlag === _i + 1 ? _x[_i] : model.startP2[_i];
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
model.point2Representation.setWorldPosition(_x);
|
|
138
|
-
}
|
|
139
|
-
} else if (model.interactionState === State.ONLINE) ; else if (model.interactionState === State.SCALING) ; else if (model.interactionState === State.TRANSLATINGP1) {
|
|
140
|
-
var _x2 = model.point1Representation.getWorldPosition();
|
|
141
|
-
|
|
142
|
-
var p2 = [];
|
|
143
|
-
|
|
144
|
-
for (var _i2 = 0; _i2 < 3; _i2++) {
|
|
145
|
-
p2[_i2] = model.startP2[_i2] + (_x2[_i2] - model.startP1[_i2]);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
model.point1Representation.setWorldPosition(p2);
|
|
149
|
-
} else if (model.interactionState === State.TRANSLATINGP2) {
|
|
150
|
-
var _x3 = model.point2Representation.getWorldPosition();
|
|
151
|
-
|
|
152
|
-
var _p = [];
|
|
153
|
-
|
|
154
|
-
for (var _i3 = 0; _i3 < 3; _i3++) {
|
|
155
|
-
_p[_i3] = model.startP1[_i3] + (_x3[_i3] - model.startP2[_i3]);
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
model.point2Representation.setWorldPosition(_p);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
model.lastEventPosition[0] = e[0];
|
|
162
|
-
model.lastEventPosition[1] = e[1];
|
|
163
|
-
model.lastEventPosition[2] = 0.0;
|
|
164
|
-
publicAPI.modified();
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
publicAPI.placeWidget = function () {
|
|
168
|
-
var boundsArray = [];
|
|
169
|
-
|
|
170
|
-
if (Array.isArray(arguments.length <= 0 ? undefined : arguments[0])) {
|
|
171
|
-
boundsArray = arguments.length <= 0 ? undefined : arguments[0];
|
|
172
|
-
} else {
|
|
173
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
174
|
-
boundsArray.push(i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
if (boundsArray.length !== 6) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
var placeFactorTemp = model.placeFactor;
|
|
183
|
-
model.placeFactor = 1.0;
|
|
184
|
-
var newBounds = [];
|
|
185
|
-
var center = [];
|
|
186
|
-
publicAPI.adjustBounds(boundsArray, newBounds, center);
|
|
187
|
-
model.placeFactor = placeFactorTemp;
|
|
188
|
-
|
|
189
|
-
for (var _i4 = 0; _i4 < 6; _i4++) {
|
|
190
|
-
model.initialBounds[_i4] = newBounds[_i4];
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
model.initialLength = Math.sqrt((newBounds[1] - newBounds[0]) * (newBounds[1] - newBounds[0]) + (newBounds[3] - newBounds[2]) * (newBounds[3] - newBounds[2]) + (newBounds[5] - newBounds[4]) * (newBounds[5] - newBounds[4])); // When PlaceWidget() is invoked, the widget orientation is preserved, but it
|
|
194
|
-
// is allowed to translate and scale. This means it is centered in the
|
|
195
|
-
// bounding box, and the representation scales itself to intersect the sides
|
|
196
|
-
// of the bounding box. Thus we have to determine where Point1 and Point2
|
|
197
|
-
// intersect the bounding box.
|
|
198
|
-
|
|
199
|
-
var p1 = model.lineSource.getPoint1();
|
|
200
|
-
var p2 = model.lineSource.getPoint2();
|
|
201
|
-
var r = [model.initialLength * (p1[0] - p2[0]), model.initialLength * (p1[1] - p2[1]), model.initialLength * (p1[2] - p2[2])];
|
|
202
|
-
var o = [center[0] - r[0], center[1] - r[1], center[2] - r[2]];
|
|
203
|
-
var placedP1 = [];
|
|
204
|
-
var t = [];
|
|
205
|
-
vtkBoundingBox.intersectBox(boundsArray, o, r, placedP1, t);
|
|
206
|
-
publicAPI.setPoint1WorldPosition(placedP1);
|
|
207
|
-
r[0] = model.initialLength * (p2[0] - p1[0]);
|
|
208
|
-
r[1] = model.initialLength * (p2[1] - p1[1]);
|
|
209
|
-
r[2] = model.initialLength * (p2[2] - p1[2]);
|
|
210
|
-
o[0] = center[0] - r[0];
|
|
211
|
-
o[1] = center[1] - r[1];
|
|
212
|
-
o[2] = center[2] - r[2];
|
|
213
|
-
var placedP2 = [];
|
|
214
|
-
vtkBoundingBox.intersectBox(boundsArray, o, r, placedP2, t);
|
|
215
|
-
publicAPI.setPoint2WorldPosition(placedP2);
|
|
216
|
-
model.placed = 1;
|
|
217
|
-
model.validPick = 1;
|
|
218
|
-
publicAPI.buildRepresentation();
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
publicAPI.computeInteractionState = function (pos) {
|
|
222
|
-
var p1State = model.point1Representation.computeInteractionState(pos);
|
|
223
|
-
var p2State = model.point2Representation.computeInteractionState(pos);
|
|
224
|
-
|
|
225
|
-
if (p1State === InteractionState.SELECTING) {
|
|
226
|
-
model.interactionState = State.ONP1;
|
|
227
|
-
publicAPI.setRepresentationState(State.ONP1);
|
|
228
|
-
} else if (p2State === InteractionState.SELECTING) {
|
|
229
|
-
model.interactionState = State.ONP2;
|
|
230
|
-
publicAPI.setRepresentationState(State.ONP2);
|
|
231
|
-
} else {
|
|
232
|
-
model.interactionState = State.OUTSIDE;
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (model.interactionState !== State.OUTSIDE) {
|
|
236
|
-
return model.interactionState;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
var pos1 = publicAPI.getPoint1DisplayPosition();
|
|
240
|
-
var pos2 = publicAPI.getPoint2DisplayPosition();
|
|
241
|
-
var xyz = [pos[0], pos[1], 0.0];
|
|
242
|
-
var p1 = [pos1[0], pos1[1], 0.0];
|
|
243
|
-
var p2 = [pos2[0], pos2[1], 0.0];
|
|
244
|
-
var tol = model.tolerance * model.tolerance;
|
|
245
|
-
var out = vtkLine.distanceToLine(xyz, p1, p2);
|
|
246
|
-
var onLine = out.distance <= tol;
|
|
247
|
-
|
|
248
|
-
if (onLine && out.t < 1.0 && out.t > 0.0) {
|
|
249
|
-
model.interactionState = State.ONLINE;
|
|
250
|
-
publicAPI.setRepresentationState(State.ONLINE);
|
|
251
|
-
pos1 = publicAPI.getPoint1WorldPosition();
|
|
252
|
-
pos2 = publicAPI.getPoint2WorldPosition(); // TODO
|
|
253
|
-
// model.linePicker.pick(pos[0], pos[1], 0.0, model.renderer);
|
|
254
|
-
// const closest = model.linePicker.getPickPosition();
|
|
255
|
-
// model.lineHandleRepresentation.setWorldPosition(closest);
|
|
256
|
-
} else {
|
|
257
|
-
model.interactionState = State.OUTSIDE;
|
|
258
|
-
publicAPI.setRepresentationState(State.OUTSIDE);
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
return model.interactionState;
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
publicAPI.setRepresentationState = function (state) {
|
|
265
|
-
if (model.representationState === state) {
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
model.representationState = state;
|
|
270
|
-
publicAPI.modified();
|
|
271
|
-
|
|
272
|
-
if (state === State.OUTSIDE) {
|
|
273
|
-
publicAPI.highlightPoint(0, 0);
|
|
274
|
-
publicAPI.highlightPoint(1, 0);
|
|
275
|
-
publicAPI.highlightLine(0);
|
|
276
|
-
} else if (state === State.ONP1) {
|
|
277
|
-
publicAPI.highlightPoint(0, 1);
|
|
278
|
-
publicAPI.highlightPoint(1, 0);
|
|
279
|
-
publicAPI.highlightLine(0);
|
|
280
|
-
} else if (state === State.ONP2) {
|
|
281
|
-
publicAPI.highlightPoint(0, 0);
|
|
282
|
-
publicAPI.highlightPoint(1, 1);
|
|
283
|
-
publicAPI.highlightLine(0);
|
|
284
|
-
} else if (state === State.ONLINE) {
|
|
285
|
-
publicAPI.highlightPoint(0, 0);
|
|
286
|
-
publicAPI.highlightPoint(1, 0);
|
|
287
|
-
publicAPI.highlightLine(1);
|
|
288
|
-
} else {
|
|
289
|
-
publicAPI.highlightPoint(0, 1);
|
|
290
|
-
publicAPI.highlightPoint(1, 1);
|
|
291
|
-
publicAPI.highlightLine(1);
|
|
292
|
-
}
|
|
293
|
-
};
|
|
294
|
-
|
|
295
|
-
publicAPI.sizeHandles = function () {// Removed because radius is always close to 0
|
|
296
|
-
// let radius = publicAPI.sizeHandlesInPixels(1.35, model.lineSource.getPoint1());
|
|
297
|
-
// model.point1Representation.setHandleSize(radius);
|
|
298
|
-
// radius = publicAPI.sizeHandlesInPixels(1.35, model.lineSource.getPoint2());
|
|
299
|
-
// model.point2Representation.setHandleSize(radius);
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
publicAPI.buildRepresentation = function () {
|
|
303
|
-
var _model$lineSource3, _model$lineSource4;
|
|
304
|
-
|
|
305
|
-
model.point1Representation.buildRepresentation();
|
|
306
|
-
model.point2Representation.buildRepresentation();
|
|
307
|
-
|
|
308
|
-
if (model.initializeDisplayPosition === 0 && model.renderer) {
|
|
309
|
-
publicAPI.setPoint1WorldPosition(model.lineSource.getPoint1());
|
|
310
|
-
publicAPI.setPoint2WorldPosition(model.lineSource.getPoint2());
|
|
311
|
-
model.validPick = 1;
|
|
312
|
-
model.initializeDisplayPosition = 1;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
model.point1Representation.setTolerance(model.tolerance);
|
|
316
|
-
model.point2Representation.setTolerance(model.tolerance); // TODO
|
|
317
|
-
// model.lineHandleRepresentation.setTolerance(model.tolerance);
|
|
318
|
-
|
|
319
|
-
var x1 = publicAPI.getPoint1WorldPosition();
|
|
320
|
-
|
|
321
|
-
(_model$lineSource3 = model.lineSource).setPoint1.apply(_model$lineSource3, _toConsumableArray(x1));
|
|
322
|
-
|
|
323
|
-
model.point1Representation.setWorldPosition(x1);
|
|
324
|
-
var x2 = publicAPI.getPoint2WorldPosition();
|
|
325
|
-
|
|
326
|
-
(_model$lineSource4 = model.lineSource).setPoint2.apply(_model$lineSource4, _toConsumableArray(x2));
|
|
327
|
-
|
|
328
|
-
model.point2Representation.setWorldPosition(x2);
|
|
329
|
-
publicAPI.sizeHandles();
|
|
330
|
-
publicAPI.modified();
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
publicAPI.highlightPoint = function (pointId, highlight) {
|
|
334
|
-
if (pointId === 0) {
|
|
335
|
-
if (highlight) {
|
|
336
|
-
model.point1Representation.applyProperty(model.selectedEndPointProperty);
|
|
337
|
-
} else {
|
|
338
|
-
model.point1Representation.applyProperty(model.endPointProperty);
|
|
339
|
-
}
|
|
340
|
-
} else if (pointId === 1) {
|
|
341
|
-
if (highlight) {
|
|
342
|
-
model.point2Representation.applyProperty(model.selectedEndPoint2Property);
|
|
343
|
-
} else {
|
|
344
|
-
model.point2Representation.applyProperty(model.endPoint2Property);
|
|
345
|
-
}
|
|
346
|
-
} else ;
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
publicAPI.highlightLine = function (highlight) {
|
|
350
|
-
if (highlight) {
|
|
351
|
-
model.lineActor.setProperty(model.selectedLineProperty);
|
|
352
|
-
} else {
|
|
353
|
-
model.lineActor.setProperty(model.lineProperty);
|
|
354
|
-
}
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
publicAPI.setLineColor = function () {
|
|
358
|
-
var col = [];
|
|
359
|
-
|
|
360
|
-
if (Array.isArray(arguments.length <= 0 ? undefined : arguments[0])) {
|
|
361
|
-
col = arguments.length <= 0 ? undefined : arguments[0];
|
|
362
|
-
} else {
|
|
363
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
364
|
-
col.push(i < 0 || arguments.length <= i ? undefined : arguments[i]);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
if (col.length !== 3) {
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
if (model.lineActor.getProperty()) {
|
|
373
|
-
model.lineActor.getProperty().setColor(col[0], col[1], col[2]);
|
|
374
|
-
}
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
publicAPI.clampPosition = function (x) {
|
|
378
|
-
for (var i = 0; i < 3; i++) {
|
|
379
|
-
if (x[i] < model.initialBounds[2 * i]) {
|
|
380
|
-
x[i] = model.initialBounds[2 * i];
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
if (x[i] > model.initialBounds[2 * i + 1]) {
|
|
384
|
-
x[i] = model.initialBounds[2 * i + 1];
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
|
|
389
|
-
publicAPI.getBounds = function () {
|
|
390
|
-
model.boundingBox.setBounds(model.lineActor.getBounds());
|
|
391
|
-
model.boundingBox.addBounds(model.point1Representation.getBounds());
|
|
392
|
-
model.boundingBox.addBounds(model.point2Representation.getBounds());
|
|
393
|
-
return model.boundingBox.getBounds();
|
|
394
|
-
};
|
|
395
|
-
|
|
396
|
-
publicAPI.getActors = function () {
|
|
397
|
-
var actors = [];
|
|
398
|
-
actors.push.apply(actors, _toConsumableArray(model.point1Representation.getActors()));
|
|
399
|
-
actors.push.apply(actors, _toConsumableArray(model.point2Representation.getActors()));
|
|
400
|
-
actors.push(model.lineActor);
|
|
401
|
-
return actors;
|
|
402
|
-
};
|
|
403
|
-
|
|
404
|
-
publicAPI.getNestedProps = function () {
|
|
405
|
-
return publicAPI.getActors();
|
|
406
|
-
};
|
|
407
|
-
} // ----------------------------------------------------------------------------
|
|
408
|
-
// Object factory
|
|
409
|
-
// ----------------------------------------------------------------------------
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
var DEFAULT_VALUES = {
|
|
413
|
-
point1Representation: null,
|
|
414
|
-
point2Representation: null,
|
|
415
|
-
lineSource: null,
|
|
416
|
-
lineMapper: null,
|
|
417
|
-
lineActor: null,
|
|
418
|
-
endPointProperty: null,
|
|
419
|
-
selectedEndPointProperty: null,
|
|
420
|
-
endPoint2Property: null,
|
|
421
|
-
selectedEndPoint2Property: null,
|
|
422
|
-
lineProperty: null,
|
|
423
|
-
selectedLineProperty: null,
|
|
424
|
-
tolerance: 5,
|
|
425
|
-
placed: 0,
|
|
426
|
-
representationState: State.OUTSIDE,
|
|
427
|
-
startP1: [0.0, 0.0, 0.0],
|
|
428
|
-
startP2: [0.0, 0.0, 0.0],
|
|
429
|
-
length: 0.0,
|
|
430
|
-
restrictFlag: Restrict.NONE,
|
|
431
|
-
initializeDisplayPosition: 0,
|
|
432
|
-
boundingBox: null
|
|
433
|
-
}; // ----------------------------------------------------------------------------
|
|
434
|
-
|
|
435
|
-
function extend(publicAPI, model) {
|
|
436
|
-
var initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
437
|
-
Object.assign(model, DEFAULT_VALUES, initialValues); // Inheritance
|
|
438
|
-
|
|
439
|
-
vtkWidgetRepresentation.extend(publicAPI, model, initialValues); // Getters/Setters
|
|
440
|
-
|
|
441
|
-
macro.get(publicAPI, model, ['point1Representation', 'point2Representation', 'endPointProperty', 'selectedEndPointProperty', 'endPoint2Property', 'selectedEndPoint2Property', 'lineProperty', 'selectedLineProperty']);
|
|
442
|
-
publicAPI.setHandleSize(5);
|
|
443
|
-
model.boundingBox = vtkBox.newInstance();
|
|
444
|
-
model.point1Representation = vtkSphereHandleRepresentation.newInstance();
|
|
445
|
-
model.point2Representation = vtkSphereHandleRepresentation.newInstance();
|
|
446
|
-
var handleSize = 10;
|
|
447
|
-
model.point1Representation.setHandleSize(handleSize);
|
|
448
|
-
model.point2Representation.setHandleSize(handleSize); // model.point1Representation.setSphereRadius(0.01);
|
|
449
|
-
// model.point2Representation.setSphereRadius(0.01);
|
|
450
|
-
// Line
|
|
451
|
-
|
|
452
|
-
model.lineSource = vtkLineSource.newInstance({
|
|
453
|
-
point1: [-0.5, 0, 0],
|
|
454
|
-
point2: [0.5, 0, 0],
|
|
455
|
-
resolution: 5
|
|
456
|
-
});
|
|
457
|
-
model.lineSource.setResolution(5);
|
|
458
|
-
model.lineMapper = vtkMapper.newInstance();
|
|
459
|
-
model.lineMapper.setInputConnection(model.lineSource.getOutputPort());
|
|
460
|
-
model.lineActor = vtkActor.newInstance({
|
|
461
|
-
parentProp: publicAPI
|
|
462
|
-
});
|
|
463
|
-
model.lineActor.setMapper(model.lineMapper); // Default properties
|
|
464
|
-
|
|
465
|
-
model.endPointProperty = vtkProperty.newInstance();
|
|
466
|
-
model.endPointProperty.setColor(1, 1, 1);
|
|
467
|
-
model.selectedEndPointProperty = vtkProperty.newInstance();
|
|
468
|
-
model.selectedEndPointProperty.setColor(0, 1, 0);
|
|
469
|
-
model.endPoint2Property = vtkProperty.newInstance();
|
|
470
|
-
model.endPoint2Property.setColor(1, 1, 1);
|
|
471
|
-
model.selectedEndPoint2Property = vtkProperty.newInstance();
|
|
472
|
-
model.selectedEndPoint2Property.setColor(0, 1, 0);
|
|
473
|
-
model.lineProperty = vtkProperty.newInstance();
|
|
474
|
-
model.lineProperty.setAmbient(1.0);
|
|
475
|
-
model.lineProperty.setAmbientColor(1.0, 1.0, 1.0);
|
|
476
|
-
model.lineProperty.setLineWidth(2.0);
|
|
477
|
-
model.selectedLineProperty = vtkProperty.newInstance();
|
|
478
|
-
model.selectedLineProperty.setAmbient(1.0);
|
|
479
|
-
model.selectedLineProperty.setColor(0.0, 1.0, 0.0);
|
|
480
|
-
model.selectedLineProperty.setLineWidth(2.0); // Pass the initial properties to the actor
|
|
481
|
-
|
|
482
|
-
model.point1Representation.applyProperty(model.endPointProperty);
|
|
483
|
-
model.point2Representation.applyProperty(model.endPoint2Property);
|
|
484
|
-
model.point1Representation.setWorldPosition(model.lineSource.getPoint1());
|
|
485
|
-
model.point2Representation.setWorldPosition(model.lineSource.getPoint2());
|
|
486
|
-
model.lineActor.setProperty(model.lineProperty); // Object methods
|
|
487
|
-
|
|
488
|
-
vtkLineRepresentation(publicAPI, model);
|
|
489
|
-
} // ----------------------------------------------------------------------------
|
|
490
|
-
|
|
491
|
-
var newInstance = macro.newInstance(extend, 'vtkLineRepresentation'); // ----------------------------------------------------------------------------
|
|
492
|
-
|
|
493
|
-
var vtkLineRepresentation$1 = {
|
|
494
|
-
newInstance: newInstance,
|
|
495
|
-
extend: extend
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
export { vtkLineRepresentation$1 as default, extend, newInstance };
|