[vtkusers] Creating a polygon from a closed polyline !

Sebastien Auclair sxa at fluent.com
Tue Feb 11 16:55:55 EST 2003


Greetings !

We need to generate a surface out of 2D closed polylines.
Like if we have a circle as a polyline and all the points have z = 0 (i.e.
2D polyline), we need to generate a surface for this circle to be displayed
as a disk !
Of course, some of our polylines do not form easy convex polygones. But they
are always composed with points with z = 0.


So far we've tried this without success :

(the code before the next line was trivial so not pasted...)
................................................
 int pointCount = points->GetNumberOfPoints ();  //  points is a valid
vtkPoints
 int i;

 vtkPolyLine* aPolyline = vtkPolyLine::New();
 aPolyline->GetPointIds()->SetNumberOfIds(pointCount);
 for (i = 0; i <  pointCount; i++){
        aPolyline->GetPointIds()->SetId( i, i);
 }

 vtkUnstructuredGrid* aGrid = vtkUnstructuredGrid::New();
 aGrid->Allocate(1,1 );
 aGrid->InsertNextCell (aPolyline->GetCellType(),
aPolyline->GetPointIds());
 aGrid->SetPoints( points->m_points);
 aGrid->Update();

 vtkGeometryFilter* filter = vtkGeometryFilter::New();
 filter->SetInput(aGrid);
 filter->Update();


 vtkTriangleFilter* tri = vtkTriangleFilter::New();
 tri->SetInput(filter->GetOutput());
 tri->Update();
 vtkStripper* strip = vtkStripper::New();
 strip->SetInput(tri->GetOutput());
 strip->Update();
...........................................................
The rest of the code is trivial !


Any suggestions ?

Thanks

_______________________________________________
Seb




More information about the vtkusers mailing list