VMTK
Loading...
Searching...
No Matches
vtkvmtkITKUtility.h File Reference

Helper templates and macros for connecting VTK and ITK image pipelines and for delegating Set/Get calls to a wrapped ITK filter. More...

#include "vtkObjectFactory.h"
#include "vtkSetGet.h"
Include dependency graph for vtkvmtkITKUtility.h:

Go to the source code of this file.

Macros

#define DelegateSetMacro(name, arg)
#define DelegateITKInputMacro(name, arg)
#define DelegateSetMacro2(name, arg1, arg2)
#define DelegateITKInputMacro2(name, arg1, arg2)
#define DelegateGetMacro(name)
#define DelegateITKOutputMacro(name)

Functions

template<typename ITK_Exporter, typename VTK_Importer>
void ConnectPipelines (ITK_Exporter exporter, VTK_Importer *importer)
template<typename VTK_Exporter, typename ITK_Importer>
void ConnectPipelines (VTK_Exporter *exporter, ITK_Importer importer)

Detailed Description

Helper templates and macros for connecting VTK and ITK image pipelines and for delegating Set/Get calls to a wrapped ITK filter.

ConnectPipelines() wires the callback-based itk::VTKImageExport / vtkImageImport (or vtkImageExport / itk::VTKImageImport) pair so that updates propagate across the VTK/ITK pipeline boundary without copying image data. DelegateITKInputMacro/DelegateITKOutputMacro (and their one- and two-argument DelegateSetMacro/DelegateSetMacro2/DelegateGetMacro shorthands) generate Set/Get methods that forward to the wrapped ITK filter held in m_Filter; used throughout vtkvmtk's ITK-backed image filters (e.g. the Segmentation module) to expose ITK filter parameters as ordinary VTK Set/Get accessors.

Definition in file vtkvmtkITKUtility.h.

Macro Definition Documentation

◆ DelegateSetMacro

#define DelegateSetMacro ( name,
arg )
Value:
DelegateITKInputMacro(Set##name,arg)
#define DelegateITKInputMacro(name, arg)

Definition at line 78 of file vtkvmtkITKUtility.h.

◆ DelegateITKInputMacro

#define DelegateITKInputMacro ( name,
arg )
Value:
if ( 1 ) { \
vtkDebugMacro( << this->GetClassName() << " (" << this << "): setting " #name " to " << #arg ); \
ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
if ( tempFilter ) \
{ \
tempFilter->name ( arg ); \
this->Modified(); \
} \
}

Definition at line 79 of file vtkvmtkITKUtility.h.

79#define DelegateITKInputMacro(name,arg) \
80if ( 1 ) { \
81 vtkDebugMacro( << this->GetClassName() << " (" << this << "): setting " #name " to " << #arg ); \
82 ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
83 if ( tempFilter ) \
84 { \
85 tempFilter->name ( arg ); \
86 this->Modified(); \
87 } \
88 }

◆ DelegateSetMacro2

#define DelegateSetMacro2 ( name,
arg1,
arg2 )
Value:
DelegateITKInputMacro2(Set##name,arg1,arg2)
#define DelegateITKInputMacro2(name, arg1, arg2)

Definition at line 90 of file vtkvmtkITKUtility.h.

◆ DelegateITKInputMacro2

#define DelegateITKInputMacro2 ( name,
arg1,
arg2 )
Value:
if ( 1 ) { \
vtkDebugMacro( << this->GetClassName() << " (" << this << "): setting " #name " to " << #arg1 ); \
ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
if ( tempFilter ) \
{ \
tempFilter->name ( arg1, arg2 ); \
this->Modified(); \
} \
}

Definition at line 91 of file vtkvmtkITKUtility.h.

91#define DelegateITKInputMacro2(name,arg1,arg2) \
92if ( 1 ) { \
93 vtkDebugMacro( << this->GetClassName() << " (" << this << "): setting " #name " to " << #arg1 ); \
94 ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
95 if ( tempFilter ) \
96 { \
97 tempFilter->name ( arg1, arg2 ); \
98 this->Modified(); \
99 } \
100 }

◆ DelegateGetMacro

#define DelegateGetMacro ( name)
Value:
#define DelegateITKOutputMacro(name)

Definition at line 102 of file vtkvmtkITKUtility.h.

◆ DelegateITKOutputMacro

#define DelegateITKOutputMacro ( name)
Value:
if ( 1 ) { \
vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name ); \
ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
if ( tempFilter ) \
{ \
return tempFilter->name (); \
} \
else \
{ \
vtkErrorMacro ( << this->GetClassName() << " Error getting " #name " Dynamic cast returned 0" ); \
return 0; \
} \
}

Definition at line 103 of file vtkvmtkITKUtility.h.

103#define DelegateITKOutputMacro(name) \
104if ( 1 ) { \
105 vtkDebugMacro(<< this->GetClassName() << " (" << this << "): returning " #name ); \
106 ImageFilterType* tempFilter = dynamic_cast<ImageFilterType*> ( this->m_Filter.GetPointer() ); \
107 if ( tempFilter ) \
108 { \
109 return tempFilter->name (); \
110 } \
111 else \
112 { \
113 vtkErrorMacro ( << this->GetClassName() << " Error getting " #name " Dynamic cast returned 0" ); \
114 return 0; \
115 } \
116 }

Function Documentation

◆ ConnectPipelines() [1/2]

template<typename ITK_Exporter, typename VTK_Importer>
void ConnectPipelines ( ITK_Exporter exporter,
VTK_Importer * importer )

This function will connect the given itk::VTKImageExport filter to the given vtkImageImport filter.

Definition at line 40 of file vtkvmtkITKUtility.h.

41{
42 importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
43 importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
44 importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
45 importer->SetSpacingCallback(exporter->GetSpacingCallback());
46 importer->SetOriginCallback(exporter->GetOriginCallback());
47 importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
48 importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
49 importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
50 importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
51 importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
52 importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
53 importer->SetCallbackUserData(exporter->GetCallbackUserData());
54}

◆ ConnectPipelines() [2/2]

template<typename VTK_Exporter, typename ITK_Importer>
void ConnectPipelines ( VTK_Exporter * exporter,
ITK_Importer importer )

This function will connect the given vtkImageExport filter to the given itk::VTKImageImport filter.

Definition at line 61 of file vtkvmtkITKUtility.h.

62{
63 importer->SetUpdateInformationCallback(exporter->GetUpdateInformationCallback());
64 importer->SetPipelineModifiedCallback(exporter->GetPipelineModifiedCallback());
65 importer->SetWholeExtentCallback(exporter->GetWholeExtentCallback());
66 importer->SetSpacingCallback(exporter->GetSpacingCallback());
67 importer->SetOriginCallback(exporter->GetOriginCallback());
68 importer->SetScalarTypeCallback(exporter->GetScalarTypeCallback());
69 importer->SetNumberOfComponentsCallback(exporter->GetNumberOfComponentsCallback());
70 importer->SetPropagateUpdateExtentCallback(exporter->GetPropagateUpdateExtentCallback());
71 importer->SetUpdateDataCallback(exporter->GetUpdateDataCallback());
72 importer->SetDataExtentCallback(exporter->GetDataExtentCallback());
73 importer->SetBufferPointerCallback(exporter->GetBufferPointerCallback());
74 importer->SetCallbackUserData(exporter->GetCallbackUserData());
75}