[vtkusers] How do I output PolyData's points?

Matt Zumwalt mz108 at york.ac.uk
Tue Jul 8 16:51:32 EDT 2003


Thanks Amy.
    Possibly someone knows what I'm doing wrong in translating Amy's code from 
C++ to Tcl?  I've gotten the following error (tcl code included below):

	Error in startup script: Object named: sphere, could not find 
	requested method: GetPoints
	or the method was called with incorrect arguments.

	    while executing
	"sphere GetPoints"
 	   invoked from within
	"set points [sphere GetPoints]"
	    (file "PointsToArray.tcl" line 6)


This is what I've done in Tcl:

package require vtk

vtkSphereSource sphere 
 sphere SetThetaResolution 8
 sphere SetPhiResolution 8
set points [sphere GetPoints]
set numberOfPoints [sphere GetNumberOfPoints]

for {set i 0} {i < $numberOfPoints} {incr i} {
    set outarray($i) [points GetPoint $i]
}

Thanks again, 
MattZ

On Tuesday 08 July 2003 18:18, Amy Henderson wrote:
> At 07:04 PM 7/8/2003 +0000, Matt Zumwalt wrote:
> >Hi all,
> >     I'm trying to figure out how to generate a list containing the
> > coordinates
> >for all the points in a PolyData object.  I need to pass the list as
> >parameters to one of the methods in an external program.   I'm sure there
> >must be some simple way of doing this, but I can't figure it out.  Any
> > help would be greatly appreciated.
>
> The following should work:
>
> vtkPoints *points = polyData->GetPoints();
> int numPts = polyData->GetNumberOfPoints();
> int i;
>
> float **ptArray = new float[numPts][3];
>
> for (i = 0; i < numPts; i++)
> {
> points->GetPoint(i, ptArray[i]);
> }
>
> - Amy
>
> >thanks,
> >  Matt Z
> >_______________________________________________
> >This is the private VTK discussion list.
> >Please keep messages on-topic. Check the FAQ at:
> ><http://public.kitware.com/cgi-bin/vtkfaq>
> >Follow this link to subscribe/unsubscribe:
> >http://www.vtk.org/mailman/listinfo/vtkusers

-- 
---------------------
MSc Candidate
Programme in Music Technology
Department of Electronics
University of York



More information about the vtkusers mailing list