19 #ifndef rtkIterationCommands_h 20 #define rtkIterationCommands_h 37 template <
typename TCaller>
57 const auto * cCaller =
dynamic_cast<const TCaller *
>(caller);
60 if (itk::EndEvent().CheckEvent(&event))
65 if (itk::IterationEvent().CheckEvent(&event))
68 if ((m_IterationCount % m_TriggerEvery) == 0)
78 unsigned int m_IterationCount = 0;
81 unsigned int m_TriggerEvery = 1;
85 Run(
const TCaller * caller) = 0;
89 End(
const TCaller * itkNotUsed(caller))
102 template <
typename TCaller>
114 Run(
const TCaller * itkNotUsed(caller))
override 117 std::cout <<
"\rIteration " << this->m_IterationCount <<
" completed." << std::flush;
121 End(
const TCaller * itkNotUsed(caller))
override 123 std::cout << std::endl;
138 template <
typename TCaller,
typename TOutputImage>
155 Run(
const TCaller * caller)
override 158 typename WriterType::Pointer writer = WriterType::New();
161 unsigned int size = snprintf(buffer, 1024, m_FileFormat.c_str(), this->m_IterationCount);
162 writer->SetFileName(std::string(buffer, size));
164 writer->SetInput(caller->GetOutput());
IterationCommand< TCaller > Superclass
IterationCommand< TCaller > Superclass
Outputs to standard output when an iteration completes.
void Execute(const itk::Object *caller, const itk::EventObject &event) override
virtual void End(const TCaller *)
itk::SmartPointer< Self > Pointer
void End(const TCaller *) override
VerboseIterationCommand Self
Output intermediate iterations in a file. This class is useful to check convergence of an iterative m...
void Run(const TCaller *caller) override
#define itkSetMacro(name, type)
itk::SmartPointer< Self > Pointer
Abstract superclass to all iteration callbacks. Derived classes must implement the Run() method...
OutputIterationCommand Self
void Execute(itk::Object *caller, const itk::EventObject &event) override
itk::SmartPointer< Self > Pointer
void Run(const TCaller *) override