[vtkusers] get points of a cutter

David Doria daviddoria+vtk at gmail.com
Thu Feb 4 14:04:38 EST 2010


On Thu, Feb 4, 2010 at 11:46 AM, Eddy Cappeau
<ecappeau at phenix-systems.com>wrote:

> 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.
> _____


Sounds like you need to call Update on the cutter
sliceCutter->Update();

Let me know if that works.

Thanks,

David
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100204/08e91ee0/attachment.htm>


More information about the vtkusers mailing list