19#ifndef rtkIterationCommands_h
20#define rtkIterationCommands_h
37template <
typename TCaller>
57 const auto * cCaller =
dynamic_cast<const TCaller *
>(caller);
60 if (itk::EndEvent().CheckEvent(&event))
65 if (itk::IterationEvent().CheckEvent(&event))
85 Run(
const TCaller * caller) = 0;
89 End(
const TCaller * itkNotUsed(caller))
102template <
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;
138template <
typename TCaller,
typename TOutputImage>
155 Run(
const TCaller * caller)
override
158 auto writer = WriterType::New();
161#if defined(__GNUC__) || defined(__clang__)
162# pragma GCC diagnostic push
163# pragma GCC diagnostic ignored "-Wformat-nonliteral"
165 unsigned int size = snprintf(buffer, 1024,
m_FileFormat.c_str(), this->m_IterationCount);
166#if defined(__GNUC__) || defined(__clang__)
167# pragma GCC diagnostic pop
169 writer->SetFileName(std::string(buffer, size));
171 writer->SetInput(caller->GetOutput());
Superclass for callback/observer methods.
Abstraction of the Events used to communicating among filters and with GUIs.
Writes image data to a single file.
Base class for most ITK classes.
Implements transparent reference counting.
Abstract superclass to all iteration callbacks. Derived classes must implement the Run() method....
itk::SmartPointer< Self > Pointer
void Execute(itk::Object *caller, const itk::EventObject &event) override
unsigned int m_TriggerEvery
virtual void Run(const TCaller *caller)=0
unsigned int m_IterationCount
virtual void End(const TCaller *caller)
void Execute(const itk::Object *caller, const itk::EventObject &event) override
Output intermediate iterations in a file. This class is useful to check convergence of an iterative m...
IterationCommand< TCaller > Superclass
OutputIterationCommand Self
void Run(const TCaller *caller) override
itk::SmartPointer< Self > Pointer
Outputs to standard output when an iteration completes.
VerboseIterationCommand Self
itk::SmartPointer< Self > Pointer
IterationCommand< TCaller > Superclass
void End(const TCaller *caller) override
void Run(const TCaller *caller) override
#define itkSetMacro(name, type)