Loading...
Searching...
No Matches
elastix::ProgressCommand Class Reference

`#include <elxProgressCommand.h>`

## Detailed Description

A specialized Command object for updating the progress of a filter.

There are 3 ways to use this class.

- Whenever a filter, such as the itk::ResampleImageFilter, supports a ProgressReporter, this class can be employed. This class makes sure that the progress of a filter is printed to screen. It works as follows:

auto command = ProgressCommand::New();
command->ConnectObserver( filterpointer );
command->SetStartString( " Progress: " );
command->SetEndString( "%" );
filterpointer->Update(); // run the filter, progress messages are printed now
command->DisconnectObserver( filterPointer );
elastix::ProgressCommand::New
static Pointer New()

So, first an instantiation of this class is created, then it is connected to a filter, and some options are set. Whenever the filter throws a ProgressEvent(), this class asks for the progress and prints the percentage of progress.

- In manually written loops, a call to UpdateAndPrintProgress() can be included. Before the loop, the user should set the total number of loops, and the frequency that the progress message should be printed with. For example

auto command = ProgressCommand::New();
command->SetUpdateFrequency( maxnrofvoxels, 100 );
command->SetStartString( " Progress: " );
command->SetEndString( "%" );
log::info(std::ostringstream{} << "Looping over voxels... ");
for ( unsigned int i =0; i < maxnrofvoxels; ++i )
{
command->UpdateAndPrintProgress( i );
}
command->PrintProgress(1.0); // make sure the 100% is reached
elastix::log::level::info
@ info
Definition elxlog.h:36

- The last possibility is to directly use the PrintProgress function:

auto command = ProgressCommand::New();
command->SetStartString( " Progress: " );
command->SetEndString( "%" );
// Reading, casting, writing...
command->PrintProgress( 0.0 );
reader->Update();
command->PrintProgress( 0.33 );
caster->Update();
command->PrintProgress( 0.67 );
writer->Update();
command->PrintProgress( 1.0 );
// example assumes reader, caster and writer have been configured before

Definition at line 90 of file elxProgressCommand.h.

Inheritance diagram for elastix::ProgressCommand:
[legend]

## Public Types

using | ConstPointer = itk::SmartPointer<const Self>
using | Pointer = itk::SmartPointer<Self>
using | ProcessObjectPointer = ProcessObjectType::Pointer
using | ProcessObjectType = itk::ProcessObject
using | Self = ProgressCommand
using | Superclass = itk::Command

## Public Member Functions

virtual void | ConnectObserver (itk::ProcessObject *filter)
void | DisconnectObserver (itk::ProcessObject *filter)
void | Execute (const itk::Object *caller, const itk::EventObject &event) override
void | Execute (itk::Object *caller, const itk::EventObject &event) override
virtual const char * | GetClassName () const
virtual const char * | GetEndString () const
virtual const char * | GetStartString () const
void | PrintProgress (const float progress) const
virtual void | SetEndString (const char *_arg)
virtual void | SetStartString (const char *_arg)
virtual void | SetUpdateFrequency (const unsigned long numberOfVoxels, const unsigned long numberOfUpdates)
void | UpdateAndPrintProgress (const unsigned long currentVoxelNumber) const

## Static Public Member Functions

static Pointer | CreateAndConnect (itk::ProcessObject &)
static Pointer | CreateAndSetUpdateFrequency (unsigned long numberOfVoxels)
static Pointer | New ()

## Protected Member Functions

| ProgressCommand ()
| ~ProgressCommand () override

## Private Attributes

std::string | m_EndString
unsigned long | m_NumberOfUpdates
unsigned long | m_NumberOfVoxels
ProcessObjectPointer | m_ObservedProcessObject
std::string | m_StartString
unsigned long | m_Tag
bool | m_TagIsSet

## Member Typedef Documentation

## ConstPointer

using elastix::ProgressCommand::ConstPointer = itk::SmartPointer<const Self>

Definition at line 97 of file elxProgressCommand.h.

## Pointer

using elastix::ProgressCommand::Pointer = itk::SmartPointer<Self>

Definition at line 96 of file elxProgressCommand.h.

## ProcessObjectPointer

using elastix::ProgressCommand::ProcessObjectPointer = ProcessObjectType::Pointer

Definition at line 105 of file elxProgressCommand.h.

## ProcessObjectType

using elastix::ProgressCommand::ProcessObjectType = itk::ProcessObject

Typedef's.

