VMTK
Loading...
Searching...
No Matches
vtkvmtkITKUtility.h
Go to the documentation of this file.
1/*=========================================================================
2
3 Copyright Brigham and Women's Hospital (BWH) All Rights Reserved.
4
5 See Doc/copyright/copyright.txt
6 or http://www.slicer.org/copyright/copyright.txt for details.
7
8 Program: vtkvmtkITK
9
10==========================================================================*/
11
12#ifndef __vtkvmtkITKUtility_h
13#define __vtkvmtkITKUtility_h
14
15
16#include "vtkObjectFactory.h"
17#include "vtkSetGet.h"
18
34
39template <typename ITK_Exporter, typename VTK_Importer>
40void ConnectPipelines(ITK_Exporter exporter, VTK_Importer* importer)
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}
55
60template <typename VTK_Exporter, typename ITK_Importer>
61void ConnectPipelines(VTK_Exporter* exporter, ITK_Importer importer)
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}
76
77
78#define DelegateSetMacro(name,arg) DelegateITKInputMacro(Set##name,arg)
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 }
89
90#define DelegateSetMacro2(name,arg1,arg2) DelegateITKInputMacro2(Set##name,arg1,arg2)
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 }
101
102#define DelegateGetMacro(name) DelegateITKOutputMacro (Get##name)
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 }
117
118
119// struct vtkvmtkITKProgressDisplay
120// {
121// ProgressDisplay(vtkObject* obj, itk::ProcessObject* process): m_Process(process), m_Object(obj) {}
122
123// void Display()
124// {
125// m_Object->SetProgress ( m_Process->GetProgress() );
126// }
127
128// itk::ProcessObject::Pointer m_Process;
129// vtkObject* m_Object();
130// };
131
132// // Add a progress observer for the itk::CurvatureFlowImageFilter.
133// // This will make it clear when this part of the ITK pipeline
134// // executes.
135// ProgressDisplay progressDisplay(denoiser);
136// itk::SimpleMemberCommand<ProgressDisplay>::Pointer progressEvent =
137// itk::SimpleMemberCommand<ProgressDisplay>::New();
138// progressEvent->SetCallbackFunction(&progressDisplay,
139// &ProgressDisplay::Display);
140// denoiser->AddObserver(itk::ProgressEvent(), progressEvent);
141
142
143
144#endif
void ConnectPipelines(ITK_Exporter exporter, VTK_Importer *importer)