[Insight-developers] itkVector, itkPoint and vnl_vector

Luis Ibanez ibanez@cs.unc.edu
Thu, 04 Jan 2001 14:09:19 -0500


Bill Hoffman wrote:

> How do you do this without using virtual functions?
>
> >
> >  vnl_vector<T>
> >|
> >|-----> vnl_vector_dynamic<T>
> >|
> >|-----> vnl_vector_fixed<T,n>
> >

Oops !
The gosth of virtual functions strikes again    :-\

I'm afraid that this cannot be done by direct
derivation without using virtual functions and
paying for their overload...

-

One alternative is to expect all the classes
that use vnl_vector to be templated over
the vector type.   Which is after all the
design that we use now for   itkMesh.

Define a common "interface" to vnl_vector
and implement several independent vector types,
in a flat structure (that is, none of them deriving
from  vnl_vector)

for example:

vnl_vector_2D<T>
vnl_vector_3D<T>
vnl_vector_fixed<T,n>
vnl_vector_dynamic<T>

If they all respond to the same API, the classes
that use these vectors (and that are templated 
over them) will be able to interact with any 
of them.

One disadvantage is that everytingh should be
resolved at compile time.

Another disadvantage (maybe the worst one) is to 
have to modify all the classes that use vnl_vector 
(my guess is that vxl people will not be very 
happy with it)



Luis