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

Elvis Dowson elvis.dowson at mac.com
Thu Oct 9 08:56:21 EDT 2008


Here is the full working Tcl source code

# This example shows how to extract poly data from unstructured grids.
#

package require vtk
package require vtkinteraction

# 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 triangle
   [triangle GetPointIds] SetId 0 0
   [triangle GetPointIds] SetId 1 1
   [triangle GetPointIds] SetId 2 2
vtkUnstructuredGrid triangleGrid
   triangleGrid Allocate 1 1
   triangleGrid InsertNextCell [triangle GetCellType] [triangle  
GetPointIds]
   triangleGrid SetPoints trianglePoints

# Extract poly data from unstructured grid
vtkDataSetSurfaceFilter triangleCellDataSetSurfaceFilter
   triangleCellDataSetSurfaceFilter SetInput triangleGrid

vtkPolyDataMapper trianglePolyDataMapper
   trianglePolyDataMapper SetInputConnection  
[triangleCellDataSetSurfaceFilter GetOutputPort]

vtkActor triangleActor
   triangleActor SetMapper trianglePolyDataMapper

# Create the usual rendering stuff.
vtkRenderer ren1
vtkRenderWindow renWin
   renWin AddRenderer ren1
   renWin SetSize 300 150
vtkRenderWindowInteractor iren
   iren SetRenderWindow renWin

ren1 SetBackground .1 .2 .4

ren1 AddActor triangleActor

ren1 ResetCamera
ren1 ResetCameraClippingRange

renWin Render

# render the image
#
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
wm withdraw .

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


More information about the vtkusers mailing list