[vtkusers] How to generate a surface normal glyph for a triangle cell
Elvis Dowson
elvis.dowson at mac.com
Tue Oct 7 15:34:24 EDT 2008
Hi,
How can I generate a simple surface normal glyph, for a
triangle cell. I just want to automatically compute the surface normal
and generate an arrow to represent the direction of the surface normal
for the triangle.
My tcl code for generating a triangle using unstructured grids is
shown below:
package require vtk
package require vtkinteraction
# Create several unstructured grids each containing a cell of a
different type.
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
vtkDataSetMapper aTriangleMapper
aTriangleMapper SetInput aTriangleGrid
vtkActor aTriangleActor
aTriangleActor SetMapper aTriangleMapper
aTriangleActor AddPosition 4 0 2
[aTriangleActor GetProperty] SetDiffuseColor .3 1 .5
# 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 aTriangleActor
ren1 ResetCamera
ren1 ResetCameraClippingRange
renWin Render
# render the image
#
iren AddObserver UserEvent {wm deiconify .vtkInteract}
iren Initialize
wm withdraw .
Best regards,
Elvis Dowson
More information about the vtkusers
mailing list