Skip to content

Commit c6a52ba

Browse files
jmannaufloryst
authored andcommitted
refactor: Updated ImageMapper to set range regardless of sliceMode
1 parent a594e19 commit c6a52ba

File tree

1 file changed

+15
-15
lines changed
  • Sources/Rendering/OpenGL/ImageMapper

1 file changed

+15
-15
lines changed

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,13 +1237,6 @@ function vtkOpenGLImageMapper(publicAPI, model) {
12371237
const spatialExt = image.getSpatialExtent();
12381238
const basicScalars = imgScalars.getData();
12391239
let scalars = null;
1240-
/**
1241-
* Used to store the range of the scalars array, if available. Pre-setting
1242-
* the scalars range can prevent it being calculated again.
1243-
*
1244-
* @type{ import("../../../interfaces").vtkRange[]|undefined }
1245-
*/
1246-
let ranges;
12471240
// Get right scalars according to slicing mode
12481241
if (ijkMode === SlicingMode.I) {
12491242
scalars = new basicScalars.constructor(dims[2] * dims[1] * numComp);
@@ -1317,18 +1310,25 @@ function vtkOpenGLImageMapper(publicAPI, model) {
13171310
ptsArray[9] = spatialExt[1];
13181311
ptsArray[10] = spatialExt[3];
13191312
ptsArray[11] = sliceDepth;
1320-
if (sliceOffset === 0) {
1321-
// If the sliceOffset is 0, the scalars array is a view of the
1322-
// original scalars array. As a micro-optimization, we can get the
1323-
// range from the original scalars array and set the range to the
1324-
// scalars array. This means there is no need to re-calculate the
1325-
// ranges for the scalars array.
1326-
ranges = imgScalars.getRanges();
1327-
}
13281313
} else {
13291314
vtkErrorMacro('Reformat slicing not yet supported.');
13301315
}
13311316

1317+
/**
1318+
*
1319+
* Fetch the ranges of the source volume, `imgScalars`, and use them when
1320+
* creating the texture. Whilst the pre-calculated ranges may not be
1321+
* strictly correct for the slice, it is guarateed to be within the
1322+
* source volume's range.
1323+
*
1324+
* There is a significant performance improvement by pre-setting the range
1325+
* of the scalars array particaulrly when scrolling through the source
1326+
* volume as there is no need to calculate the range of the slice scalar.
1327+
*
1328+
* @type{ import("../../../interfaces").vtkRange[] }
1329+
*/
1330+
const ranges = imgScalars.getRanges();
1331+
13321332
// Don't share this resource as `scalars` is created in this function
13331333
// so it is impossible to share
13341334
model.openGLTexture.resetFormatAndType();

0 commit comments

Comments
 (0)