[vtkusers] get points of a cutter
Eddy Cappeau
ecappeau at phenix-systems.com
Fri Feb 5 11:32:48 EST 2010
You're rigth.
It works fine now.
Thanks.
Eddy
----
Date: Fri, 5 Feb 2010 10:15:53 +0000
From: KS Jothybasu<jothybasu at gmail.com>
Subject: Re: [vtkusers] get points of a cutter
To: David Doria<daviddoria+vtk at gmail.com>
Cc:vtkusers at vtk.org
Message-ID:
<1dd3c8b21002050215h6767849bqcc8b96d00512307a at mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
I am bale to get the points like this
cutter=vtk.vtkCutter()
cutter.SetCutFunction(plane)
cutter.SetInput(vtkObject.GetOutput())
cutter.Update()
out=cutter.GetOutput()
points=out.GetPoints()
NumPts=points.GetNumberOfPoints()
#print NumPts
OutlinePts=np.zeros([NumPts,3])
for n in range(0,NumPts,1):
OutlinePts[n,:]=np.round(points.GetPoint(n))
As David said, you have to call the Update method.
Jothy
On Thu, Feb 4, 2010 at 7:04 PM, David Doria
<daviddoria+vtk at gmail.com<daviddoria%2Bvtk at gmail.com>
> > wrote:
>
> >
> >
> > 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
> >
> > _______________________________________________
> > Powered bywww.kitware.com
> >
> > Visit other Kitware open-source projects at
> > http://www.kitware.com/opensource/opensource.html
> >
> > Please keep messages on-topic and check the VTK FAQ at:
> > http://www.vtk.org/Wiki/VTK_FAQ
> >
> > Follow this link to subscribe/unsubscribe:
> > http://www.vtk.org/mailman/listinfo/vtkusers
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:<http://www.vtk.org/pipermail/vtkusers/attachments/20100205/f9c8a11c/attachment-0001.htm>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100205/2604f82e/attachment.htm>
More information about the vtkusers
mailing list