Skip to content

Commit 11d6f4b

Browse files
PaulHaxfinetjul
authored andcommitted
refactor(bounds): convert VolumeMapper and ImageResliceMapper to computeBounds
1 parent 26bd64d commit 11d6f4b

2 files changed

Lines changed: 16 additions & 9 deletions

File tree

Sources/Rendering/Core/ImageResliceMapper/index.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,25 @@ function vtkImageResliceMapper(publicAPI, model) {
1616
// Set our className
1717
model.classHierarchy.push('vtkImageResliceMapper');
1818

19-
publicAPI.getBounds = () => {
20-
let bds = [...vtkBoundingBox.INIT_BOUNDS];
19+
publicAPI.computeBounds = () => {
2120
const image = publicAPI.getInputData();
2221
if (publicAPI.getSlicePolyData()) {
23-
bds = publicAPI.getSlicePolyData().getBounds();
22+
vtkBoundingBox.setBounds(
23+
model.bounds,
24+
publicAPI.getSlicePolyData().getBounds()
25+
);
2426
} else if (image) {
25-
bds = image.getBounds();
27+
vtkBoundingBox.setBounds(model.bounds, image.getBounds());
2628
if (publicAPI.getSlicePlane()) {
2729
vtkBoundingBox.cutWithPlane(
28-
bds,
30+
model.bounds,
2931
publicAPI.getSlicePlane().getOrigin(),
3032
publicAPI.getSlicePlane().getNormal()
3133
);
3234
}
35+
} else {
36+
vtkBoundingBox.reset(model.bounds);
3337
}
34-
return bds;
3538
};
3639
}
3740

Sources/Rendering/Core/VolumeMapper/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ function vtkVolumeMapper(publicAPI, model) {
8181

8282
const superClass = { ...publicAPI };
8383

84-
publicAPI.getBounds = () => {
84+
publicAPI.computeBounds = () => {
85+
const input = publicAPI.getInputData();
86+
if (!input) {
87+
vtkBoundingBox.reset(model.bounds);
88+
return;
89+
}
8590
if (!model.static) {
8691
publicAPI.update();
8792
}
88-
model.bounds = [...publicAPI.getInputData().getBounds()];
89-
return model.bounds;
93+
vtkBoundingBox.setBounds(model.bounds, input.getBounds());
9094
};
9195

9296
publicAPI.setBlendModeToComposite = () => {

0 commit comments

Comments
 (0)