[vtkusers] get points of a cutter

Eddy Cappeau ecappeau at phenix-systems.com
Thu Feb 4 11:46:20 EST 2010


Hi,

I'm new to VTK and I'v got a little problem with it.
I want to cut a mesh with a plane and get the polyline of the intersection.
The mesh come from a stl file loaded like this :

     vtkSmartPointer<vtkSTLReader> reader = 
vtkSmartPointer<vtkSTLReader>::New();
     reader->SetFileName("myfile.stl");

     vtkSmartPointer<vtkPolyDataMapper> stlMapper = 
vtkSmartPointer<vtkPolyDataMapper>::New();
     stlMapper->SetInputConnection(reader->GetOutputPort());

I create a cutter like this :

     vtkCutter * sliceCutter = vtkCutter::New();
     sliceCutter->SetInput( reader->GetOutput() );
     vtkPlane *slicePlane = vtkPlane::New();
     slicePlane->SetOrigin(0.0,0.0,7.0);
     slicePlane->SetNormal(0.0,0.0,1.0);

     sliceCutter->SetCutFunction( slicePlane );

I'v created a mapper and an actor for the mesh and the section, and i 
can visualize them both.

So I try to retrieve the points like this :

     vtkPolyData * testdata = sliceCutter->GetOutput();
     vtkPoints * points = sliceCutter->GetOutput()->GetPoints();
     int n = points->GetNumberOfPoints();

But the vtkPoints is always NULL and  I don't understand why.
How can I get those points ?

thanks.



More information about the vtkusers mailing list