contouring 3D polyData object not giving isosurface

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

contouring 3D polyData object not giving isosurface

frmunoz
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
Reply | Threaded
Open this post in threaded view
|

Re: contouring 3D polyData object not giving isosurface

VTK - Users mailing list
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 <[hidden email]> 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.

_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: contouring 3D polyData object not giving isosurface

Bill Lorensen
In reply to this post by frmunoz
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 <[hidden email]> 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
_______________________________________________
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