[vtkusers] Urgent!Please help!!!

ravi kiran vcravikiran at hotmail.com
Sun Oct 13 06:23:50 EDT 2002


hi,
I have tetrahedralized a cube of 11*11*5 points. The following code 
tetrahedralizes the cube. But, i am having a hard time generating a file 
that represents each cell with its coordinates. Can anyone help me modify 
this code to generate a file that gives me the coordinates of each cell that 
is tetrahedralized.Please help me as it is urgent.
Thanks in advance.
Ravi

catch {load vtktcl}
set VTK_DATA "../vtkdata"
set VTK_TCL  ".."

# include get the vtk interactor ui
source $VTK_TCL/vtkInt.tcl

set x [list 0 100 200 300 400 500 600 700 800 900 1000]
set y [list 0 100 200 300 400 500 600 700 800 900 1000]
#set z [list 0 100 200 300 400 500 600 700 800 900 1000]
set z [list 0 100 200 300 400 500]

# create a vtkPoints object to contain a list of points
vtkPoints points

set fileid [open "MARS.txt" w+]
seek $fileid 0 start
puts $fileid "Sl X Y Z"
set l 0
# using InsertNextPoint, you don't have to number the vertices
for {set i 0} {$i < [llength $x]} {incr i} {
    for {set j 0} {$j < [llength $y]} {incr j} {
	for {set k 0} {$k < [llength $z]} {incr k} {
	   points InsertNextPoint [lindex $x $i] [lindex $y $j] [lindex $z $k]
	   puts $fileid "$l [lindex $x $i] [lindex $y $j] [lindex $z $k]"
	   set l [expr $l + 1]
	}
    }
}
close $fileid

vtkUnstructuredGrid pSet
    pSet SetPoints points

vtkPolyData profile
    profile SetPoints points

# triangulate them
#
vtkDelaunay3D del
    del SetInput profile
    del BoundingTriangulationOff
    del SetTolerance 100
    del SetAlpha 0
    del SetInput profile

vtkShrinkFilter shrink
    shrink SetInput [del GetOutput]
    shrink SetShrinkFactor 0.98

# Transform And Transform Filter Were Used To Scale The Height Field
vtkTransform delT
    delT Identity

vtkTransformFilter delTF
    delTF SetTransform delT
    delTF SetInput [shrink GetOutput]
    delT Scale 1.0 1.0 1.0

vtkExtractUnstructuredGrid gridCell
    gridCell SetInput [delTF GetOutput]


vtkDataSetMapper map
    map SetInput [gridCell GetOutput]

vtkActor triangulation
    triangulation SetMapper map
    [triangulation GetProperty] SetColor 0 0 1

# Build the prop assembly out of a vtkActor and a vtkAssembly
vtkPropAssembly assembly
  assembly AddPart triangulation

# Create the RenderWindow, Renderer and both Actors
#
vtkRenderer ren1
vtkRenderWindow renWin
    renWin AddRenderer ren1
vtkRenderWindowInteractor iren
    iren SetRenderWindow renWin

# Add the actors to the renderer, set the background and size
#
ren1 AddProp assembly
ren1 SetBackground 0 0 0
renWin SetSize 2000 2000

set cam1 [ren1 GetActiveCamera]
$cam1 Zoom 1.0
$cam1 Elevation -45

# Get handles to some useful objects
#
iren SetUserMethod {wm deiconify .vtkInteract}
iren Initialize
renWin Render

# prevent the tk window from showing up then start the event loop
wm withdraw .



_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com




More information about the vtkusers mailing list