LJ Archive

Listing 2. Code to Connect Nodes to Build Mesh

vtkRenderWindow renwin
vtkRenderer ren
vtkRenderWindowInteractor iren
vtkPolyData mesh
vtkFloatPoints points
vtkCellArray cells
points InsertPoint 0 0 0 0
for {set i 1} {$i <= $nverts} {incr i} {
 points InsertPoint $i $xk($i) $yk($i) $zk($i)
}
for {set i [expr $ifirst]} {$i <= $nverts} \
   {incr i} {
 if {$fk($i) > 0} {
    set p1 $i1tab($i)
    set p2 $i3tab($i)
    set p3 $i8tab($i)
   set len [expr hypot($xk($p1)-$xk($i),\
   hypot($zk($p1)-$zk($i),$yk($p1)-$yk($i)))]
   if {$len < $minlen} {set minlen $len; \
    set mini $i}
# (do for p2 and p3) (snipped)
   if {$len < $minlen} {set minlen $len;\
    set mini $i}
    cells InsertNextCell 2
    cells InsertCellPoint $i
    cells InsertCellPoint $p1
    cells InsertNextCell 2
    cells InsertCellPoint $i
    cells InsertCellPoint $p2
    cells InsertNextCell 2
    cells InsertCellPoint $i
    cells InsertCellPoint $p3
 }
}
mesh SetPoints points
mesh SetLines cells
points Delete
cells Delete
vtkPolyDataMapper mapper
mapper SetInput mesh
vtkSphereSource sphere
eval sphere SetCenter [mesh GetPoint $mini]
sphere SetRadius 1.0
vtkPolyDataMapper spheremap
spheremap SetInput [sphere GetOutput]
vtkActor sphact
sphact SetMapper spheremap
vtkLODActor meshactor
meshactor SetMapper mapper
ren AddActor sphact
ren AddActor meshactor
renwin AddRenderer ren
iren SetRenderWindow renwin
iren Initialize
LJ Archive