[vtkusers] How to extract poly data from an unstructured grid

Frederic DANESI frederic.danesi at dinccs.com
Thu Oct 9 02:49:51 EDT 2008


It should be easier if you build directly a polydata 


# Create an unstructured grids containing a triangle cell.

vtkPoints trianglePoints

  trianglePoints SetNumberOfPoints 3

  trianglePoints InsertPoint 0 0 0 0

  trianglePoints InsertPoint 1 1 0 0

  trianglePoints InsertPoint 2 .5 .5 0

vtkTriangle aTriangle

  [aTriangle GetPointIds] SetId 0 0

  [aTriangle GetPointIds] SetId 1 1

  [aTriangle GetPointIds] SetId 2 2

vtkPolyData aTrianglePoly

  aTrianglePoly Allocate 1 1

  aTrianglePoly InsertNextCell [aTriangle GetCellType] [aTriangle
GetPointIds]

  aTrianglePoly SetPoints trianglePoints

   

Fred.

 

De : vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] De la part
de Elvis Dowson
Envoyé : jeudi 9 octobre 2008 07:13
À : VTK Users
Objet : [vtkusers] How to extract poly data from an unstructured grid

 

Hi,

        I have an example code fragment shown below. How can I extract
vtkPolyData from the vtkUnstructuredGrid?

 

# Create an unstructured grids containing a triangle cell.

vtkPoints trianglePoints

  trianglePoints SetNumberOfPoints 3

  trianglePoints InsertPoint 0 0 0 0

  trianglePoints InsertPoint 1 1 0 0

  trianglePoints InsertPoint 2 .5 .5 0

vtkTriangle aTriangle

  [aTriangle GetPointIds] SetId 0 0

  [aTriangle GetPointIds] SetId 1 1

  [aTriangle GetPointIds] SetId 2 2

vtkUnstructuredGrid aTriangleGrid

  aTriangleGrid Allocate 1 1

  aTriangleGrid InsertNextCell [aTriangle GetCellType] [aTriangle
GetPointIds]

  aTriangleGrid SetPoints trianglePoints

 

I want to get a vtkPolyData object so that I can pass it along to
vtkPolyDataNormals.

 

Best regards,

 

Elvis Dowson

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20081009/e4ad2fbe/attachment.htm>


More information about the vtkusers mailing list