[vtkusers] get points of a cutter
Bill Lorensen
bill.lorensen at gmail.com
Fri Feb 5 08:15:56 EST 2010
Also, if you want the polylines to be continuous look at this example:
http://vtk.org/Wiki/VTK/Examples/ExtractPolyLinesFromPolyData
On Fri, Feb 5, 2010 at 5:15 AM, KS Jothybasu <jothybasu at gmail.com> wrote:
> 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>
> 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 by www.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
>>
>
>
> _______________________________________________
> Powered by www.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
>
>
More information about the vtkusers
mailing list