Definition at line 104 of file elxProgressCommand.h.

## Self

using elastix::ProgressCommand::Self = ProgressCommand

Smart pointer declaration methods.

Definition at line 94 of file elxProgressCommand.h.

## Superclass

using elastix::ProgressCommand::Superclass = itk::Command

Definition at line 95 of file elxProgressCommand.h.

## Constructor & Destructor Documentation

## ProgressCommand()

elastix::ProgressCommand::ProgressCommand | ( |  | ) |

protected

The constructor.

## ~ProgressCommand()

elastix::ProgressCommand::~ProgressCommand | ( |  | ) |

override protected

The destructor.

## Member Function Documentation

## ConnectObserver()

virtual void elastix::ProgressCommand::ConnectObserver | ( | itk::ProcessObject * | filter | ) |

virtual

Connect an observer to a process object.

## CreateAndConnect()

Pointer elastix::ProgressCommand::CreateAndConnect | ( | itk::ProcessObject & |  | ) |

static

## CreateAndSetUpdateFrequency()

Pointer elastix::ProgressCommand::CreateAndSetUpdateFrequency | ( | unsigned long | numberOfVoxels | ) |

static

## DisconnectObserver()

void elastix::ProgressCommand::DisconnectObserver | ( | itk::ProcessObject * | filter | ) |

Disconnect an observer to a process object.

## Execute() [1/2]

void elastix::ProgressCommand::Execute | ( | const itk::Object * | caller,
|  | const itk::EventObject & | event )

override

## Execute() [2/2]

void elastix::ProgressCommand::Execute | ( | itk::Object * | caller,
|  | const itk::EventObject & | event )

override

Standard Command virtual methods.

## GetClassName()

virtual const char * elastix::ProgressCommand::GetClassName | ( |  | ) | const

virtual

Standard ITK stuff.

## GetEndString()

virtual const char * elastix::ProgressCommand::GetEndString | ( |  | ) | const

virtual

## GetStartString()

virtual const char * elastix::ProgressCommand::GetStartString | ( |  | ) | const

virtual

## New()

Pointer elastix::ProgressCommand::New | ( |  | ) |

static

## PrintProgress()

void elastix::ProgressCommand::PrintProgress | ( | const float | progress | ) | const

Print the progress to screen. A float value between 0.0 and 1.0 is expected as input.

## SetEndString()

virtual void elastix::ProgressCommand::SetEndString | ( | const char * | _arg | ) |

virtual

Set and get the string ending each progress report.

## SetStartString()

virtual void elastix::ProgressCommand::SetStartString | ( | const char * | _arg | ) |

virtual

Set and get the string starting each progress report.

## SetUpdateFrequency()

virtual void elastix::ProgressCommand::SetUpdateFrequency | ( | const unsigned long | numberOfVoxels,
|  | const unsigned long | numberOfUpdates )

virtual

Define when to print the progress.

## UpdateAndPrintProgress()

void elastix::ProgressCommand::UpdateAndPrintProgress | ( | const unsigned long | currentVoxelNumber | ) | const

Update and possibly print the progress to screen. The progress information on screen is refreshed according to the UpdateFrequency, which is assumed being specified beforehand using the SetUpdateFrequency function.

## Field Documentation

## m_EndString

std::string elastix::ProgressCommand::m_EndString

private

Definition at line 164 of file elxProgressCommand.h.

## m_NumberOfUpdates

unsigned long elastix::ProgressCommand::m_NumberOfUpdates

private

Definition at line 173 of file elxProgressCommand.h.

## m_NumberOfVoxels

unsigned long elastix::ProgressCommand::m_NumberOfVoxels

private

Member variables that define the update frequency.

Definition at line 172 of file elxProgressCommand.h.

## m_ObservedProcessObject

ProcessObjectPointer elastix::ProgressCommand::m_ObservedProcessObject

private

Definition at line 169 of file elxProgressCommand.h.

## m_StartString

std::string elastix::ProgressCommand::m_StartString

private

Member variables to define a start and end string for printing.

Definition at line 163 of file elxProgressCommand.h.

## m_Tag

unsigned long elastix::ProgressCommand::m_Tag

private

Member variables to keep track of what is set.

Definition at line 167 of file elxProgressCommand.h.

## m_TagIsSet

bool elastix::ProgressCommand::m_TagIsSet

private

Definition at line 168 of file elxProgressCommand.h.

Generated on 1768596610 for elastix by 1.15.0 |