[vtkusers] contouring 3D polyData object not giving isosurface

frmunoz fjmunoz95 at gmail.com
Wed Feb 6 10:51:16 EST 2019


hi,

I have problems when doing contours on a PolyData object, my input data
comes from a .vtu files which have Unstructured Grid, so this is what i've
done:
- transform the UnstructuredGrid to PolyData
- do pointsValues().SetScalars using one Attribute from the Unstructured
Grid (i've checked that is a point data attribute) as vtkDoubleArray. 
- do contour using this poly data, choose the contours and update
- then create the mapper, actor and rederer to visualize.

and i get a contour line which correspond to the border of the isosurface
(checked with paraview) but inside the contour line, where the surface
should be, there is nothing.

I'm using windows 10 and i've isntalled vtk using anaconda, cannot upload
the file since is too big, but in code what im doing is:

# read file
reader = vtk.vtkXMLUnstructuredGridReader()
reader.SetFileName(file_name)
reader.Update()

# transform to poly
geo = vtk.vtkGeometryFilter()
geo.SetInputConnection(reader.GetOutputPort())
geo.Update()
poly = geo.GetOutput()

# set desired scalar on poly data
attr = poly.GetAttributes(0).GetArray(1) # desired attr
poly.GetPointData().SetScalars(attr)

# get contour poly data
contour = vtk.vtkContourFilter()
contour.SetInputData(poly)
contour.SetValue(0, 0)
contour.Update()

# mapper
mapper = vtk.vtkPolyDataMapper()
mapper.SetInputData(contour.GetOutput())
mapper.ScalarVisibilityOff()

# actor
actor = vtk.vtkActor()
actor.SetMapper(mapper)

# renderer
renderer = vtk.vtkRenderer()
render_window = vtk.vtkRenderWindow()
render_window.AddRenderer(renderer)
interactor = vtk.vtkRenderWindowInteractor()
interactor.SetRenderWindow(render_window)

renderer.AddActor(actor)
renderer.SetBackground(.3, .6, .3) # green

render_window.SetSize(600, 600)
render_window.Render()
interactor.Initialize()
interactor.Start()

i'll insert an image of the result i'm seeing. 
<http://vtk.1045678.n5.nabble.com/file/t342690/contour.png> 


P.D.1 if you wonder why im not just using the UnstructuredGrid to do the
contour it's because didn't work, but really dont know what was the problem.

Thanks




--
Sent from: http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html


More information about the vtkusers mailing list