[Insight-developers] Removing SpatialOrientation stuff
from itk::ImageBase
Kent Williams
norman-k-williams at uiowa.edu
Mon Sep 12 10:12:52 EDT 2005
I knew that partial specialization isn't really feasible, but it would
have been optimal.
I'm not clear about how making the Orientation a trait of the class
would work. The problem with templating just over image dimension, is
that what we want here is a conversion from Direction Cosines to a data
type, but with the same base function signature:
template <class T, unsigned int Dimension = 3>
class OrientationAdapter
{
public:
T FromDirectionCosines(const typename
ImageBase<Dimension>::DirectionType &dir);
ImageBase<Dimension>::DirectionType ToDirectionCosines
ToDirectionCosines(const T &Orienatation);
};
Perhaps a better solution in this context would be to use inheritance
from a template base to approximate the 'ideal' template solution:
template <class T, unsigned int Dimension = 3>
class OrientationAdapterBase
{
public:
virtual T FromDirectionCosines(const typename
ImageBase<Dimension>::DirectionType &dir) = 0
virtual ImageBase<Dimension>::DirectionType ToDirectionCosines
ToDirectionCosines(const T &Orienatation) = 0
};
template <int Dimension>
class SpatialOrientationAdapter : public
OrientationAdapterBase<SpatialOrientation::ValidCoordinateOrientationFlags,
Dimension>
{
public:
typedef typename SpatialOrientation::ValidCoordinateOrientationFlags
OrientationType;
typedef typename ImageBase<Dimension>::DirectionType DirectionType;
virtual OrientationType FromDirectionCosines(DirectionType &dir);
virtual DirectionType ToDirectionCosines(const OrientationType &Or);
}
Luis Ibanez wrote:
>
> Hi Kent,
>
> As long as we support VC++ 6.0 we cannot do any partial specialization.
>
> This fact is unfortunate, and it has prevented us from doing a lot of
> cool MetaProgramming... so we look forward to the day when we can drop
> the support for Visual C++ 6.0.
>
> In the meantime,... looking at your code, it seems that we don't
> really need to template the class OrientationAdapter over:
>
> 1) OrientationRepresentation
> 2) ImageDimension
>
> Instead, I would suggest to only template it over ImageDimension
> and to make OrientationRepresentation to be a trait of the
> specialization of OrientationAdapter.
>
> The drawback of this approach is that it will only allow one
> OrientationRepresentation per image dimension.
>
> From the developers point of view this may not be too bad,
> since in their applications they could create a variation of
> the OrientationAdapter, that has in its traits a different
> definition of the OrientationRepresentation.
>
> I would guess that in the typical uses of the orientation
> representation we don't need to switch from one representation
> to another.
>
> Do you see other drawbacks in moving the OrientationRepresentaiton
> from being a template argument to being an internal trait ?
>
>
>
> My 2 cents,
>
>
> Luis
>
>
>
> ------------------------
> Kent Williams wrote:
>
>> My proposal for removing SpatialOrientation stuff from itk::ImageBase
>> (scroll to the bottom):
>>
>> http://www.itk.org/Wiki/Proposals:Orientation#Cosine_Direction_Vectors.2C_and_itk::SpatialOrientation_.28Kent_Williams.29
>>
>>
>> In summary, the conversion betwee SpatialOrientation and Direction
>> Cosines is moved to a template 'helper' class. I'm open to
>> discussions/suggestions on whether this is the way to go -- the
>> drawback to the scheme presented is that it requires partial template
>> specialization to handle general N-dimensional orientation
>> representations elegantly.
>>
>> _______________________________________________
>> Insight-developers mailing list
>> Insight-developers at itk.org
>> http://www.itk.org/mailman/listinfo/insight-developers
>>
>>
>
More information about the Insight-developers
mailing list