[vtk-developers] Issue to get plane from vtkPlanes

David Cole david.cole at kitware.com
Tue Jul 12 12:40:51 EDT 2011


On Tue, Jul 12, 2011 at 10:33 AM, Biddiscombe, John A. <biddisco at cscs.ch> wrote:
> is really a question for the users list, but the answer is actually written
> in the header file.
>
>
>
> if you look at the doc
>
>   // Description:
>
>   // Create and return a pointer to a vtkPlane object at the ith
>
>   // position. Asking for a plane outside the allowable range returns NULL.
>
>   // This method always returns the same object.
>
>   // Use GetPlane(int i, vtkPlane *plane) instead
>
>   vtkPlane *GetPlane(int i);
>
>   void GetPlane(int i, vtkPlane *plane);
>
>
>
> you can see that the same object is used every time and so your pointers are
> the same. so use GetPlane(...) instead, where a new object is created for
> you.

I'm pretty sure to use that 2nd signature where you pass in a
"vtkPlane *" that you have to create a vtkPlane object to pass in
before you make the call. You create it, the call fills it in for you,
then you delete it when you're done with it.


>
>
>
> you must delete the extra objects when you’re done with them.
>
>
>
> JB
>
>
>
> From: vtk-developers-bounces at vtk.org [mailto:vtk-developers-bounces at vtk.org]
> On Behalf Of Laurent Chauvin
> Sent: 12 July 2011 16:25
> To: vtk-developers at vtk.org
> Subject: [vtk-developers] Issue to get plane from vtkPlanes
>
>
>
> Hello,
>
> I was using vtkPlanes, and I needed to retrieve 2 planes (number 4 and 5).
>
> When I was using:
>
> planes->GetPlane(5) and planes->GetPlane(4)
>
> and using this as argument for clipping, like this:
>
> clip->SetClipFunction(planes->GetPlane(5));
> clip2->SetClipFunction(planes->GetPlane(4));
>
> But, when I was not doing clip2, everything was working good, but after
> adding clip2, my first clip changed and become the same as the clip2.
>
> So, I try this insted:
>
> vtkPlane* plane1 = vtkPlane::New();
> planes->GetPlane(4, plane1);
>
> vtkPlane* plane2 = vtkPlane::New();
> planes->GetPlane(5, plane2);
>
> clip->SetClipFunction(plane1);
> clip2->SetClipFunction(plane2);
>
> And it works.
> I don't really understand. Is there shared memory in these classes
> (vtkPlanes, vtkClipPolyData) ?
> I was thinking the vtkClipPolyData output was shared, so the clip2 write in
> the same place than the clip, which could explain why they are the same
> after second clipping.
>
> Thank you.
> Laurent.
>
>
> --
>
> Laurent Chauvin, MS
>
> Surgical Planning Laboratory, Radiology
>
> Brigham And Women's Hospital, Harvard Medical School
>
> http://wiki.ncigt.org/index.php/User:Lchauvin
>
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtk-developers
>
>
>



More information about the vtk-developers mailing list