[vtkusers] Filter to merge several lines into a single polyline?

Amy Henderson amy.henderson at kitware.com
Tue May 11 16:45:50 EDT 2004


At 04:39 PM 5/11/2004, Jean-Dominique Barnichon wrote:
>It's done already (see code of original message)
>Jean-Do

Sorry; didn't read far enough before.
- Amy

>-----Message d'origine-----
>De : Amy Henderson [mailto:amy.henderson at kitware.com]
>Envoye : mardi 11 mai 2004 22:09
>A : Jean-Dominique Barnichon; vtkusers
>Objet : Re: [vtkusers] Filter to merge several lines into a single
>polyline?
>
>
>Hi Jean-Do,
>
>Try passing the results of vtkCutter through vtkStripper.
>
>- Amy
>
>At 04:04 PM 5/11/2004, Jean-Dominique Barnichon wrote:
> >Hello,
> >
> >As a result of applying a vtkCutter filter to a 3D surface (see code
>snippet
> >below), I obtain a vtkPolyData object that is made of :
> >  - a set of points,
> >  - a set of lines (7 in the example below, see ouput below).
> >
> >You can notice that output lines share end points, i.e. they could 'easily'
> >all be converted into a single polyline (in the exmaple shown below, this
> >could be done starting backward from the last line, but I don't known this
> >can always be done this way).
> >
> >All I need is converting this set of 'jointive' lines into a single
> >polyline.
> >Is there any filter that can do that? Or do I have to write one by myself?
> >
> >Any answer/hint is welcome.
> >Note that applying vtkCleanPolyData is pointless here as there are already
> >no duplicate points.
> >
> >Jean-Do
> >
> >
> >code snippet
> >         //Define cutting plane
> >         vtkPlane* plane = vtkPlane::New();
> >         plane->SetOrigin(300., 500., 0);
> >         plane->SetNormal(-1, -1, 0);
> >
> >         //Generate cut lines
> >         vtkCutter* cutEdges = vtkCutter::New();
> >         cutEdges->SetInput(Normals->GetOutput());
> >         cutEdges->SetCutFunction(plane);
> >
> >         //Forms lines from cutter
> >         vtkStripper* cutStrips = vtkStripper::New();
> >         cutStrips->SetInput(cutEdges->GetOutput());
> >         cutStrips->Update();
> >
> >         //Defines polygons as polyline
> >         vtkPolyData* LinePoly = vtkPolyData::New();
> >         LinePoly->SetPoints((cutStrips->GetOutput())->GetPoints());
> >         LinePoly->SetLines((cutStrips->GetOutput())->GetLines());
> >
> >         //Write PolyData to file
> >         vtkPolyDataWriter* wr = vtkPolyDataWriter::New();
> >         wr->SetFileName("Line4.vtk");
> >         wr->SetInput(LinePoly);
> >         wr->Write();
> >
> >Output of the vtkPolyDataWriter (file Line4.vtk)
> ># vtk DataFile Version 3.0
> >vtk output
> >ASCII
> >DATASET POLYDATA
> >POINTS 28 float
> >252.329 547.171 500 235.668 563.832 500 314.825 484.675 549.214
> >305.908 493.592 553.277 224.208 575.292 500 223.112 576.388 500
> >342.103 457.397 590.352 339.985 459.515 587.917 446.203 353.297 737.623
> >441.629 357.871 700 294.445 505.055 542.116 343.253 456.247 592.317
> >415.885 383.615 664.838 409.217 390.283 664.838 350.938 448.562 600
> >426.08 373.42 670.902 439.236 360.264 700 492.288 307.212 866.422
> >482.154 317.346 884.873 458.735 340.765 779.183 451.048 348.452 750.164
> >479.711 319.789 887.034 463.563 335.937 800 512.234 287.266 900
> >510.437 289.063 900 496.357 303.143 851.732 502.247 297.253 829.042
> >519.514 279.986 900
> >LINES 7 41
> >4 0 1 4 5
> >4 2 3 10 0
> >3 6 7 2
> >9 8 9 16 15 12 13 14 11 6
> >7 17 18 21 22 19 20 8
> >5 23 24 26 25 17
> >2 27 23
> >
> >CELL_DATA 7
> >POINT_DATA 28
> >
> >
> >_______________________________________________
> >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://www.vtk.org/mailman/listinfo/vtkusers






More information about the vtkusers mailing list