Skip to content

Commit 8166f2a

Browse files
fix(ImageMapper): Provide reasonable default if no function
1 parent bb17297 commit 8166f2a

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

  • Sources/Rendering/OpenGL/ImageMapper

Sources/Rendering/OpenGL/ImageMapper/index.js

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -690,18 +690,23 @@ function vtkOpenGLImageMapper(publicAPI, model) {
690690

691691
for (let c = 0; c < numIComps; ++c) {
692692
pwfun = actorProperty.getPiecewiseFunction(c);
693-
const pwfRange = pwfun.getRange();
694-
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth, tmpTable, 1);
695-
// adjust for sample distance etc
696-
if (iComps) {
697-
for (let i = 0; i < pwfWidth; i++) {
698-
pwfFloatTable[c * pwfWidth * 2 + i] = 255.0 * tmpTable[i];
699-
pwfFloatTable[c * pwfWidth * 2 + i + pwfWidth] =
700-
255.0 * tmpTable[i];
701-
}
693+
if (pwfun === null) {
694+
// Piecewise constant max if no function supplied for this component
695+
pwfFloatTable.fill(255.0);
702696
} else {
703-
for (let i = 0; i < pwfWidth; i++) {
704-
pwfFloatTable[c * pwfWidth * 2 + i] = 255.0 * tmpTable[i];
697+
const pwfRange = pwfun.getRange();
698+
pwfun.getTable(pwfRange[0], pwfRange[1], pwfWidth, tmpTable, 1);
699+
// adjust for sample distance etc
700+
if (iComps) {
701+
for (let i = 0; i < pwfWidth; i++) {
702+
pwfFloatTable[c * pwfWidth * 2 + i] = 255.0 * tmpTable[i];
703+
pwfFloatTable[c * pwfWidth * 2 + i + pwfWidth] =
704+
255.0 * tmpTable[i];
705+
}
706+
} else {
707+
for (let i = 0; i < pwfWidth; i++) {
708+
pwfFloatTable[c * pwfWidth * 2 + i] = 255.0 * tmpTable[i];
709+
}
705710
}
706711
}
707712
}

0 commit comments

Comments
 (0)