[vtkusers] Accessing polygon vertices from SphereSource

Philip Cook pacook at blueyonder.co.uk
Fri Jun 8 13:32:16 EDT 2001


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






More information about the vtkusers mailing list