[vtkusers] contouring 3D polyData object not giving isosurface
Cory Quammen
cory.quammen at kitware.com
Wed Feb 6 11:04:13 EST 2019
Hi,
The vtkusers mailing list is transitioning to discourse.vtk.org. Please
post new questions on that forum.
To answer your question, you are seeing exactly what you should see with
this pipeline. The contour on a surface will always be a set of line
segments. If you want to see a surface corresponding the interior of the
contour, you might consider using the vtkClipPolyData, which will clip the
geometry by the active scalar array according to what you set in
vtkClipPolyData::SetValue().
HTH,
Cory
On Wed, Feb 6, 2019 at 10: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
>
--
Cory Quammen
Staff R&D Engineer
Kitware, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20190206/67cd9810/attachment.html>
More information about the vtkusers
mailing list