From a8991434797b2a21b6c321dcd6d87f4591e3f350 Mon Sep 17 00:00:00 2001 From: Ouwen Huang Date: Sun, 12 Feb 2023 17:52:40 +0000 Subject: [PATCH] updated examples, removed voiRange from volume viewport --- .../core/examples/stackVoiSigmoid/index.ts | 2 +- .../core/examples/volumeVoiSigmoid/index.ts | 2 +- .../src/RenderingEngine/BaseVolumeViewport.ts | 47 ++++++++----------- 3 files changed, 22 insertions(+), 29 deletions(-) diff --git a/packages/core/examples/stackVoiSigmoid/index.ts b/packages/core/examples/stackVoiSigmoid/index.ts index 21136195e9..6ad402b276 100644 --- a/packages/core/examples/stackVoiSigmoid/index.ts +++ b/packages/core/examples/stackVoiSigmoid/index.ts @@ -76,7 +76,7 @@ addButtonToToolbar({ // Set a range to highlight bones viewport.setProperties({ - VOILUTFunction: Enums.VOILUTFunctionType.SIGMOID, + VOILUTFunction: Enums.VOILUTFunctionType.SAMPLED_SIGMOID, }); viewport.render(); diff --git a/packages/core/examples/volumeVoiSigmoid/index.ts b/packages/core/examples/volumeVoiSigmoid/index.ts index 15e6dec03c..0eb5c5f9c9 100644 --- a/packages/core/examples/volumeVoiSigmoid/index.ts +++ b/packages/core/examples/volumeVoiSigmoid/index.ts @@ -69,7 +69,7 @@ addButtonToToolbar({ // Set a range to highlight bones viewport.setProperties({ - VOILUTFunction: Enums.VOILUTFunctionType.SIGMOID, + VOILUTFunction: Enums.VOILUTFunctionType.SAMPLED_SIGMOID, }); viewport.render(); diff --git a/packages/core/src/RenderingEngine/BaseVolumeViewport.ts b/packages/core/src/RenderingEngine/BaseVolumeViewport.ts index 8a93be1e0d..861974368b 100644 --- a/packages/core/src/RenderingEngine/BaseVolumeViewport.ts +++ b/packages/core/src/RenderingEngine/BaseVolumeViewport.ts @@ -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) { @@ -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); } /** @@ -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 = { @@ -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, }; }; @@ -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 @@ -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);