Skip to content

Commit 8230288

Browse files
authored
fix: 🐛 Correct code for swapping out labelmap (#91)
1 parent 2440489 commit 8230288

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/VTKViewport/View2D.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,23 @@ export default class View2D extends Component {
439439
) {
440440
this.subs.labelmap.unsubscribe();
441441

442+
// Remove actors.
443+
if (this.labelmap && this.labelmap.actor) {
444+
this.renderer.removeVolume(this.labelmap.actor);
445+
446+
if (this.api) {
447+
const { actors } = this.api;
448+
449+
const index = actors.findIndex(
450+
actor => actor === this.labelmap.actor
451+
);
452+
453+
if (index !== -1) {
454+
actors.splice(index, 1);
455+
}
456+
}
457+
}
458+
442459
const labelmapImageData = this.props.paintFilterLabelMapImageData;
443460

444461
const labelmap = createLabelPipeline(
@@ -449,6 +466,15 @@ export default class View2D extends Component {
449466

450467
this.labelmap = labelmap;
451468

469+
// Add actors.
470+
if (this.labelmap && this.labelmap.actor) {
471+
this.renderer.addVolume(this.labelmap.actor);
472+
473+
if (this.api) {
474+
this.api.actors = this.api.actors.concat(this.labelmap.actor);
475+
}
476+
}
477+
452478
labelmap.mapper.setInputConnection(this.paintFilter.getOutputPort());
453479

454480
// You can update the labelmap externally just by calling modified()

0 commit comments

Comments
 (0)