[vtk-developers] vtkPlane DeepCopy?
David Gobbi
david.gobbi at gmail.com
Sat Dec 5 17:14:02 EST 2009
On Sat, Dec 5, 2009 at 3:00 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
> On Sat, Dec 5, 2009 at 4:38 PM, David Doria <daviddoria+vtk at gmail.com> wrote:
>> Is there a reason vtkPlane doesn't have a copy function? I.e. if I
>> write one can we add it?
>>
>> Thanks,
>>
>> David
>
> I see. I was just trying to make it more usable. I am writing a RANSAC
> plane class so at every iteration CurrentPlane should be copied into
> BestPlane if it is indeed the best plane so far. It seemed awkward to
> have to get/set the normal and origin.
>
> For the same reason, it would also be nice to have
> double dist = plane->DistanceToPoint(double[3]);
>
> instead of:
> double n[3];
> double o[3];
> plane->GetNormal(n);
> plane->GetOrigin(o);
> double dist = vtkPlane::DistanceToPlane(point, n, o);
Oh, there's a reason for that too. I mean specifically, there's a
reason for all these static computational methods in VTK. VTK objects
are "heavy". You shouldn't create a VTK object just to do things like
distance-to-plane computations.
Instead, you should just create C array for the normal and origin for
each plane you need. Or, create your own lightweight object.
class myplane
{
public:
double normal[3];
double origin[3];
};
vtkPlane::DistanceToPlane(point, plane.normal, plane.origin);
Take a look at vtkObject and vtkObjectBase and you will see how
"heavy" these classes are. All vtkObjects support reference counting,
observers, wrapping, etc, etc. If you just need to store 6 numbers,
don't use a vtkPlane.
Just my 2 cents.
David
More information about the vtk-developers
mailing list