[vtkusers] Rendering polyhedras

Avinandan Sengupta avinandan.sengupta at gmail.com
Wed Dec 5 02:39:27 EST 2007


Hi,

I'm using the following mechanism to render polygons with thickness as 
3D objects (polyhedra). Is there something simpler or more effective?

Thanks,
Avi

########### start of code ##############
package require vtk
package require vtkinteraction

vtkPoints aPoints

#0
aPoints InsertNextPoint 350.00 125.00 0.00
aPoints InsertNextPoint 200.00  75.00 0.00

#2
aPoints InsertNextPoint 100.00 100.00 0.00
aPoints InsertNextPoint 100.00 200.00 0.00

#4
aPoints InsertNextPoint 180.00 270.00 0.00
aPoints InsertNextPoint 250.00 100.00 0.00

#6
aPoints InsertNextPoint 350.00 125.00 30.00
aPoints InsertNextPoint 200.00  75.00 30.00

#8
aPoints InsertNextPoint 100.00 100.00 30.00
aPoints InsertNextPoint 100.00 200.00 30.00

#10
aPoints InsertNextPoint 180.00 270.00 30.00
aPoints InsertNextPoint 250.00 100.00 30.00

vtkPolygon aPoly
 [aPoly GetPointIds] SetNumberOfIds 6
 [aPoly GetPointIds] SetId 0 0
 [aPoly GetPointIds] SetId 1 1
 [aPoly GetPointIds] SetId 2 2
 [aPoly GetPointIds] SetId 3 3
 [aPoly GetPointIds] SetId 4 4
 [aPoly GetPointIds] SetId 5 5

vtkPolygon bPoly
 [bPoly GetPointIds] SetNumberOfIds 6
 [bPoly GetPointIds] SetId 0 6
 [bPoly GetPointIds] SetId 1 7
 [bPoly GetPointIds] SetId 2 8
 [bPoly GetPointIds] SetId 3 9
 [bPoly GetPointIds] SetId 4 10
 [bPoly GetPointIds] SetId 5 11

vtkQuad quad1
   [quad1 GetPointIds] SetId 0 0
   [quad1 GetPointIds] SetId 1 1
   [quad1 GetPointIds] SetId 2 7
   [quad1 GetPointIds] SetId 3 6

vtkQuad quad2
   [quad2 GetPointIds] SetId 0 1
   [quad2 GetPointIds] SetId 1 2
   [quad2 GetPointIds] SetId 2 8
   [quad2 GetPointIds] SetId 3 7

vtkQuad quad3
   [quad3 GetPointIds] SetId 0 2
   [quad3 GetPointIds] SetId 1 3
   [quad3 GetPointIds] SetId 2 9
   [quad3 GetPointIds] SetId 3 8

vtkQuad quad4
   [quad4 GetPointIds] SetId 0 3
   [quad4 GetPointIds] SetId 1 4
   [quad4 GetPointIds] SetId 2 10
   [quad4 GetPointIds] SetId 3 9

vtkQuad quad5
   [quad5 GetPointIds] SetId 0 4
   [quad5 GetPointIds] SetId 1 5
   [quad5 GetPointIds] SetId 2 11
   [quad5 GetPointIds] SetId 3 10

vtkQuad quad6
   [quad6 GetPointIds] SetId 0 5
   [quad6 GetPointIds] SetId 1 0
   [quad6 GetPointIds] SetId 2 6
   [quad6 GetPointIds] SetId 3 11

vtkCellArray aPolyArray
aPolyArray InsertNextCell aPoly
aPolyArray InsertNextCell bPoly
aPolyArray InsertNextCell quad1
aPolyArray InsertNextCell quad2
aPolyArray InsertNextCell quad3
aPolyArray InsertNextCell quad4
aPolyArray InsertNextCell quad5
aPolyArray InsertNextCell quad6

# Assign points and cells
vtkPolyData aPolydata
aPolydata SetPoints aPoints
aPolydata SetPolys aPolyArray

vtkTriangleFilter tf
tf SetInput aPolydata

vtkPolyDataMapper aMapper
aMapper SetInput aPolydata
aMapper SetInputConnection [tf GetOutputPort]

vtkActor aActor
aActor SetMapper aMapper
[aActor GetProperty] SetColor 1.0 0.0 0.0

vtkRenderer ren1
vtkRenderWindow renWin
 renWin AddRenderer ren1
 renWin SetSize 300 150

vtkRenderWindowInteractor iren
 iren SetRenderWindow renWin

ren1 SetBackground .1 .2 .4
ren1 AddActor aActor
ren1 ResetCamera

renWin Render

iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
wm withdraw .
########### end of code ##############





More information about the vtkusers mailing list