SV: [vtkusers] Get CellID

Tron Darvann trd at odont.ku.dk
Mon Dec 11 07:32:03 EST 2006


Hi Ricardo,

Maybe you can use this.

Tron

 

Snippet from simple code that computes cell center given polydata with triangles.

int i, pId;

float m[3];

double p0[3], p1[3], p2[3];

....

vtkPolyData *Source = reader->GetOutput();

// Get the points belonging to this cell i.

Source->GetCellPoints(i,cells);

// Put the three vertex coordinates in p0, p1, p2.

pId = cells->GetId(0);

points->GetPoint(pId,p0);

pId = cells->GetId(1);

points->GetPoint(pId,p1);

pId = cells->GetId(2);

points->GetPoint(pId,p2);

// Compute the cell center m.

m[0] = (p0[0] + p1[0] + p2[0]) / 3.0;

m[1] = (p0[1] + p1[1] + p2[1]) / 3.0; 

m[2] = (p0[2] + p1[2] + p2[2]) / 3.0; 

 

 
Tron Darvann
Research Engineer, PhD, 3D-Laboratory
 
Tel: (+45) 35 32 67 58 (lab) / (+45) 28 20 03 12 (mobile)
E-mail: trd at odont.ku.dk
Skype: tron.darvann
Fax: (+45) 35 32 65 05
Mailing and Visiting Address:
3D-Lab, School of Dentistry
University of Copenhagen
Nørre Alle 20
DK-2200 Copenhagen N
Denmark

________________________________

Fra: vtkusers-bounces+trd=odont.ku.dk at vtk.org på vegne af Secolas UA
Sendt: ma 11-12-2006 13:10
Til: vtkusers at vtk.org
Emne: [vtkusers] Get CellID



Hello!

 

I am doing an application that from an imported VRML Model I want to get cell information. I need to get the points that define the cell.

This is part of the code that I use to access the cells but I'm stuck because I don't know how to get the cellId for the GetCellPoints function.

      

...

polyData = (vtkPolyData* ) Act->GetMapper()->GetInput();

      int t = polyData->GetNumberOfPolys();

      cellArray = polyData->GetPolys();

      polyData->GetCellPoints(  pointList);

      ...

 

If anyone knows the best way to do this I would forever gratefull. Any other sugestions are very welcome too!

 

Best Regards

 

Ricardo Seco, University of Aveiro, Portugal

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20061211/cc33d5cf/attachment.htm>


More information about the vtkusers mailing list