[vtkusers] Creating a polygon from a closed polyline !

Sébastien MARAUX maraux at ondim.fr
Wed Feb 12 04:46:06 EST 2003


Hello,

it is possible to do it via creation of new polygon cells in
place of polylines ones, and calling tesselate on it.

pseudo code :

new vtkPolydata,
new temp cell (contains polygon)
newpolydata SetPoints(yourpolydata GetPoints)
for all polyline cells{
    reset temp Cell
    for all points of this poly {
        if first, store
        add point id to cell
    }
    add first stored id (to close polygon)
    add cell to your poly
}
newpolydata Tesselate

I don't have the time to tell you more, sorry

good luck

Seb

----- Original Message -----
From: "Sebastien Auclair" <sxa at fluent.com>
To: <vtkusers at public.kitware.com>
Sent: Tuesday, February 11, 2003 10:55 PM
Subject: [vtkusers] Creating a polygon from a closed polyline !


> 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
>
> _______________________________________________
> 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
>




More information about the vtkusers mailing list