[vtk-developers] Issue to get plane from vtkPlanes

Biddiscombe, John A. biddisco at cscs.ch
Tue Jul 12 10:33:15 EDT 2011


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.

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtk-developers/attachments/20110712/32b244bc/attachment.html>


More information about the vtk-developers mailing list