[vtkusers] boundary cells
David Doria
daviddoria at gmail.com
Mon Aug 13 12:16:47 EDT 2012
On Mon, Aug 13, 2012 at 12:10 PM, Gonzalo Amadio
<gonzaloamadio at gmail.com> wrote:
> Hello, I am trying to extract boundary cells of a polydata. I've used
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/BoundaryEdges to extract
> boundary edges.
>
> Then I looked to this example :
> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Tcl/capSphere.tcl?root=VTK&content-type=text/plain
> to extract the cells.
>
> But when I print the result polydata data , gives me an error.
>
>> vtkSmartPointer<vtkFeatureEdges> boundaryEdges =
>> vtkSmartPointer<vtkFeatureEdges>::New();
>> boundaryEdges->SetInput(myPolyData);
>> boundaryEdges->BoundaryEdgesOn();
>> boundaryEdges->FeatureEdgesOff();
>> boundaryEdges->ManifoldEdgesOff();
>> boundaryEdges->NonManifoldEdgesOff();
>> boundaryEdges->Update();
>>
>>
>>
>> vtkSmartPointer<vtkCleanPolyData> boundaryClean =
>> vtkSmartPointer<vtkCleanPolyData>::New();
>> boundaryClean->SetInput(boundaryEdges->GetOutput());
>>
>>
>> vtkSmartPointer<vtkStripper> boundaryStrips =
>> vtkSmartPointer<vtkStripper>::New();
>> boundaryStrips->SetInput(boundaryClean->GetOutput());
>> boundaryStrips->Update();
>>
>>
>>
>> vtkSmartPointer<vtkPolyData> boundaryPoly =
>> vtkSmartPointer<vtkPolyData>::New();
>> boundaryPoly->SetPoints((boundaryStrips->GetOutput())->GetPoints());
>> boundaryPoly->SetPolys((boundaryStrips->GetOutput())->GetLines());
>>
>>
>>
>> vtkSmartPointer<vtkTriangleFilter> boundaryTriangles =
>> vtkSmartPointer<vtkTriangleFilter>::New();
>> boundaryTriangles->SetInput(boundaryPoly);
>>
>>
>>
>> vtkSmartPointer<vtkPolyData> boundaryTrianglesPD =
>> boundaryTriangles->GetOutput();
>>
>>
>>
>> std::cout << "cell " << boundaryTrianglesPD->GetNumberOfCells() <<
>> std::endl; // gives me 0
>> std::cout << "lines " <<
>> boundaryTrianglesPD->GetLines()->GetNumberOfCells() << std::endl;
>> //gives me 0
>> std::cout << "points " <<
>> boundaryTrianglesPD->GetPoints()->GetNumberOfPoints() << std::endl; //
>> crash here
>
>
> Can someone help me?
>
> Thank you!
>
> --
> --------
> Gonzalo Amadio
You need to call boundaryTriangles->Update() before
boundaryTriangles->GetOutput() if you're going to use it like this.
David
More information about the vtkusers
mailing list