[vtkusers] How to use display distance between two points of a cell

Elvis Dowson elvis.dowson at mac.com
Tue Oct 7 15:31:28 EDT 2008


Hi,
        I have the following tcl code which generates a simple  
triangle using an unstructured grid. How can I measure and display the  
distance between two points or point ids of the triangle (e.g. point 0  
and point 1)?

If I were to use vtkDistanceRepresentation2D, how can I pass the list  
of points directly to compute the distance between two points on the  
triangle and display it using an actor?

Best regards,

Elvis Dowson


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 .




More information about the vtkusers mailing list