[vtkusers] Add a plan to a vtkPolyData

David Doria daviddoria+vtk at gmail.com
Wed Jan 27 10:16:57 EST 2010


On Wed, Jan 27, 2010 at 10:12 AM, Frantch <le_maitre at bluewin.ch> wrote:
>
> Hello everybody,
>
> I would like to know how can I add a plane to a polydata ? because ehre what
> I'm trying to do:
>
> I have a PolyData that I clip using vtkClipPolyData (clipping function = ONE
> plane). I manage to clip it and to display the clipped part. Unfortunately
> this clipped polydata
> has a missing plane... (the one who has been used to clip..) So as I result
> I don't have a close polydata and.. it make wrong the calculation that I'm
> doing after..
>
> So here what I did to create the missing plane: I use vtkCutter but
> vtkCutter creates lines where the cut function intersects the polydata. So I
> will use
> vtkStrippers then to puts them together into polylines. I then pull a trick
> and define polygons using the closed line segements that the stripper
> created..
>
> vtkCutter * cutEdges = vtkCutter::New();
>
> cutEdges->SetInput(myPolyData);
> cutEdges->SetCutFunction(plane);
> cutEdges->GenerateCutScalarsOn();
> cutEdges->SetValue(0, 0.5);
>
> vtkStripper * cutStrips = vtkStripper::New();
>
>
> cutStrips->SetInputConnection(cutEdges->GetOutputPort());
> cutStrips->Update();
> vtkPolyData * cutPoly = vtkPolyData::New();
> cutPoly->SetPoints(cutStrips->GetOutput()->GetPoints());
> cutPoly->SetPolys(cutStrips->GetOutput()->GetLines());
>
> // Triangle filter is robust enough to ignore the duplicate point at
> // the beginning and end of the polygons and triangulate them.
> vtkTriangleFilter * cutTriangles = vtkTriangleFilter::New();
> cutTriangles->SetInput(cutPoly);
> cutTriangles->Update();
>
> so cutTriangles is my missing plane.. How can I add that to my clipped
> polyData ?
>
> Regards,
> Francesco

If I read that correctly, the problem boils down to simply wanting to
combine two polydata's, correct? If so, you can use the
vtkAppendPolyDataFilter:
http://www.vtk.org/Wiki/VTK/Examples/CombinePolydata

Let us know if that does what you need.

Thanks,

David



More information about the vtkusers mailing list