[Insight-developers] Reducing template depth
Luis Ibanez
ibanez@choroid.cs.unc.edu
Fri, 29 Jun 2001 10:34:37 -0400 (EDT)
Lydia's findings are quite illuminating !
It seems that some de-Templating would be
a good idea at this point.
Here are the template dependencies for
the registration framework :
Transform
Mapper<Transform,ReferenceImage>
Metric<Mapper,TargetImage,Measure,Derivative>
Optimizer<Metric>
Currently optimizers are templated over the
Cost function (the metric). That makes sense if
the evaluation of the cost function can be inlined,...
but for registration every evaluation is so long
that using virtual functions will be just fine.
Optimizers can be modified to use the same style
vnl_optimizer use, that is to expect a pointer to
a cost_function class that derives from a common
base_cost_function class. That is, all the Metrics
should derive from a common non-templated class
that defines the interface for a cost function.
The group of Transform,Mapper,Metric could be
detemplated if we step back on itkPoints and
use vnl_points that are dynamic in dimension.
Transforms are templated in order to be of
variable dimension (in the input and output
spaces). If vnl_points are used, templates can
be removed at the price of checking dimensions
each time a point is pass as parameter to a function.
It Transforms are detemplated, Mappers could remove
Tranforms as template parameter (and only keep
the reference image).
Metrics will stil have to be templated over Reference
Image and Target Image.
---
The question at some point is how much should be
squeeze the design of frameworks, if they are
responsible for less of 50% of the template depth ?
and how much that will cost in functionality and
maintenance effort.
Luis