[Insight-developers] Questions on Program Style/Design Functors/Function Parameters

Kent Williams norman-k-williams at uiowa . edu
Thu, 29 May 2003 16:53:55 -0500


So I've got a working version of my Octree template class working.=20
Functionality includes:

1. templated over Pixel type, and size of the Color Table.
2. requires user-defined Pixel mapping function.
3. Tree can be generated from itk::Image.
4. itk::Image can be generated from the Octree.

I'm converting some code from Brains2 that will generate an=20
itk::PolygonGroupSpatialObject from an Octree.  When that is done, you'll=
 be=20
able to go from an itk::Image to an itk::PolygonGroupSpatialObject -- sim=
ply=20
specify a colormapping function that converts to two color mode via=20
threshold, create the Octree from an image, then the=20
PolygonGroupSpatialObject from the Octree.

First question -- my Color Mapping function currently is a function point=
er,=20
set after the tree is instantiated.  The function pointer type is defined=
 as

typedef unsigned (*OctreeColorMappingFunction) (void *PixelPtr);

This function pointer is NOT templated; at this point anyone defining suc=
h a=20
function will have to do something like this:

unsigned MappingFunction(const void *PixelPtr)
{
=09const TPixel *Pixel =3D static_cast<TPixel *>(PixelPtr);
=09// For some pixel type TPixel, evaluate *TPixel and convert to
=09// a unsigned int.
}

I'd like to use something like a itk::FunctionBase but it seems like a wa=
y to=20
introduce even more overhead to the process of generating a tree.
If anyone can point me at existing ITK code that would be applicable as a=
=20
pattern to follow, I'd be much obliged.

}