[vtkusers] Polygon triangulation (vtkPolygon::Triangulate)

polys_poly at hotmail.com polys_poly at hotmail.com
Sat Feb 16 12:10:16 EST 2008


I am trying to triangulate a polygon?

My code is this:

polygonPoints  = vtkPoints::New();
polygon = vtkPolygon::New();

polygonPoints ->SetNumberOfPoints(8);
polygon->GetPointIds()->SetNumberOfIds(8);
 
polygonPoints->InsertPoint(0, 0, 0, 0);
polygonPoints->InsertPoint(1, 1, 0, 0);
polygonPoints->InsertPoint(2, 1, 1, 0);
polygonPoints->InsertPoint(3, 0, 1, 0);

polygon->GetPointIds()->SetId(0, 0);
polygon->GetPointIds()->SetId(1, 1);
polygon->GetPointIds()->SetId(2, 2);
polygon->GetPointIds()->SetId(3, 3);

I found out that vtkPolygon has a function named Triangulate 

int vtkPolygon::Triangulate  (vtkIdList * outTris)    
Triangulate this polygon. The user must provide the vtkIdList outTris. On output, the outTris list contains the ids of the points defining the triangulation. The ids are ordered into groups of three: each three-group defines one triangle. 

I 've tried this:

polygon->Triangulate(polygon->PointIds); 

but get exception

int vtkPolygon::Triangulate (int index,vtkIdList* ptIds, vtkPoints* pts)

I also tried this:

polygon->Triangulate(1, polygon->PointIds, polygonPoints);

and get exception error too.

I could really use your help

Thanks in advance,
Polys
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080216/c320ea28/attachment.htm>


More information about the vtkusers mailing list