@kitware/vtk.js 34.11.2 → 34.11.3
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.
|
@@ -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
|
|
|
@@ -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;
|
package/Rendering/Core/Prop3D.js
CHANGED
|
@@ -186,6 +186,12 @@ function vtkProp3D(publicAPI, model) {
|
|
|
186
186
|
}
|
|
187
187
|
return model.properties[mapperInputPort];
|
|
188
188
|
};
|
|
189
|
+
publicAPI.getProperties = () => {
|
|
190
|
+
if (model.properties.length === 0) {
|
|
191
|
+
model.properties[0] = publicAPI.makeProperty?.();
|
|
192
|
+
}
|
|
193
|
+
return model.properties;
|
|
194
|
+
};
|
|
189
195
|
publicAPI.setProperty = (firstArg, secondArg) => {
|
|
190
196
|
// Two options for argument layout:
|
|
191
197
|
// - (mapperInputPort, property)
|