Skip to content

Commit

Permalink
updated examples, removed voiRange from volume viewport
Browse files Browse the repository at this point in the history
  • Loading branch information
Ouwen committed Feb 12, 2023
1 parent ac069b7 commit a899143
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion packages/core/examples/stackVoiSigmoid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ addButtonToToolbar({

// Set a range to highlight bones
viewport.setProperties({
VOILUTFunction: Enums.VOILUTFunctionType.SIGMOID,
VOILUTFunction: Enums.VOILUTFunctionType.SAMPLED_SIGMOID,
});

viewport.render();
Expand Down
2 changes: 1 addition & 1 deletion packages/core/examples/volumeVoiSigmoid/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ addButtonToToolbar({

// Set a range to highlight bones
viewport.setProperties({
VOILUTFunction: Enums.VOILUTFunctionType.SIGMOID,
VOILUTFunction: Enums.VOILUTFunctionType.SAMPLED_SIGMOID,
});

viewport.render();
Expand Down
47 changes: 20 additions & 27 deletions packages/core/src/RenderingEngine/BaseVolumeViewport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
private _FrameOfReferenceUID: string;

// Viewport Properties
private voiRange: VOIRange;
// TODO: similar to setVoi, this is only applicable to first volume
private VOILUTFunction: VOILUTFunctionType;

constructor(props: ViewportInput) {
Expand Down Expand Up @@ -183,7 +183,7 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
voiLUTFunction = VOILUTFunctionType.LINEAR;
}
this.VOILUTFunction = voiLUTFunction;
this.setVOI(this.voiRange, volumeId, suppressEvents);
this.setVOI(undefined, volumeId, suppressEvents);
}

/**
Expand Down Expand Up @@ -242,7 +242,6 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
const cfun = createLinearRGBTransferFunction(voiRangeToUse);
volumeActor.getProperty().setRGBTransferFunction(0, cfun);
}
this.voiRange = voiRangeToUse;

if (!suppressEvents) {
const eventDetail: VoiModifiedEventDetail = {
Expand Down Expand Up @@ -284,8 +283,25 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
* @returns viewport properties including voi, interpolation type: TODO: slabThickness, invert, rotation, flip
*/
public getProperties = (): VolumeViewportProperties => {
const actorEntries = this.getActors();
const voiRanges = actorEntries.map((actorEntry) => {
const volumeActor = actorEntry.actor as vtkVolume;
const volumeId = actorEntry.uid;
const voiRange = volumeActor
.getProperty()
.getRGBTransferFunction(0)
// @ts-ignore: vtk d ts problem
.getRange();
return {
volumeId,
voiRange: {
lower: voiRange[0],
upper: voiRange[1],
},
};
});
return {
voiRange: this.voiRange,
voiRange: voiRanges[0].voiRange, // TODO: handle multiple actors instead of just first.
VOILUTFunction: this.VOILUTFunction,
};
};
Expand Down Expand Up @@ -331,18 +347,6 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
suppressEvents
);

if (i === 0 && !this.voiRange) {
const voiRange = actor
.getProperty()
.getRGBTransferFunction(0)
// @ts-ignore: vtk d ts problem
.getRange();
this.voiRange = {
lower: voiRange[0],
upper: voiRange[1],
};
}

// We cannot use only volumeId since then we cannot have for instance more
// than one representation of the same volume (since actors would have the
// same name, and we don't allow that) AND We cannot use only any uid, since
Expand Down Expand Up @@ -407,17 +411,6 @@ abstract class BaseVolumeViewport extends Viewport implements IVolumeViewport {
this.id,
suppressEvents
);
if (i === 0 && !this.voiRange) {
const voiRange = actor
.getProperty()
.getRGBTransferFunction(0)
// @ts-ignore: vtk d ts problem
.getRange();
this.voiRange = {
lower: voiRange[0],
upper: voiRange[1],
};
}

if (visibility === false) {
actor.setVisibility(false);
Expand Down

0 comments on commit a899143

Please sign in to comment.