[vtkusers] contouring 3D polyData object not giving isosurface
Bill Lorensen
bill.lorensen at gmail.com
Wed Feb 6 12:23:07 EST 2019
Run contour on the unstructured grid. Geometry filter will just
produce polydata on the external surface.
Bill
On Wed, Feb 6, 2019 at 7:53 AM frmunoz <fjmunoz95 at gmail.com> wrote:
>
> 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
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
--
Unpaid intern in BillsParadise at noware dot com
More information about the vtkusers
mailing list