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);
500#if !defined(ITK_LEGACY_REMOVE) || defined(ITKV4_COMPATIBILITY)
501 itkLegacyMacro(
void SetNumberOfThreads(
ThreadIdType count)) { this->SetNumberOfWorkUnits(count); }
503 itkLegacyMacro(
ThreadIdType GetNumberOfThreads()
const) {
return this->GetNumberOfWorkUnits(); }
510 return m_MultiThreader;
551 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
556 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
606 return m_IndexedInputs[0]->second;
611 return m_IndexedInputs[0]->second;
621 return this->m_IndexedInputs[0]->first.c_str();
717 return this->m_IndexedOutputs[0]->first.c_str();
740 return m_IndexedOutputs[0]->second;
745 return m_IndexedOutputs[0]->second;
814 VerifyInputInformation() ITKv5_CONST;
830 GenerateInputRequestedRegion();
857 GenerateOutputInformation();
906 itkGetConstMacro(ThreaderUpdateProgress,
bool);
907 itkBooleanMacro(ThreaderUpdateProgress);
916 static inline constexpr float
919 return static_cast<double>(fixed) /
static_cast<double>(std::numeric_limits<uint32_t>::max());
927 static inline uint32_t
936 return std::numeric_limits<uint32_t>::max();
938 double temp =
static_cast<double>(f) * std::numeric_limits<uint32_t>::max();
939 return static_cast<uint32_t
>(temp);
966 std::vector<DataObjectPointerMap::iterator> m_IndexedInputs{};
967 std::vector<DataObjectPointerMap::iterator> m_IndexedOutputs{};
970 std::map<DataObjectIdentifierType, bool> m_CachedInputReleaseDataFlags{};
976 using NameSet = std::set<DataObjectIdentifierType>;
982 bool m_AbortGenerateData{};
983 std::atomic<uint32_t> m_Progress{};
986 std::thread::id m_UpdateThreadID{};
993 bool m_ThreaderUpdateProgress{
true };
996 bool m_ReleaseDataBeforeUpdateFlag{};
1012 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 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 SetThreaderUpdateProgress(bool arg)
virtual void RemoveOutput(const DataObjectIdentifierType &key)
DataObjectPointerArraySizeType MakeIndexFromName(const DataObjectIdentifierType &) const
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)
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.
virtual void VerifyPreconditions() ITKv5_CONST
Verifies that the process object has been configured correctly, that all required inputs are set,...
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.
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 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
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