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)
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->SetNumberOfWorkUnits(val);
132 return this->m_Process->GetNumberOfWorkUnits();
138 void SetOutput ( vtkDataObject* d )
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();
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,
nullptr);
195 this->InvokeEvent(vtkCommand::EndEvent,
nullptr);
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 =
nullptr;
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()
vtkMTimeType GetMTime() override
Abstract base class for connecting ITK and VTK.
int GetNumberOfThreads()
Pass SetNumberOfThreads.
void DebugOn() override
Pass DebugOn.
vtkImageImport * vtkImporter
void Modified() override
Pass modified message to itk filter
MemberCommandPointer m_EndEventCommand
vtkImageExport * vtkExporter
void Update(int port) override
void DebugOff() override
Pass DebugOff.
void PrintSelf(ostream &os, vtkIndent indent) override
virtual void SetInput(vtkImageData *Input)
Set the Input of the filter.
void SetInputConnection(vtkAlgorithmOutput *input) override
void LinkITKProgressToVTKProgress(itk::ProcessObject *process)
BTX.
virtual vtkDataObject * GetInput()
Return the input to the filter
itk::ProcessObject::Pointer m_Process
void SetOutput(vtkDataObject *d) override
void ExecuteData(vtkDataObject *) override
ETX.
virtual vtkImageData * GetOutput(int idx)
void SetInputConnection(int port, vtkAlgorithmOutput *input) override
~vtkITKImageToImageFilter() override
static vtkITKImageToImageFilter * New()