[vtkusers] newbie question - drawing a line!
Anusha
ats36 at cam.ac.uk
Sun Nov 6 12:29:41 EST 2005
Hi,
I'm trying to draw lots of raypaths on a 3-D model I've created by
plotting a lines joining up the multiple points which define these
paths. I am sure it is a very trivial thing to do and that I'm making
a basic mistake somewhere but have been grappling with it for a while
and but can't seem to to make it work so any help/suggestions would be
much appreciated! Am I on the right track - should I be trying to turn
the set of points into cells or should my data be defined as lines in
the data file to begin with?
Many thanks!
Anusha
My data set is a set of x,y,z grid points and looks like...
# vtk DataFile Version 2.0
Ray paths
ASCII
DATASET POLYDATA
POINTS 143088 float
21.3300 50.9900 -0.0241
21.3300 50.9900 -0.0241
21.3300 50.9900 -0.0328
21.3300 50.9900 -0.0327
....etc
and this is the chunk of code I've been attempting to make work (but
get an error when trying to get the output of the vtkPolyData "rays" in
the vtkPolyDataReader.)
vtkPolyDataReader raysReader
raysReader SetFileName "rays.vtk"
vtkPolyData rays
vtkPoints points
vtkCellArray line
set numPoints [[raysReader GetOutput] GetNumberOfPoints]
for {set i 0 } { $i < $numPoints} { incr i } {
set val [[raysReader GetOutput] GetPointData]
points InsertPoint $i $i $val
}
rays SetPoints points
points Delete
line InsertNextCell $numPoints
for {set i 0 } { $i < $numPoints} { incr i } {
line InsertCellPoint $i
ptIds[1] =
}
rays SetLines line
line Delete
vtkPolyDataMapper mapRays
mapRays SetInput [rays GetOutput]
vtkActor raysActor
raysActor SetMapper mapRays
More information about the vtkusers
mailing list