@kitware/vtk.js 34.11.2 → 34.12.0
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/Common/DataModel/BoundingBox.js +8 -8
- package/Filters/Sources/TorusSource.js +107 -0
- package/Filters/Sources.js +3 -1
- package/Interaction/Style/InteractorStyleMPRSlice.js +15 -23
- package/Interaction/Style/InteractorStyleManipulator.js +1 -0
- package/Proxy/Representations/GlyphRepresentationProxy.js +1 -0
- package/Rendering/Core/Prop3D.js +16 -0
- package/Widgets/Manipulators/PlaneManipulator.js +2 -2
- package/Widgets/Manipulators.js +2 -2
- package/Widgets/Representations/RotateTransformHandleRepresentation.js +46 -0
- package/Widgets/Representations/ScaleTransformHandleRepresentation.js +57 -0
- package/Widgets/Representations/TranslateTransformHandleRepresentation/TransformHandleSource.js +85 -0
- package/Widgets/Representations/TranslateTransformHandleRepresentation.js +57 -0
- package/Widgets/Representations.js +6 -0
- package/Widgets/Widgets3D/AngleWidget.js +2 -2
- package/Widgets/Widgets3D/EllipseWidget.js +2 -2
- package/Widgets/Widgets3D/ImageCroppingWidget.js +3 -3
- package/Widgets/Widgets3D/ImplicitPlaneWidget.js +2 -2
- package/Widgets/Widgets3D/LabelWidget.js +2 -2
- package/Widgets/Widgets3D/LineWidget.js +2 -2
- package/Widgets/Widgets3D/PaintWidget.js +2 -2
- package/Widgets/Widgets3D/PolyLineWidget.js +2 -2
- package/Widgets/Widgets3D/RectangleWidget.js +2 -2
- package/Widgets/Widgets3D/ResliceCursorWidget.js +2 -2
- package/Widgets/Widgets3D/SphereWidget.js +2 -2
- package/Widgets/Widgets3D/SplineWidget.js +2 -2
- package/Widgets/Widgets3D/TransformControlsWidget/behavior.js +180 -0
- package/Widgets/Widgets3D/TransformControlsWidget/constants.js +15 -0
- package/Widgets/Widgets3D/TransformControlsWidget/state.js +157 -0
- package/Widgets/Widgets3D/TransformControlsWidget.js +147 -0
- package/Widgets/Widgets3D.js +3 -1
- package/package.json +4 -4
|
@@ -234,14 +234,14 @@ function oppositeSign(a, b) {
|
|
|
234
234
|
return a <= 0 && b >= 0 || a >= 0 && b <= 0;
|
|
235
235
|
}
|
|
236
236
|
function getCorners(bounds, corners) {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
corners[0] = [bounds[0], bounds[2], bounds[4]];
|
|
238
|
+
corners[1] = [bounds[0], bounds[2], bounds[5]];
|
|
239
|
+
corners[2] = [bounds[0], bounds[3], bounds[4]];
|
|
240
|
+
corners[3] = [bounds[0], bounds[3], bounds[5]];
|
|
241
|
+
corners[4] = [bounds[1], bounds[2], bounds[4]];
|
|
242
|
+
corners[5] = [bounds[1], bounds[2], bounds[5]];
|
|
243
|
+
corners[6] = [bounds[1], bounds[3], bounds[4]];
|
|
244
|
+
corners[7] = [bounds[1], bounds[3], bounds[5]];
|
|
245
245
|
return corners;
|
|
246
246
|
}
|
|
247
247
|
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkPolyData from '../../Common/DataModel/PolyData.js';
|
|
3
|
+
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
4
|
+
|
|
5
|
+
// ----------------------------------------------------------------------------
|
|
6
|
+
// vtkTorusSource methods
|
|
7
|
+
// Adapted from three.js TorusGeometry
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
const TAU = Math.PI * 2;
|
|
11
|
+
function vtkTorusSource(publicAPI, model) {
|
|
12
|
+
// Set our className
|
|
13
|
+
model.classHierarchy.push('vtkTorusSource');
|
|
14
|
+
function requestData(inData, outData) {
|
|
15
|
+
let dataset = outData[0];
|
|
16
|
+
|
|
17
|
+
// Points
|
|
18
|
+
const points = macro.newTypedArray(model.pointType, 3 * (model.resolution + 1) * (model.tubeResolution + 1));
|
|
19
|
+
let pointIdx = 0;
|
|
20
|
+
for (let ti = 0; ti <= model.tubeResolution; ti++) {
|
|
21
|
+
const v = ti / model.tubeResolution * TAU;
|
|
22
|
+
const cosV = Math.cos(v);
|
|
23
|
+
const sinV = Math.sin(v);
|
|
24
|
+
for (let ri = 0; ri <= model.resolution; ri++) {
|
|
25
|
+
const u = ri / model.resolution * model.arcLength;
|
|
26
|
+
points[pointIdx++] = (model.radius + model.tubeRadius * cosV) * Math.cos(u);
|
|
27
|
+
points[pointIdx++] = (model.radius + model.tubeRadius * cosV) * Math.sin(u);
|
|
28
|
+
points[pointIdx++] = model.tubeRadius * sinV;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Cells
|
|
33
|
+
const cellArraySize = 4 * 2 * (model.resolution * model.tubeResolution);
|
|
34
|
+
let cellLocation = 0;
|
|
35
|
+
const polys = new Uint32Array(cellArraySize);
|
|
36
|
+
for (let ti = 1; ti <= model.tubeResolution; ti++) {
|
|
37
|
+
for (let ri = 1; ri <= model.resolution; ri++) {
|
|
38
|
+
const a = (model.resolution + 1) * ti + ri - 1;
|
|
39
|
+
const b = (model.resolution + 1) * (ti - 1) + ri - 1;
|
|
40
|
+
const c = (model.resolution + 1) * (ti - 1) + ri;
|
|
41
|
+
const d = (model.resolution + 1) * ti + ri;
|
|
42
|
+
polys[cellLocation++] = 3;
|
|
43
|
+
polys[cellLocation++] = a;
|
|
44
|
+
polys[cellLocation++] = b;
|
|
45
|
+
polys[cellLocation++] = d;
|
|
46
|
+
polys[cellLocation++] = 3;
|
|
47
|
+
polys[cellLocation++] = b;
|
|
48
|
+
polys[cellLocation++] = c;
|
|
49
|
+
polys[cellLocation++] = d;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Apply transformation to the points coordinates
|
|
54
|
+
vtkMatrixBuilder.buildFromRadian().translate(...model.center).rotateFromDirections([1, 0, 0], model.direction).apply(points);
|
|
55
|
+
dataset = vtkPolyData.newInstance();
|
|
56
|
+
dataset.getPoints().setData(points, 3);
|
|
57
|
+
dataset.getPolys().setData(polys, 1);
|
|
58
|
+
|
|
59
|
+
// Update output
|
|
60
|
+
outData[0] = dataset;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Expose methods
|
|
64
|
+
publicAPI.requestData = requestData;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------------------------------------------
|
|
68
|
+
// Object factory
|
|
69
|
+
// ----------------------------------------------------------------------------
|
|
70
|
+
|
|
71
|
+
const DEFAULT_VALUES = {
|
|
72
|
+
radius: 0.5,
|
|
73
|
+
tubeRadius: 0.01,
|
|
74
|
+
resolution: 64,
|
|
75
|
+
tubeResolution: 64,
|
|
76
|
+
arcLength: TAU,
|
|
77
|
+
center: [0, 0, 0],
|
|
78
|
+
direction: [1.0, 0.0, 0.0],
|
|
79
|
+
pointType: 'Float64Array'
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
function extend(publicAPI, model) {
|
|
85
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
86
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
87
|
+
|
|
88
|
+
// Build VTK API
|
|
89
|
+
macro.obj(publicAPI, model);
|
|
90
|
+
macro.setGet(publicAPI, model, ['radius', 'tubeRadius', 'resolution', 'tubeResolution', 'arcLength']);
|
|
91
|
+
macro.setGetArray(publicAPI, model, ['center', 'direction'], 3);
|
|
92
|
+
macro.algo(publicAPI, model, 0, 1);
|
|
93
|
+
vtkTorusSource(publicAPI, model);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ----------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
const newInstance = macro.newInstance(extend, 'vtkTorusSource');
|
|
99
|
+
|
|
100
|
+
// ----------------------------------------------------------------------------
|
|
101
|
+
|
|
102
|
+
var vtkTorusSource$1 = {
|
|
103
|
+
newInstance,
|
|
104
|
+
extend
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
export { vtkTorusSource$1 as default, extend, newInstance };
|
package/Filters/Sources.js
CHANGED
|
@@ -16,6 +16,7 @@ import vtkPointSource from './Sources/PointSource.js';
|
|
|
16
16
|
import vtkRTAnalyticSource from './Sources/RTAnalyticSource.js';
|
|
17
17
|
import vtkSLICSource from './Sources/SLICSource.js';
|
|
18
18
|
import vtkSphereSource from './Sources/SphereSource.js';
|
|
19
|
+
import vtkTorusSource from './Sources/TorusSource.js';
|
|
19
20
|
|
|
20
21
|
var Sources = {
|
|
21
22
|
vtkArcSource,
|
|
@@ -35,7 +36,8 @@ var Sources = {
|
|
|
35
36
|
vtkPointSource,
|
|
36
37
|
vtkRTAnalyticSource,
|
|
37
38
|
vtkSLICSource,
|
|
38
|
-
vtkSphereSource
|
|
39
|
+
vtkSphereSource,
|
|
40
|
+
vtkTorusSource
|
|
39
41
|
};
|
|
40
42
|
|
|
41
43
|
export { Sources as default };
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
|
-
import { l as normalize, e as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
2
|
+
import { l as normalize, E as areEquals, e as distance2BetweenPoints } from '../../Common/Core/Math/index.js';
|
|
3
3
|
import vtkMatrixBuilder from '../../Common/Core/MatrixBuilder.js';
|
|
4
|
+
import vtkBoundingBox from '../../Common/DataModel/BoundingBox.js';
|
|
4
5
|
import vtkInteractorStyleManipulator from './InteractorStyleManipulator.js';
|
|
5
6
|
import vtkMouseCameraTrackballRotateManipulator from '../Manipulators/MouseCameraTrackballRotateManipulator.js';
|
|
6
7
|
import vtkMouseCameraTrackballPanManipulator from '../Manipulators/MouseCameraTrackballPanManipulator.js';
|
|
7
8
|
import vtkMouseCameraTrackballZoomManipulator from '../Manipulators/MouseCameraTrackballZoomManipulator.js';
|
|
8
9
|
import vtkMouseRangeManipulator from '../Manipulators/MouseRangeManipulator.js';
|
|
10
|
+
import { mat4 } from 'gl-matrix';
|
|
9
11
|
|
|
10
12
|
// ----------------------------------------------------------------------------
|
|
11
13
|
// Global methods
|
|
12
14
|
// ----------------------------------------------------------------------------
|
|
13
15
|
|
|
14
|
-
function boundsToCorners(bounds) {
|
|
15
|
-
return [[bounds[0], bounds[2], bounds[4]], [bounds[0], bounds[2], bounds[5]], [bounds[0], bounds[3], bounds[4]], [bounds[0], bounds[3], bounds[5]], [bounds[1], bounds[2], bounds[4]], [bounds[1], bounds[2], bounds[5]], [bounds[1], bounds[3], bounds[4]], [bounds[1], bounds[3], bounds[5]]];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
16
|
// ----------------------------------------------------------------------------
|
|
19
17
|
|
|
20
18
|
function clamp(value, min, max) {
|
|
@@ -120,9 +118,8 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
|
|
|
120
118
|
const camera = renderer.getActiveCamera();
|
|
121
119
|
if (model.volumeMapper) {
|
|
122
120
|
const range = publicAPI.getSliceRange();
|
|
123
|
-
const bounds = model.volumeMapper.getBounds();
|
|
124
121
|
const clampedSlice = clamp(slice, ...range);
|
|
125
|
-
const center =
|
|
122
|
+
const center = model.volumeMapper.getCenter();
|
|
126
123
|
const distance = camera.getDistance();
|
|
127
124
|
const dop = camera.getDirectionOfProjection();
|
|
128
125
|
normalize(dop);
|
|
@@ -137,28 +134,23 @@ function vtkInteractorStyleMPRSlice(publicAPI, model) {
|
|
|
137
134
|
publicAPI.getSliceRange = () => {
|
|
138
135
|
if (model.volumeMapper) {
|
|
139
136
|
const sliceNormal = publicAPI.getSliceNormal();
|
|
140
|
-
if (sliceNormal
|
|
137
|
+
if (areEquals(sliceNormal, cache.sliceNormal)) {
|
|
141
138
|
return cache.sliceRange;
|
|
142
139
|
}
|
|
143
|
-
const bounds = model.volumeMapper.getBounds();
|
|
144
|
-
const points = boundsToCorners(bounds);
|
|
145
140
|
|
|
146
141
|
// Get rotation matrix from normal to +X (since bounds is aligned to XYZ)
|
|
147
|
-
const
|
|
148
|
-
|
|
142
|
+
const sliceOrientation = vtkMatrixBuilder.buildFromDegree().identity().rotateFromDirections(sliceNormal, [1, 0, 0]);
|
|
143
|
+
const imageAlongSliceNormal = mat4.create();
|
|
144
|
+
mat4.multiply(imageAlongSliceNormal, sliceOrientation.getMatrix(), model.volumeMapper.getInputData().getIndexToWorld());
|
|
145
|
+
|
|
146
|
+
// Transform the 8 corners of the input data's bounding box
|
|
147
|
+
// to rotate into the slice plane space without the intermediate
|
|
148
|
+
// axis-aligned box (provided by getBounds) which would grow the bounds.
|
|
149
|
+
const transformedBounds = vtkBoundingBox.transformBounds(model.volumeMapper.getInputData().getSpatialExtent(), imageAlongSliceNormal);
|
|
149
150
|
|
|
150
151
|
// range is now maximum X distance
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
for (let i = 0; i < 8; i++) {
|
|
154
|
-
const x = points[i][0];
|
|
155
|
-
if (x > maxX) {
|
|
156
|
-
maxX = x;
|
|
157
|
-
}
|
|
158
|
-
if (x < minX) {
|
|
159
|
-
minX = x;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
152
|
+
const minX = transformedBounds[0];
|
|
153
|
+
const maxX = transformedBounds[1];
|
|
162
154
|
cache.sliceNormal = sliceNormal;
|
|
163
155
|
cache.sliceRange = [minX, maxX];
|
|
164
156
|
return cache.sliceRange;
|
|
@@ -355,6 +355,7 @@ function vtkInteractorStyleManipulator(publicAPI, model) {
|
|
|
355
355
|
if (!model._interactor.isPointerLocked()) {
|
|
356
356
|
model.currentManipulator = null;
|
|
357
357
|
}
|
|
358
|
+
model._interactor.cancelAnimation(publicAPI.onButtonDown);
|
|
358
359
|
publicAPI.invokeEndInteractionEvent(END_INTERACTION_EVENT);
|
|
359
360
|
}
|
|
360
361
|
};
|
|
@@ -25,6 +25,7 @@ import '../../Filters/Sources/PointSource.js';
|
|
|
25
25
|
import '../../Filters/Sources/RTAnalyticSource.js';
|
|
26
26
|
import '../../Filters/Sources/SLICSource.js';
|
|
27
27
|
import '../../Filters/Sources/SphereSource.js';
|
|
28
|
+
import '../../Filters/Sources/TorusSource.js';
|
|
28
29
|
|
|
29
30
|
// ----------------------------------------------------------------------------
|
|
30
31
|
// vtkGlyphRepresentationProxy methods
|
package/Rendering/Core/Prop3D.js
CHANGED
|
@@ -83,6 +83,16 @@ function vtkProp3D(publicAPI, model) {
|
|
|
83
83
|
publicAPI.modified();
|
|
84
84
|
return true;
|
|
85
85
|
};
|
|
86
|
+
publicAPI.setOrientationFromQuaternion = q => {
|
|
87
|
+
const rotation = mat4.create();
|
|
88
|
+
mat4.fromQuat(rotation, q);
|
|
89
|
+
if (!areMatricesEqual(rotation, model.rotation)) {
|
|
90
|
+
model.rotation = rotation;
|
|
91
|
+
publicAPI.modified();
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
return false;
|
|
95
|
+
};
|
|
86
96
|
publicAPI.setUserMatrix = matrix => {
|
|
87
97
|
if (areMatricesEqual(model.userMatrix, matrix)) {
|
|
88
98
|
return false;
|
|
@@ -186,6 +196,12 @@ function vtkProp3D(publicAPI, model) {
|
|
|
186
196
|
}
|
|
187
197
|
return model.properties[mapperInputPort];
|
|
188
198
|
};
|
|
199
|
+
publicAPI.getProperties = () => {
|
|
200
|
+
if (model.properties.length === 0) {
|
|
201
|
+
model.properties[0] = publicAPI.makeProperty?.();
|
|
202
|
+
}
|
|
203
|
+
return model.properties;
|
|
204
|
+
};
|
|
189
205
|
publicAPI.setProperty = (firstArg, secondArg) => {
|
|
190
206
|
// Two options for argument layout:
|
|
191
207
|
// - (mapperInputPort, property)
|
|
@@ -44,10 +44,10 @@ const newInstance = macro.newInstance(extend, 'vtkPlaneManipulator');
|
|
|
44
44
|
|
|
45
45
|
// ----------------------------------------------------------------------------
|
|
46
46
|
|
|
47
|
-
var
|
|
47
|
+
var vtkPlaneManipulator$1 = {
|
|
48
48
|
intersectDisplayWithPlane,
|
|
49
49
|
extend,
|
|
50
50
|
newInstance
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
export {
|
|
53
|
+
export { vtkPlaneManipulator$1 as default, extend, intersectDisplayWithPlane, newInstance };
|
package/Widgets/Manipulators.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import vtkPickerManipulator from './Manipulators/PickerManipulator.js';
|
|
2
2
|
import vtkLineManipulator from './Manipulators/LineManipulator.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkPlaneManipulator from './Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkTrackballManipulator from './Manipulators/TrackballManipulator.js';
|
|
5
5
|
|
|
6
6
|
var Manipulators = {
|
|
7
7
|
vtkPickerManipulator,
|
|
8
8
|
vtkLineManipulator,
|
|
9
|
-
vtkPlaneManipulator
|
|
9
|
+
vtkPlaneManipulator,
|
|
10
10
|
vtkTrackballManipulator
|
|
11
11
|
};
|
|
12
12
|
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
3
|
+
import vtkTorusSource from '../../Filters/Sources/TorusSource.js';
|
|
4
|
+
|
|
5
|
+
// ----------------------------------------------------------------------------
|
|
6
|
+
// vtkRotateTransformHandleRepresentation methods
|
|
7
|
+
// ----------------------------------------------------------------------------
|
|
8
|
+
|
|
9
|
+
function vtkRotateTransformHandleRepresentation(publicAPI, model) {
|
|
10
|
+
// Set our className
|
|
11
|
+
model.classHierarchy.push('vtkRotateTransformHandleRepresentation');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// ----------------------------------------------------------------------------
|
|
15
|
+
// Object factory
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
// ----------------------------------------------------------------------------
|
|
19
|
+
function defaultValues(initialValues) {
|
|
20
|
+
return {
|
|
21
|
+
_pipeline: {
|
|
22
|
+
glyph: vtkTorusSource.newInstance({})
|
|
23
|
+
},
|
|
24
|
+
...initialValues
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function extend(publicAPI, model) {
|
|
28
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
29
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
30
|
+
|
|
31
|
+
// Object specific methods
|
|
32
|
+
vtkRotateTransformHandleRepresentation(publicAPI, model);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// ----------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
const newInstance = macro.newInstance(extend, 'vtkRotateTransformHandleRepresentation');
|
|
38
|
+
|
|
39
|
+
// ----------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
var vtkRotateTransformHandleRepresentation$1 = {
|
|
42
|
+
newInstance,
|
|
43
|
+
extend
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { vtkRotateTransformHandleRepresentation$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
3
|
+
import vtkCubeSource from '../../Filters/Sources/CubeSource.js';
|
|
4
|
+
import vtkTransformHandleSource from './TranslateTransformHandleRepresentation/TransformHandleSource.js';
|
|
5
|
+
|
|
6
|
+
// ----------------------------------------------------------------------------
|
|
7
|
+
// vtkScaleTransformHandleRepresentation methods
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
function vtkScaleTransformHandleRepresentation(publicAPI, model) {
|
|
11
|
+
// Set our className
|
|
12
|
+
model.classHierarchy.push('vtkScaleTransformHandleRepresentation');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// ----------------------------------------------------------------------------
|
|
16
|
+
// Object factory
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
20
|
+
function defaultValues(initialValues) {
|
|
21
|
+
const source = vtkTransformHandleSource.newInstance({
|
|
22
|
+
height: initialValues.height ?? 1,
|
|
23
|
+
radius: initialValues.radius ?? 1,
|
|
24
|
+
resolution: initialValues.glyphResolution ?? 12,
|
|
25
|
+
direction: [0, 0, 1]
|
|
26
|
+
});
|
|
27
|
+
const cube1 = vtkCubeSource.newInstance(initialValues.cubeSource);
|
|
28
|
+
const cube2 = vtkCubeSource.newInstance(initialValues.cubeSource);
|
|
29
|
+
source.addInputConnection(cube1.getOutputPort());
|
|
30
|
+
source.addInputConnection(cube2.getOutputPort());
|
|
31
|
+
return {
|
|
32
|
+
_pipeline: {
|
|
33
|
+
glyph: source
|
|
34
|
+
},
|
|
35
|
+
...initialValues
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function extend(publicAPI, model) {
|
|
39
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
40
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
41
|
+
|
|
42
|
+
// Object specific methods
|
|
43
|
+
vtkScaleTransformHandleRepresentation(publicAPI, model);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
const newInstance = macro.newInstance(extend, 'vtkScaleTransformHandleRepresentation');
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
var vtkScaleTransformHandleRepresentation$1 = {
|
|
53
|
+
newInstance,
|
|
54
|
+
extend
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { vtkScaleTransformHandleRepresentation$1 as default, extend, newInstance };
|
package/Widgets/Representations/TranslateTransformHandleRepresentation/TransformHandleSource.js
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { m as macro } from '../../../macros2.js';
|
|
2
|
+
import vtkMatrixBuilder from '../../../Common/Core/MatrixBuilder.js';
|
|
3
|
+
import vtkAppendPolyData from '../../../Filters/General/AppendPolyData.js';
|
|
4
|
+
import vtkCylinderSource from '../../../Filters/Sources/CylinderSource.js';
|
|
5
|
+
|
|
6
|
+
function rotatePolyData(pd, direction) {
|
|
7
|
+
const points = pd.getPoints().getData();
|
|
8
|
+
vtkMatrixBuilder.buildFromRadian().rotateFromDirections([0, 1, 0], direction).apply(points);
|
|
9
|
+
pd.getPoints().modified();
|
|
10
|
+
pd.modified();
|
|
11
|
+
}
|
|
12
|
+
function translatePolyData(pd, translation) {
|
|
13
|
+
const points = pd.getPoints().getData();
|
|
14
|
+
vtkMatrixBuilder.buildFromRadian().translate(...translation).apply(points);
|
|
15
|
+
pd.modified();
|
|
16
|
+
}
|
|
17
|
+
function vtkTransformHandleSource(publicAPI, model) {
|
|
18
|
+
// Set our className
|
|
19
|
+
model.classHierarchy.push('vtkTransformHandleSource');
|
|
20
|
+
function requestData(inData, outData) {
|
|
21
|
+
const cylinderSource = vtkCylinderSource.newInstance({
|
|
22
|
+
height: model.height,
|
|
23
|
+
initAngle: model.initAngle,
|
|
24
|
+
radius: model.radius,
|
|
25
|
+
resolution: model.resolution,
|
|
26
|
+
capping: model.capping,
|
|
27
|
+
pointType: model.pointType,
|
|
28
|
+
center: [0, 0, 0],
|
|
29
|
+
direction: [0, 1, 0]
|
|
30
|
+
});
|
|
31
|
+
const appendFilter = vtkAppendPolyData.newInstance();
|
|
32
|
+
appendFilter.setInputConnection(cylinderSource.getOutputPort(), 0);
|
|
33
|
+
if (inData[0]) {
|
|
34
|
+
translatePolyData(inData[0], [0, model.height / 2, 0]);
|
|
35
|
+
appendFilter.addInputData(inData[0]);
|
|
36
|
+
}
|
|
37
|
+
if (inData[1]) {
|
|
38
|
+
rotatePolyData(inData[1], [0, -1, 0]);
|
|
39
|
+
translatePolyData(inData[1], [0, -model.height / 2, 0]);
|
|
40
|
+
appendFilter.addInputData(inData[1]);
|
|
41
|
+
}
|
|
42
|
+
const poly = appendFilter.getOutputData();
|
|
43
|
+
const points = poly.getPoints().getData();
|
|
44
|
+
|
|
45
|
+
// Apply transformation to the points coordinates
|
|
46
|
+
vtkMatrixBuilder.buildFromRadian().translate(...model.center).rotateFromDirections([0, 1, 0], model.direction).translate(...model.center.map(c => c * -1)).apply(points);
|
|
47
|
+
|
|
48
|
+
// Update output
|
|
49
|
+
outData[0] = poly;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// Expose methods
|
|
53
|
+
publicAPI.requestData = requestData;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// ----------------------------------------------------------------------------
|
|
57
|
+
// Object factory
|
|
58
|
+
// ----------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
const DEFAULT_VALUES = {
|
|
61
|
+
capPolyData: null
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// ----------------------------------------------------------------------------
|
|
65
|
+
|
|
66
|
+
function extend(publicAPI, model) {
|
|
67
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
68
|
+
Object.assign(model, DEFAULT_VALUES, initialValues);
|
|
69
|
+
vtkCylinderSource.extend(publicAPI, model, initialValues);
|
|
70
|
+
macro.algo(publicAPI, model, 2, 1);
|
|
71
|
+
vtkTransformHandleSource(publicAPI, model);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ----------------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
const newInstance = macro.newInstance(extend, 'vtkTransformHandleSource');
|
|
77
|
+
|
|
78
|
+
// ----------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
var vtkTransformHandleSource$1 = {
|
|
81
|
+
newInstance,
|
|
82
|
+
extend
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { vtkTransformHandleSource$1 as default, extend, newInstance };
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { m as macro } from '../../macros2.js';
|
|
2
|
+
import vtkGlyphRepresentation from './GlyphRepresentation.js';
|
|
3
|
+
import vtkConeSource from '../../Filters/Sources/ConeSource.js';
|
|
4
|
+
import vtkTransformHandleSource from './TranslateTransformHandleRepresentation/TransformHandleSource.js';
|
|
5
|
+
|
|
6
|
+
// ----------------------------------------------------------------------------
|
|
7
|
+
// vtkTranslateTransformHandleRepresentation methods
|
|
8
|
+
// ----------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
function vtkTranslateTransformHandleRepresentation(publicAPI, model) {
|
|
11
|
+
// Set our className
|
|
12
|
+
model.classHierarchy.push('vtkTranslateTransformHandleRepresentation');
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// ----------------------------------------------------------------------------
|
|
16
|
+
// Object factory
|
|
17
|
+
// ----------------------------------------------------------------------------
|
|
18
|
+
|
|
19
|
+
// ----------------------------------------------------------------------------
|
|
20
|
+
function defaultValues(initialValues) {
|
|
21
|
+
const source = vtkTransformHandleSource.newInstance({
|
|
22
|
+
height: initialValues.height ?? 1,
|
|
23
|
+
radius: initialValues.radius ?? 1,
|
|
24
|
+
resolution: initialValues.glyphResolution ?? 12,
|
|
25
|
+
direction: [0, 0, 1]
|
|
26
|
+
});
|
|
27
|
+
const cone1 = vtkConeSource.newInstance(initialValues.coneSource);
|
|
28
|
+
const cone2 = vtkConeSource.newInstance(initialValues.coneSource);
|
|
29
|
+
source.addInputConnection(cone1.getOutputPort());
|
|
30
|
+
source.addInputConnection(cone2.getOutputPort());
|
|
31
|
+
return {
|
|
32
|
+
_pipeline: {
|
|
33
|
+
glyph: source
|
|
34
|
+
},
|
|
35
|
+
...initialValues
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function extend(publicAPI, model) {
|
|
39
|
+
let initialValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
40
|
+
vtkGlyphRepresentation.extend(publicAPI, model, defaultValues(initialValues));
|
|
41
|
+
|
|
42
|
+
// Object specific methods
|
|
43
|
+
vtkTranslateTransformHandleRepresentation(publicAPI, model);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ----------------------------------------------------------------------------
|
|
47
|
+
|
|
48
|
+
const newInstance = macro.newInstance(extend, 'vtkTranslateTransformHandleRepresentation');
|
|
49
|
+
|
|
50
|
+
// ----------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
var vtkTranslateTransformHandleRepresentation$1 = {
|
|
53
|
+
newInstance,
|
|
54
|
+
extend
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export { vtkTranslateTransformHandleRepresentation$1 as default, extend, newInstance };
|
|
@@ -8,8 +8,11 @@ import vtkImplicitPlaneRepresentation from './Representations/ImplicitPlaneRepre
|
|
|
8
8
|
import vtkLineHandleRepresentation from './Representations/LineHandleRepresentation.js';
|
|
9
9
|
import vtkOutlineContextRepresentation from './Representations/OutlineContextRepresentation.js';
|
|
10
10
|
import vtkPolyLineRepresentation from './Representations/PolyLineRepresentation.js';
|
|
11
|
+
import vtkRotateTransformHandleRepresentation from './Representations/RotateTransformHandleRepresentation.js';
|
|
12
|
+
import vtkScaleTransformHandleRepresentation from './Representations/ScaleTransformHandleRepresentation.js';
|
|
11
13
|
import vtkSphereHandleRepresentation from './Representations/SphereHandleRepresentation.js';
|
|
12
14
|
import vtkSplineContextRepresentation from './Representations/SplineContextRepresentation.js';
|
|
15
|
+
import vtkTranslateTransformHandleRepresentation from './Representations/TranslateTransformHandleRepresentation.js';
|
|
13
16
|
import vtkWidgetRepresentation from './Representations/WidgetRepresentation.js';
|
|
14
17
|
|
|
15
18
|
var Representations = {
|
|
@@ -23,8 +26,11 @@ var Representations = {
|
|
|
23
26
|
vtkLineHandleRepresentation,
|
|
24
27
|
vtkOutlineContextRepresentation,
|
|
25
28
|
vtkPolyLineRepresentation,
|
|
29
|
+
vtkRotateTransformHandleRepresentation,
|
|
30
|
+
vtkScaleTransformHandleRepresentation,
|
|
26
31
|
vtkSphereHandleRepresentation,
|
|
27
32
|
vtkSplineContextRepresentation,
|
|
33
|
+
vtkTranslateTransformHandleRepresentation,
|
|
28
34
|
vtkWidgetRepresentation
|
|
29
35
|
};
|
|
30
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkPlaneManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkPolyLineRepresentation from '../Representations/PolyLineRepresentation.js';
|
|
5
5
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
6
|
import { s as subtract, Z as angleBetweenVectors } from '../../Common/Core/Math/index.js';
|
|
@@ -69,7 +69,7 @@ function vtkAngleWidget(publicAPI, model) {
|
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
// Default manipulator
|
|
72
|
-
publicAPI.setManipulator(model.manipulator ||
|
|
72
|
+
publicAPI.setManipulator(model.manipulator || vtkPlaneManipulator.newInstance({
|
|
73
73
|
useCameraNormal: true
|
|
74
74
|
}));
|
|
75
75
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkCircleContextRepresentation from '../Representations/CircleContextRepresentation.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkPlaneManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkShapeWidget from './ShapeWidget.js';
|
|
5
5
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
6
|
import widgetBehavior from './EllipseWidget/behavior.js';
|
|
@@ -39,7 +39,7 @@ function vtkEllipseWidget(publicAPI, model) {
|
|
|
39
39
|
// initialization
|
|
40
40
|
// --------------------------------------------------------------------------
|
|
41
41
|
|
|
42
|
-
publicAPI.setManipulator(model.manipulator ||
|
|
42
|
+
publicAPI.setManipulator(model.manipulator || vtkPlaneManipulator.newInstance({
|
|
43
43
|
useCameraNormal: true
|
|
44
44
|
}));
|
|
45
45
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { m as macro } from '../../macros2.js';
|
|
2
2
|
import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
3
|
-
import
|
|
3
|
+
import vtkPlaneManipulator from '../Manipulators/PlaneManipulator.js';
|
|
4
4
|
import vtkLineManipulator from '../Manipulators/LineManipulator.js';
|
|
5
5
|
import vtkSphereHandleRepresentation from '../Representations/SphereHandleRepresentation.js';
|
|
6
6
|
import vtkCroppingOutlineRepresentation from '../Representations/CroppingOutlineRepresentation.js';
|
|
@@ -129,10 +129,10 @@ function vtkImageCroppingWidget(publicAPI, model) {
|
|
|
129
129
|
// initialization
|
|
130
130
|
// --------------------------------------------------------------------------
|
|
131
131
|
|
|
132
|
-
publicAPI.setCornerManipulator(
|
|
132
|
+
publicAPI.setCornerManipulator(vtkPlaneManipulator.newInstance({
|
|
133
133
|
useCameraNormal: true
|
|
134
134
|
}));
|
|
135
|
-
publicAPI.setEdgeManipulator(
|
|
135
|
+
publicAPI.setEdgeManipulator(vtkPlaneManipulator.newInstance());
|
|
136
136
|
publicAPI.setFaceManipulator(vtkLineManipulator.newInstance());
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -4,7 +4,7 @@ import vtkAbstractWidgetFactory from '../Core/AbstractWidgetFactory.js';
|
|
|
4
4
|
import vtkImplicitPlaneRepresentation from '../Representations/ImplicitPlaneRepresentation.js';
|
|
5
5
|
import vtkLineManipulator from '../Manipulators/LineManipulator.js';
|
|
6
6
|
import vtkTrackballManipulator from '../Manipulators/TrackballManipulator.js';
|
|
7
|
-
import
|
|
7
|
+
import vtkPlaneManipulator from '../Manipulators/PlaneManipulator.js';
|
|
8
8
|
import { ViewTypes } from '../Core/WidgetManager/Constants.js';
|
|
9
9
|
|
|
10
10
|
// ----------------------------------------------------------------------------
|
|
@@ -145,7 +145,7 @@ function widgetBehavior(publicAPI, model) {
|
|
|
145
145
|
// --------------------------------------------------------------------------
|
|
146
146
|
|
|
147
147
|
model.lineManipulator = vtkLineManipulator.newInstance();
|
|
148
|
-
model.planeManipulator =
|
|
148
|
+
model.planeManipulator = vtkPlaneManipulator.newInstance();
|
|
149
149
|
model.trackballManipulator = vtkTrackballManipulator.newInstance();
|
|
150
150
|
}
|
|
151
151
|
|