[vtkusers] Polygon triangulation using vtkPolugon::Triangulate

polys_poly at hotmail.com polys_poly at hotmail.com
Sat Feb 23 08:26:18 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 (int index,vtkIdList* ptIds, vtkPoints* pts)

I tried this:

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

and get exception error.

What do i do wrong?

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


More information about the vtkusers mailing list