[vtkusers] extract verticies from polydata

Mathieu Malaterre mmalat at imaging.robarts.ca
Wed Jul 17 16:10:43 EDT 2002


Hi Matt and Elizabeth,

Try this:

vtkIdType i;
float points[3];
vtkPoints* spolyPoints=spolys->GetPoints();

for (i=0; i<numcells; i++){
 spolyPoints->GetPoint(i, points);
}

HTH
mathieu

Matt and Elizabeth Kay wrote:

> Hi All-
>
> I have a vtkPolyData called 'spoly'. I would like to
> extract from spoly the vertex positions of each
> polygon in the dataset and save them in a float array
> called 'verticies'. Polygons are triangles. Here is a
> segment of my code:
>
> float **verticies;int i, numverts, numcells;
>
> vtkSphereSource *sphere = vtkSphereSource::New();
>    sphere->SetRadius(1);
>    sphere->Update();
>
> vtkPolyData *spoly=sphere->GetOutput();
> numverts=spoly->GetNumberOfPoints();
> numcells=spoly->GetNumberOfCells();
> verticies=(float **)malloc((unsigned
> int)numcells*sizeof(float*));
> for (i=0;i<numcells;++i){
>   verticies[i]=(float *)malloc(3*sizeof(float));}
> Now I want something like this, but of course this
> doesn't work:
>
> for (i=0;i<numcells;++i){
>   points[i][0] spoly->GetVertex(i,0);
>   points[i][1] spoly->GetVertex(i,1);
>   points[i][2] spoly->GetVertex(i,2);
> }
>
> Any suggestions?
>
> Thanks a ton,
> Matt
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.com
> _______________________________________________
> 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

--
If all else fail read the instructions
Malaterre, Mathieu
The John P. Robarts Research Institute
Imaging Research Laboratories
http://www.imaging.robarts.ca/~mmalat






More information about the vtkusers mailing list