28#ifndef itkProcessObject_h
29#define itkProcessObject_h
45class MultiThreaderBase;
165 using NameArray = std::vector<DataObjectIdentifierType>;
296 itkSetMacro(AbortGenerateData,
bool);
299 itkGetConstReferenceMacro(AbortGenerateData,
bool);
302 itkBooleanMacro(AbortGenerateData);
312#if !defined(ITK_LEGACY_REMOVE)
314 SetProgress(
float progress)
316 m_Progress = progressFloatToFixed(progress);
328 return progressFixedToFloat(m_Progress);
469 this->SetReleaseDataFlag(
true);
474 this->SetReleaseDataFlag(
false);
490 itkSetMacro(ReleaseDataBeforeUpdateFlag,
bool);
491 itkGetConstReferenceMacro(ReleaseDataBeforeUpdateFlag,
bool);
492 itkBooleanMacro(ReleaseDataBeforeUpdateFlag);
504 return m_MultiThreader;
545 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
550 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
600 return m_IndexedInputs[0]->second;
605 return m_IndexedInputs[0]->second;
615 return this->m_IndexedInputs[0]->first.c_str();
711 return this->m_IndexedOutputs[0]->first.c_str();
734 return m_IndexedOutputs[0]->second;
739 return m_IndexedOutputs[0]->second;
900 itkGetConstMacro(ThreaderUpdateProgress,
bool);
901 itkBooleanMacro(ThreaderUpdateProgress);
910 static inline constexpr float
913 return static_cast<double>(fixed) /
static_cast<double>(std::numeric_limits<uint32_t>::max());
920 static inline uint32_t
929 return std::numeric_limits<uint32_t>::max();
931 double temp =
static_cast<double>(f) * std::numeric_limits<uint32_t>::max();
932 return static_cast<uint32_t
>(temp);
938 template <
typename TSourceObject>
942 sourceObject.ProcessObject::SetNumberOfRequiredOutputs(numberOfRequiredOutputs);
944 for (
unsigned int i{}; i < numberOfRequiredOutputs; ++i)
946 sourceObject.ProcessObject::SetNthOutput(i, sourceObject.TSourceObject::MakeOutput(i));
973 std::vector<DataObjectPointerMap::iterator> m_IndexedInputs{};
974 std::vector<DataObjectPointerMap::iterator> m_IndexedOutputs{};
977 std::map<DataObjectIdentifierType, bool> m_CachedInputReleaseDataFlags{};
983 using NameSet = std::set<DataObjectIdentifierType>;
989 bool m_AbortGenerateData{};
990 std::atomic<uint32_t> m_Progress{};
993 std::thread::id m_UpdateThreadID{};
1000 bool m_ThreaderUpdateProgress{
true };
1003 bool m_ReleaseDataBeforeUpdateFlag{};
1019 friend class TestProcessObject;
A forward iterator over the DataObject of a ProcessObject.
A forward iterator over the DataObject of a ProcessObject.
Base class for all data objects in ITK.
SmartPointer< Self > Pointer
std::string DataObjectIdentifierType
Control indentation during Print() invocation.
Light weight base class for most itk classes.
A class for performing multithreaded execution.
Base class for most ITK classes.
A forward iterator over outputs of a ProcessObject.
A forward iterator over outputs of a ProcessObject.
The base class for all process objects (source, filters, mappers) in the Insight data processing pipe...
static constexpr float progressFixedToFloat(uint32_t fixed)
virtual void SetPrimaryInputName(const DataObjectIdentifierType &key)
virtual void ReleaseInputs()
bool HasOutput(const DataObjectIdentifierType &key) const
Return true if the output with this name is defined.
virtual void PopBackInput()
virtual void SetPrimaryInput(DataObject *object)
static uint32_t progressFloatToFixed(float f)
const DataObject * GetOutput(const DataObjectIdentifierType &key) const
const DataObject * GetPrimaryOutput() const
std::map< DataObjectIdentifierType, DataObjectPointer > DataObjectPointerMap
DataObjectIdentifierType MakeNameFromIndex(DataObjectPointerArraySizeType) const
void AddOptionalInputName(const DataObjectIdentifierType &)
Define a named input that is not required and optionally associate with a numbered index.
const DataObject * GetOutput(DataObjectPointerArraySizeType i) const
void SetRequiredInputNames(const NameArray &)
Set all required named inputs.
virtual const char * GetPrimaryInputName() const
virtual void PrepareOutputs()
virtual void GenerateOutputRequestedRegion(DataObject *output)
virtual bool GetReleaseDataFlag() const
virtual void SetInput(const DataObjectIdentifierType &key, DataObject *input)
Protected method for setting indexed and named inputs.
DataObjectPointerArray GetOutputs()
Return an array with the defined named outputs.
DataObject * GetInput(DataObjectPointerArraySizeType idx)
DataObject * GetOutput(const DataObjectIdentifierType &key)
DataObjectPointerArray::size_type DataObjectPointerArraySizeType
DataObjectPointerArraySizeType GetNumberOfIndexedInputs() const
Get the number of defined Indexed inputs.
void SetMultiThreader(MultiThreaderType *threader)
virtual void Update()
Bring this filter up-to-date.
virtual void RemoveInput(const DataObjectIdentifierType &key)
Remove an input.
virtual void SetOutput(const DataObjectIdentifierType &name, DataObject *output)
NameArray GetOutputNames() const
Return an array with the defined names of the outputs.
virtual void VerifyPreconditions() const
Verifies that the process object has been configured correctly, that all required inputs are set,...
virtual void SetThreaderUpdateProgress(bool arg)
virtual void RemoveOutput(const DataObjectIdentifierType &key)
DataObjectPointerArraySizeType MakeIndexFromName(const DataObjectIdentifierType &) const
virtual void VerifyInputInformation() const
Verifies that the inputs meta-data is consistent and valid for continued execution of the pipeline,...
DataObjectPointerArraySizeType GetNumberOfInputs() const
Get the size of the input container.
void SetNumberOfIndexedInputs(DataObjectPointerArraySizeType num)
Define the number of indexed inputs defined.
const DataObject * GetInput(DataObjectPointerArraySizeType idx) const
virtual void AddOutput(DataObject *output)
virtual const char * GetPrimaryOutputName() const
std::vector< DataObjectIdentifierType > NameArray
virtual void PushFrontInput(const DataObject *input)
virtual void SetPrimaryOutput(DataObject *object)
virtual void GenerateData()
DataObjectIdentifierType MakeNameFromInputIndex(DataObjectPointerArraySizeType idx) const
virtual DataObjectPointer MakeOutput(const DataObjectIdentifierType &)
Make a DataObject of the correct type to used as the specified output.
bool AddRequiredInputName(const DataObjectIdentifierType &)
Define a required named input and optionally associate it with a numbered index.
virtual DataObjectPointerArraySizeType GetNumberOfValidRequiredInputs() const
Get the number of valid indexed inputs.
DataObject * GetPrimaryOutput()
virtual void RestoreInputReleaseDataFlags()
virtual void PopFrontInput()
DataObjectPointerArray GetInputs()
Return an array of DataObjects with the defined named inputs.
virtual void PushBackInput(const DataObject *input)
Push/Pop an indexed input of this process object.
~ProcessObject() override
NameArray GetRequiredInputNames() const
virtual void SetNumberOfRequiredInputs(DataObjectPointerArraySizeType)
Set the number of required indexed inputs.
DataObjectPointerArraySizeType GetNumberOfIndexedOutputs() const
The number of defined Indexed outputs.
virtual void SetNthInput(DataObjectPointerArraySizeType idx, DataObject *input)
DataObject * GetOutput(DataObjectPointerArraySizeType i)
DataObjectPointerArraySizeType GetNumberOfOutputs() const
Get the size of the output container.
bool IsIndexedInputName(const DataObjectIdentifierType &) const
virtual void ResetPipeline()
Reset the pipeline.
void UpdateProgress(float progress)
Update the progress of the process object.
DataObject::DataObjectIdentifierType DataObjectIdentifierType
bool HasInput(const DataObjectIdentifierType &key) const
bool AddRequiredInputName(const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx)
virtual void UpdateLargestPossibleRegion()
Sets the output requested region to the largest possible region and updates.
DataObjectPointerArraySizeType MakeIndexFromInputName(const DataObjectIdentifierType &name) const
MultiThreaderType * GetMultiThreader() const
DataObject * GetInput(const DataObjectIdentifierType &key)
Return an input.
static void MakeRequiredOutputs(TSourceObject &sourceObject, const DataObjectPointerArraySizeType numberOfRequiredOutputs)
DataObjectPointerArray GetIndexedInputs()
Return an array with all the indexed inputs.
virtual void SetNthOutput(DataObjectPointerArraySizeType idx, DataObject *output)
virtual void SetReleaseDataFlag(bool val)
virtual void PropagateRequestedRegion(DataObject *output)
void IncrementProgress(float increment)
Increment the progress of the process object.
virtual void SetPrimaryOutputName(const DataObjectIdentifierType &key)
DataObject * GetPrimaryInput()
NameArray GetInputNames() const
Return an array with the names of the inputs defined.
virtual void GenerateOutputInformation()
virtual void EnlargeOutputRequestedRegion(DataObject *)
DataObjectPointerArraySizeType MakeIndexFromOutputName(const DataObjectIdentifierType &name) const
void ReleaseDataFlagOff()
virtual DataObjectPointer MakeOutput(DataObjectPointerArraySizeType idx)
Make a DataObject of the correct type to used as the specified output.
const DataObject * GetInput(const DataObjectIdentifierType &key) const
std::set< DataObjectIdentifierType > NameSet
bool IsRequiredInputName(const DataObjectIdentifierType &) const
Query if the named input is required by name.
virtual void RemoveOutput(DataObjectPointerArraySizeType idx)
void SetNumberOfIndexedOutputs(DataObjectPointerArraySizeType num)
bool IsIndexedOutputName(const DataObjectIdentifierType &) const
virtual void GenerateInputRequestedRegion()
void AddOptionalInputName(const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx)
virtual void AddInput(DataObject *input)
DataObjectIdentifierType MakeNameFromOutputIndex(DataObjectPointerArraySizeType idx) const
virtual void RemoveInput(DataObjectPointerArraySizeType)
virtual float GetProgress() const
Get the execution progress of a process object.
virtual void UpdateOutputInformation()
Update the information describing the output data.
virtual void PropagateResetPipeline()
virtual void UpdateOutputData(DataObject *output)
const DataObject * GetPrimaryInput() const
void PrintSelf(std::ostream &os, Indent indent) const override
virtual void CacheInputReleaseDataFlags()
DataObjectPointerArray GetIndexedOutputs()
Return an array with the indexed outputs.
bool RemoveRequiredInputName(const DataObjectIdentifierType &)
Remove the named input from the required inputs.
itk::SmartPointer< MultiThreaderType > m_MultiThreader
std::vector< DataObjectPointer > DataObjectPointerArray
Implements progress tracking for a filter.
Generate a unique, increasing time value.
A progress reporter for concurrent threads.
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....
constexpr vcl_size_t ITK_MAX_THREADS
class ITK_FORWARD_EXPORT ProcessObject
unsigned int ThreadIdType