[vtkusers] newbie question - drawing a line!
Sylvain Jaume
sylvain.jaume at kitware.com
Mon Nov 7 09:17:09 EST 2005
Hi Anusha,
Did you allocate memory for your cells?
You could do this:
line Allocate [expr 1 + $numPoints]
line InsertNextCell $numPoints
for {set i 0 } { $i < $numPoints} { incr i } {
line InsertCellPoint $i
}
Cheers,
Sylvain
Anusha wrote:
> 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
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages
> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list