[vtkusers] Accessing polygon vertices from SphereSource

Amy Henderson amy.henderson at kitware.com
Fri Jun 8 12:55:41 EDT 2001


You need to call sphere.Update() before you assign sphere.GetOutput() to 
poly.  You'll want to call poly.GetPoints() to get the points making up the 
sphere.

- Amy

At 05:32 PM 6/8/2001 +0000, Philip Cook wrote:
>On page 107 of the Shroeder book, there is some example code
>which shows a SphereSource object. The sphere is represented by
>a framework of polygons.
>
>I am attempting to access the polygon vertices that make up a
>SphereSource object, so that I might scale the position of each
>vertex in order to represent datapoints of an arbitrary spherical
>function. I have written the following Java code:
>
>   vtkSphereSource sphere = new vtkSphereSource();
>   sphere.SetRadius(5.0);
>   sphere.SetThetaResolution(18);
>   sphere.SetPhiResolution(18);
>
>   vtkPolyData poly = sphere.GetOutput();
>   vtkCellArray verts = poly.GetVerts();
>
>
>   System.out.println("points (poly) = " + poly.GetNumberOfPoints());
>   System.out.println("vertices (poly) = " +poly.GetNumberOfVerts());
>   System.out.println("cells (verts) = " + verts.GetNumberOfCells());
>   System.out.println("cells (poly) = " + poly.GetNumberOfCells());
>   System.out.println("lines (poly) = " + poly.GetNumberOfLines());
>   System.out.println("polys(poly) = " + poly.GetNumberOfPolys());
>
>When I run the program all these numbers come out to zero, so
>apparently there are no vertices to modify! But I can use sphere as
>input to a vtkPolyDataMapper and it displays the correct shape.
>Am I looking in the wrong place for the vertices?
>
>Thanks,
>
>
>Phil Cook
>
>
>
>_______________________________________________
>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://public.kitware.com/mailman/listinfo/vtkusers





More information about the vtkusers mailing list