Skip to content

Fix volume pipeline range check to work with cell_data#1020

Merged
prabhuramachandran merged 1 commit into
enthought:masterfrom
topikuu:fix_cell_data_check
Nov 11, 2021
Merged

Fix volume pipeline range check to work with cell_data#1020
prabhuramachandran merged 1 commit into
enthought:masterfrom
topikuu:fix_cell_data_check

Conversation

@topikuu
Copy link
Copy Markdown
Contributor

@topikuu topikuu commented Mar 24, 2021

Previously trying to render volume views of UnstructuredGrids with
cell_data as the rendered scalar field caused constant error
messages although there are no real issues with them.

Signed-off-by: Topi Kuutela topi.kuutela@aalto.fi

@rahulporuri
Copy link
Copy Markdown
Contributor

@topikuu thanks for the fix but can you give us some more information about what the actual issue is? If possible, maybe add a code snippet which we can use to reproduce the issue.

@topikuu
Copy link
Copy Markdown
Contributor Author

topikuu commented Mar 24, 2021

Here's a minimal example which triggers the error:

from mayavi import mlab
from tvtk.api import tvtk
import numpy as np

v = np.array([[0.25, -0.5, 0.25],
              [-0.25, 0.0, 0.25],
              [0.25, 0.5, 0.25],
              [0.0, 0.0, -0.25],
              [0.25, 0.0, 0.25]], dtype=float)
t = np.array([[0, 1, 3, 4],
              [1, 2, 3, 4]], dtype=int)

t_m = tvtk.UnstructuredGrid(points = v)
t_m.set_cells(tvtk.Tetra().cell_type, t)

t_m.cell_data.scalars = np.array([1, 10])
t_m.cell_data.scalars.name = "values"
dset = mlab.pipeline.add_dataset(t_m)
volume_pipe = mlab.pipeline.volume(dset, vmin=-50, vmax=10)
volume_pipe.volume_mapper_type = 'UnstructuredGridVolumeRayCastMapper'
mlab.show()

The repeated messages then appear if volume_pipe is updated via update_pipeline() or update_data().

@rahulporuri rahulporuri self-requested a review March 24, 2021 13:43
@rahulporuri
Copy link
Copy Markdown
Contributor

@topikuu the CI failure is unrelated so you can ignore them.

Copy link
Copy Markdown
Member

@prabhuramachandran prabhuramachandran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fix, this looks good barring the small change I have requested. Please update this and I can merge this before the upcoming release.

Comment thread mayavi/modules/volume.py Outdated
if point_name is None and cell_name is None:
error('No scalars in input data!')
rng = (0, 255)
elif not point_name is None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be elif point_name is not None:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

@prabhuramachandran
Copy link
Copy Markdown
Member

@topikuu -- could you also please rebase to current master so the tests will run. Thanks.

@rahulporuri rahulporuri removed their request for review November 11, 2021 09:51
Previously trying to render volume views of UnstructuredGrids with
cell_data as the rendered scalar field caused constant error
messages although there are no real issues with them.

Signed-off-by: Topi Kuutela <topi.kuutela@aalto.fi>
@topikuu topikuu force-pushed the fix_cell_data_check branch from 1b4a11a to 89b0030 Compare November 11, 2021 13:55
@rahulporuri
Copy link
Copy Markdown
Contributor

thanks @topikuu

Copy link
Copy Markdown
Member

@prabhuramachandran prabhuramachandran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@prabhuramachandran prabhuramachandran merged commit 8e64b26 into enthought:master Nov 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants