go home Home | Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages
Macros
elxMacro.h File Reference
#include "itkWin32Header.h"
+ Include dependency graph for elxMacro.h:

Go to the source code of this file.

Macros

#define ELASTIXLIB_API
 
#define elxClassNameMacro(_name)
 
#define elxInstallComponentFunctionCallMacro(_classname)    ret |= _classname##InstallComponent( _cdb )
 
#define elxInstallComponentFunctionDeclarationMacro(_classname)
 
#define elxInstallMacro(_classname)
 
#define elxout   ::xl::xout[ "standard" ]
 
#define elxOverrideGetConstMacro(name, type)
 
#define elxPrepareImageTypeSupportMacro()
 
#define elxSupportedImageTypeMacro(_fPixelType, _fDim, _mPixelType, _mDim, _VIndex)
 

Macro Definition Documentation

◆ ELASTIXLIB_API

#define ELASTIXLIB_API

Definition at line 301 of file elxMacro.h.

◆ elxClassNameMacro

#define elxClassNameMacro (   _name)
Value:
static const char * elxGetClassNameStatic( void ) { return _name; } \
const char * elxGetClassName( void ) const override { return _name; }

elxClassNameMacro(_name)

Example of usage:

class MyMetric { public: elxClassNameMacro("MyFirstMetric"); }

This macro defines two functions.

static const char * elxGetClassNameStatic(void){return _name;} const char * elxGetClassName( void ) const override { return _name; }

Use this macro in every component that will be installed in the ComponentDatabase, using "elxInstallMacro".

Definition at line 262 of file elxMacro.h.

◆ elxInstallComponentFunctionCallMacro

#define elxInstallComponentFunctionCallMacro (   _classname)     ret |= _classname##InstallComponent( _cdb )

elxInstallComponentFunctionCallMacro

Usage example: elxInstallComponentFunctionCallMacro( BSplineTransform );

This macro calls the function implemented by the elxInstallMacro. This macro is used by the CMake generated file elxInstallComponentFunctionCalls.h only.

Details: the InstallComponent function defined by elxInstallMacro is called.

See also elxInstallAllComponents.h.

Definition at line 161 of file elxMacro.h.

◆ elxInstallComponentFunctionDeclarationMacro

#define elxInstallComponentFunctionDeclarationMacro (   _classname)
Value:
extern "C" int _classname##InstallComponent( \
::elx::ComponentDatabase * _cdb )

elxInstallComponentFunctionDeclarationMacro

Usage example: elxInstallComponentFunctionDeclarationMacro( BSplineTransform );

This macro declares the function implemented by the elxInstallMacro. This macro is used by the CMake generated file elxInstallComponentFunctionDeclarations.h only.

Details: the declaration of InstallComponent function defined by elxInstallMacro is simply repeated.

See also elxInstallAllComponents.h.

Definition at line 140 of file elxMacro.h.

◆ elxInstallMacro

#define elxInstallMacro (   _classname)
Value:
template< ::elx::ComponentDatabase::IndexType VIndex > \
class _classname##_install \
{ \
public: \
typedef typename::elx::ElastixTypedef< VIndex >::ElastixType ElastixType; \
typedef::elx::ComponentDatabase::ComponentDescriptionType ComponentDescriptionType; \
static int DO( ::elx::ComponentDatabase * cdb ) \
{ \
ComponentDescriptionType name = ::elx::_classname< ElastixType >::elxGetClassNameStatic(); \
int dummy = ::elx::InstallFunctions< ::elx::_classname< ElastixType > >::InstallComponent( name, VIndex, cdb ); \
if( ::elx::ElastixTypedef< VIndex + 1 >::Defined() ) \
{ return _classname##_install< VIndex + 1 >::DO( cdb ); } \
return dummy; \
} \
}; \
template< > \
class _classname##_install< ::elx::NrOfSupportedImageTypes + 1 > \
{ \
public: \
typedef::elx::ComponentDatabase::ComponentDescriptionType ComponentDescriptionType; \
static int DO( ::elx::ComponentDatabase * ) \
{ return 0; } \
}; \
extern "C" int _classname##InstallComponent( \
::elx::ComponentDatabase * _cdb ) \
{ \
int _InstallDummy##_classname = _classname##_install< 1 >::DO( _cdb ); \
return _InstallDummy##_classname; \
}

This include is only used to get rid of a MSVS compiler warning when using std::copy. The warning is like: 'conversion' conversion from 'type1' to 'type2', possible loss of data To solve it ITK recommends to include itkMacro.h before <algorithm> or any other stl header. In elastix we try to make sure that elxIncludes.h is included before anything else, which includes elxMacro.h, which now includes itkWin32Header.h. Macro for installing support new components (like a new metric, interpolator, or transform). Must be invoked in the .cxx file of the component, after declaration of the class.

Example of usage:

// elxMyMetric.h //
#include "elxMetricBase.h"
#include "itkMattesMutualInformationImageToImageMetric.h"
namespace elastix {
template <class TElastix>
class MyMetric : public MetricBase<TElastix>,
public itk::MattesMutualInformationImageToImageMetric
< MetricBase<TElastix>::FixedImageType
MetricBase<TElastix>::MovingImageType >
{
typedef MyMetric Self;
itkNewMacro( Self ); //needed for the elxInstallMacro
elxClassNameMacro("MattesMutualInformation"); //also needed
.......
};
} // end namespace elastix
#define elxClassNameMacro(_name)
Definition: elxMacro.h:262
// elxMyMetric.hxx //
// Definitions of the methods of the MyMetric class template
// elxMyMetric.cxx //
#include elxMyMetric.h
elxInstallMacro(MyMetric);
// CMakeLists.txt //
ADD_ELXCOMPONENT( MyMetric
elxMyMetric.h
elxMyMetric.hxx
elxMyMetric.cxx
[<any other source files needed>] )
#define elxInstallMacro(_classname)
Definition: elxMacro.h:92

The class to be installed should inherit from the appropriate base class. (elx::MetricBase, elx::TransformBase etc,) and from a specific itk object.

IMPORTANT: only one template argument <class TElastix> is allowed. Not more, not less.

Details: a function "int _classname##InstallComponent( _cdb )" is defined. In this function a template is defined, _classname##_install<VIndex>. It contains the ElastixTypedef<VIndex>, and recursive function DO(cdb). DO installs the component for all defined ElastixTypedefs (so for all supported image types).

Definition at line 92 of file elxMacro.h.

◆ elxout

#define elxout   ::xl::xout[ "standard" ]

elxout

This macro replaces 'elxout' by 'xl::xout["standard"]'. This simplifies writing messages to screen and logfile.

NB: for error and warning messages, for writing to the transformparameterfile etc. do not use elxout, but xout["{error, warning, etc}"].

Definition at line 287 of file elxMacro.h.

◆ elxOverrideGetConstMacro

#define elxOverrideGetConstMacro (   name,
  type 
)
Value:
type Get##name () const override \
{ \
return this->m_##name; \
}

Get built-in type. Creates an override of the virtual member Get"name"() This is the "const" form of the itkGetMacro. It should be used unless the member can be changed through the "Get" access routine.

Definition at line 269 of file elxMacro.h.

◆ elxPrepareImageTypeSupportMacro

#define elxPrepareImageTypeSupportMacro ( )
Value:
template< ::elx::ComponentDatabase::IndexType VIndex > \ \
class ElastixTypedef \
{ \
public: \ \ \
typedef::itk::Object ElastixType; \
typedef::elx::ComponentDatabase::PixelTypeDescriptionType PixelTypeString; \
static PixelTypeString fPixelTypeAsString( void ) \
{ return PixelTypeString( "" ); } \
static PixelTypeString mPixelTypeAsString( void ) \
{ return PixelTypeString( "" ); } \
static unsigned int fDim( void ) \
{ return 0; } \
static unsigned int mDim( void ) \
{ return 0; } \ \ \
static bool Defined( void ) \
{ return false; } \
}

elxPrepareImageTypeSupportMacro To be called once, before the elxSupportImageTypeMacro()

IMPORTANT: the macro must be invoked in namespace elastix!

Definition at line 171 of file elxMacro.h.

◆ elxSupportedImageTypeMacro

#define elxSupportedImageTypeMacro (   _fPixelType,
  _fDim,
  _mPixelType,
  _mDim,
  _VIndex 
)
Value:
template< > \
class ElastixTypedef< _VIndex > \
{ \
public: \
typedef::itk::Image< _fPixelType, _fDim > FixedImageType; \
typedef::itk::Image< _mPixelType, _mDim > MovingImageType; \
typedef::elx::ElastixTemplate< FixedImageType, MovingImageType > ElastixType; \
typedef::elx::ComponentDatabase::PixelTypeDescriptionType PixelTypeString; \
static PixelTypeString fPixelTypeAsString( void ) \
{ return PixelTypeString( #_fPixelType ); } \
static PixelTypeString mPixelTypeAsString( void ) \
{ return PixelTypeString( #_mPixelType ); } \
static unsigned int fDim( void ) \
{ return _fDim; } \
static unsigned int mDim( void ) \
{ return _mDim; } \
static bool Defined( void ) \
{ return true; } \
}

Macro for installing support for new ImageTypes. Used in elxSupportedImageTypes.cxx .

Example of usage:

namespace elastix { elxSupportedImageTypeMacro(unsigned short, 2, float, 3, 1); elxSupportedImageTypeMacro(unsigned short, 3, float, 3, 2); etc. } //end namespace elastix

The first line adds support for the following combination of ImageTypes: fixedImage: 2D unsigned short movingImage 3D float The Index (last argument) of this combination of ImageTypes is 1.

The Index should not be 0. This value is reserved for errormessages. Besides, duplicate indices are not allowed.

IMPORTANT: the macro must be invoked in namespace elastix!

Details: the macro adds a class template specialization for the class ElastixTypedef<VIndex>.

Definition at line 222 of file elxMacro.h.



Generated on 1667476801 for elastix by doxygen 1.9.4 elastix logo