Skip to content

[Feature] Increase the color width valueย #3377

@lsw123lwq-cell

Description

@lsw123lwq-cell

Hi! ๐Ÿ‘‹

Firstly, thanks for your work on this project! ๐Ÿ™‚

Today I used patch-package to patch @kitware/[email protected] for the project I'm working on.

Currently, the color width is set using model.renderable.getColorTextureWidth(), but if the imageโ€™s scalar range exceeds that value, I want the color width to automatically expand to the maximum size.

Here is the diff that solved my problem:

diff --git a/node_modules/@kitware/vtk.js/Rendering/OpenGL/ImageMapper.js b/node_modules/@kitware/vtk.js/Rendering/OpenGL/ImageMapper.js
index bb676c7..cee022a 100644
--- a/node_modules/@kitware/vtk.js/Rendering/OpenGL/ImageMapper.js
+++ b/node_modules/@kitware/vtk.js/Rendering/OpenGL/ImageMapper.js
@@ -581,6 +581,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
     if (!imgScalars) {
       return;
     }
+    const maxScalarRange = image.getPointData().getScalars().getRange()[1];
     const dataType = imgScalars.getDataType();
     const numComp = imgScalars.getNumberOfComponents();
     const actorProperty = actor.getProperty();
@@ -602,7 +603,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
       });
       model.colorTexture.setOpenGLRenderWindow(model._openGLRenderWindow);
       let cWidth = model.renderable.getColorTextureWidth();
-      if (cWidth <= 0) {
+      if (cWidth <= 0 || maxScalarRange > cWidth) {
         cWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
       }
       const cSize = cWidth * textureHeight * 3;
@@ -680,7 +681,7 @@ function vtkOpenGLImageMapper(publicAPI, model) {
     const reBuildPwf = !pwfTex?.oglObject?.getHandle() || pwfTex?.hash !== pwfunToString;
     if (reBuildPwf) {
       let pwfWidth = model.renderable.getOpacityTextureWidth();
-      if (pwfWidth <= 0) {
+      if (pwfWidth <= 0 || maxScalarRange > pwfWidth) {
         pwfWidth = model.context.getParameter(model.context.MAX_TEXTURE_SIZE);
       }
       const pwfSize = pwfWidth * textureHeight;

This issue body was partially generated by patch-package.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions