15 #ifndef __vtkITKImageToImageFilter_h 16 #define __vtkITKImageToImageFilter_h 21 #include <itkCommand.h> 22 #include <itkProcessObject.h> 25 #include <vtkCommand.h> 26 #include <vtkImageAlgorithm.h> 27 #include <vtkImageCast.h> 28 #include <vtkImageData.h> 29 #include <vtkImageExport.h> 30 #include <vtkImageImport.h> 31 #include <vtkVersion.h> 33 #undef itkExceptionMacro 34 #define itkExceptionMacro(x) \ 36 ::std::ostringstream message; \ 37 message << "itk::ERROR: " << this->GetNameOfClass() \ 38 << "(" << this << "): "; \ 39 std::cout << message.str().c_str() << std::endl; \ 42 #undef itkGenericExceptionMacro 43 #define itkGenericExceptionMacro(x) \ 45 ::std::ostringstream message; \ 46 message << "itk::ERROR: " x; \ 47 std::cout << message.str() << std::endl; \ 54 :
public vtkImageAlgorithm
60 #ifdef VTK_HAS_INITIALIZE_OBJECT_BASE 61 result->InitializeObjectBase();
68 void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE
70 Superclass::PrintSelf ( os, indent );
71 this->vtkExporter->PrintSelf ( os, indent );
72 this->vtkImporter->PrintSelf ( os, indent );
82 t1 = this->Superclass::GetMTime();
83 t2 = this->vtkExporter->GetMTime();
88 t2 = this->vtkImporter->GetMTime();
100 this->Superclass::Modified();
103 m_Process->Modified();
111 this->m_Process->DebugOn();
118 this->m_Process->DebugOff();
125 this->m_Process->SetNumberOfThreads(val);
132 return this->m_Process->GetNumberOfThreads();
138 virtual void SetOutput ( vtkDataObject* d ) VTK_OVERRIDE { this->vtkImporter->SetOutput ( d ); };
139 virtual vtkImageData *
GetOutput() {
return this->vtkImporter->GetOutput(); };
142 return (vtkImageData *) this->vtkImporter->GetOutput(idx);
149 this->vtkCast->SetInputData(Input);
154 this->vtkCast->SetInputConnection(input);
159 this->vtkCast->SetInputConnection(port, input);
166 return (vtkDataObject::SafeDownCast( this->vtkCast->GetInput() ));
171 using vtkAlgorithm::Update;
174 this->vtkCast->Update();
175 this->vtkImporter->Update();
177 virtual void Update(
int port) VTK_OVERRIDE
179 this->vtkCast->Update();
180 this->vtkImporter->Update(port);
184 if ( this->m_Process )
186 this->UpdateProgress ( m_Process->GetProgress() );
191 this->InvokeEvent(vtkCommand::StartEvent,NULL);
195 this->InvokeEvent(vtkCommand::EndEvent,NULL);
205 vtkWarningMacro(<<
"This filter does not respond to Update(). Doing a GetOutput->Update() instead.");
212 this->vtkCast = vtkImageCast::New();
213 this->vtkExporter = vtkImageExport::New();
214 this->vtkImporter = vtkImageImport::New();
215 this->vtkExporter->SetInputConnection( this->vtkCast->GetOutputPort() );
216 this->m_Process = NULL;
217 this->m_ProgressCommand = MemberCommand::New();
219 this->m_StartEventCommand = MemberCommand::New();
221 this->m_EndEventCommand = MemberCommand::New();
226 vtkDebugMacro (
"Destructing vtkITKImageToImageFilter");
227 this->vtkExporter->Delete();
228 this->vtkImporter->Delete();
229 this->vtkCast->Delete();
237 this->m_Process = process;
238 this->m_Process->AddObserver ( itk::ProgressEvent(), this->m_ProgressCommand );
239 this->m_Process->AddObserver ( itk::StartEvent(), this->m_StartEventCommand );
240 this->m_Process->AddObserver ( itk::EndEvent(), this->m_EndEventCommand );
244 typedef itk::SimpleMemberCommand<vtkITKImageToImageFilter> MemberCommand;
MemberCommandPointer m_ProgressCommand
MemberCommand::Pointer MemberCommandPointer
virtual vtkImageData * GetOutput()
void SetNumberOfThreads(int val)
Pass SetNumberOfThreads.
vtkITKImageToImageFilter()
ETX.
MemberCommandPointer m_StartEventCommand
void HandleProgressEvent()
~vtkITKImageToImageFilter()
Abstract base class for connecting ITK and VTK.
void ExecuteData(vtkDataObject *) VTK_OVERRIDE
ETX.
int GetNumberOfThreads()
Pass SetNumberOfThreads.
vtkImageImport * vtkImporter
virtual void SetOutput(vtkDataObject *d) VTK_OVERRIDE
MemberCommandPointer m_EndEventCommand
void DebugOn() VTK_OVERRIDE
Pass DebugOn.
vtkMTimeType GetMTime() VTK_OVERRIDE
vtkImageExport * vtkExporter
virtual void Update() VTK_OVERRIDE
void PrintSelf(ostream &os, vtkIndent indent) VTK_OVERRIDE
virtual void SetInputConnection(vtkAlgorithmOutput *input) VTK_OVERRIDE
virtual void SetInput(vtkImageData *Input)
Set the Input of the filter.
void LinkITKProgressToVTKProgress(itk::ProcessObject *process)
BTX.
virtual vtkDataObject * GetInput()
Return the input to the filter
itk::ProcessObject::Pointer m_Process
void DebugOff() VTK_OVERRIDE
Pass DebugOff.
virtual vtkImageData * GetOutput(int idx)
virtual void Update(int port) VTK_OVERRIDE
virtual void SetInputConnection(int port, vtkAlgorithmOutput *input) VTK_OVERRIDE
static vtkITKImageToImageFilter * New()
void Modified() VTK_OVERRIDE
Pass modified message to itk filter