[vtkusers] BoxWidget + VolumeMapper errors

David Gobbi dgobbi at imaging.robarts.ca
Thu May 27 16:07:26 EDT 2004


On Thu, 27 May 2004, Mathieu Malaterre wrote:

> David Gobbi wrote:
> > Hi Dean,
> >
> > The old "GetPlane() always returns the same object" kind of problem
> > is pervasive in VTK.
> >
> > A vtkPlanes object has exactly one Plane, and when you call GetPlane(i),
> > it simply sets the Normal and Origin of that plane as appropriate, and
> > then returns it.  This is what caused the problem you were seeing.
> >
> > Digging a bit deeper, this problem did not occur in VTK 4.2, since back
> > then GetPlane() would create a new plane via vtkPlane::New(), and then
> > return that new plane after setting the Origin and Normal.  Of course,
> > returning a New'ly created object results in a memory leak.
> >
> > The solution would be for vtkPlanes to have a different internal plane
> > for each index i (any volunteers?).
>
> Since, I did the mistake of fixing the mem leak, I'll fix it. Thanks for
> the explanation.
>
> http://vtk.org/Bug/bug.php?op=show&bugid=888
>
> Mathieu

I hate to impose, but when you do the fix, can you also add a "safe"
method

  void GetPlane(int i, vtkPlane *plane);

which will set up the plane with the correct origin & normal?  Many other
VTK objects take exactly this approach, to avoid the sorts of problems
that Dean saw with vtkPlanes.

 - David




More information about the vtkusers mailing list