enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

GeometryFilter clipping segmentation fault #1071

Closed JaRoSchm closed 2 years ago

JaRoSchm commented 3 years ago

Hi, I noticed a segmentation fault when applying the GeometryFilter. Here is an example reproducing the error which is adopted from https://docs.enthought.com/mayavi/mayavi/auto/example_adjust_cropping_extents.html

import numpy as np
from mayavi import mlab

x, y, z, s = np.random.random((4, 500))

# Now build the visualization using mlab
fig = mlab.figure(1, bgcolor=(1, 1, 1))

# Create unconnected points
pts = mlab.pipeline.scalar_scatter(x, y, z, s)
mlab.outline(pts)

# Use a geometry_filter to filter with a bounding box
geometry_filter = mlab.pipeline.user_defined(pts, filter="GeometryFilter")
geometry_filter.filter.extent_clipping = True
# Connect our dialog to the filter
geometry_filter.filter.extent = [0.0, 1.0, 0.0, 1.0, 0.0, 0.8]

# The geometry_filter leaves hanging points, we need to add a
# CleanPolyData filter to get rid of these.
clip = mlab.pipeline.user_defined(geometry_filter, filter="CleanPolyData")

# Finally, visualize the remaining points with spheres using a glyph
# module
spheres = mlab.pipeline.glyph(clip, scale_factor=0.1)

mlab.show()

I use the versions: mayavi 4.7.3, vtk 9.0.1, python 3.8.11 Everything works fine for vtk < 9.

JaRoSchm commented 2 years ago

Hi, I just tested the snippet again and noticed that this error is still present with vtk 9.0.3 and the master branch of mayavi with the fixes for new vtk versions. Is there any hope for this to be fixed in the upcoming release? Thanks!

prabhuramachandran commented 2 years ago

Thanks for pointing this out, I have just sent a PR to fix this: https://github.com/enthought/mayavi/pull/1103

prabhuramachandran commented 2 years ago

I realize there is a bigger problem though in that VTK 9.1 is out and there are several issues to fix there. So this fix will only work with 9.0.3.

JaRoSchm commented 2 years ago

Thank you very much! A fix of this bug for any VTK version >= 9 is helpful for me.