28 #ifndef itkProcessObject_h
29 #define itkProcessObject_h
45 class MultiThreaderBase;
165 using NameArray = std::vector<DataObjectIdentifierType>;
176 GetInputNames()
const;
180 GetRequiredInputNames()
const;
207 GetNumberOfInputs()
const;
211 GetNumberOfOutputs()
const;
219 GetOutputNames()
const;
251 GetNumberOfIndexedInputs()
const;
263 GetNumberOfValidRequiredInputs()
const;
271 GetNumberOfIndexedOutputs()
const;
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);
341 UpdateProgress(
float progress);
351 IncrementProgress(
float increment);
387 UpdateLargestPossibleRegion();
405 UpdateOutputInformation();
410 PropagateRequestedRegion(
DataObject * output);
454 virtual DataObjectPointer
455 MakeOutput(
const DataObjectIdentifierType &);
463 SetReleaseDataFlag(
bool val);
465 GetReleaseDataFlag()
const;
469 this->SetReleaseDataFlag(
true);
474 this->SetReleaseDataFlag(
false);
490 itkSetMacro(ReleaseDataBeforeUpdateFlag,
bool);
491 itkGetConstReferenceMacro(ReleaseDataBeforeUpdateFlag,
bool);
492 itkBooleanMacro(ReleaseDataBeforeUpdateFlag);
497 itkGetConstReferenceMacro(NumberOfWorkUnits,
ThreadIdType);
504 return m_MultiThreader;
509 SetMultiThreader(MultiThreaderType * threader);
525 PrintSelf(std::ostream & os,
Indent indent)
const override;
536 GetInput(
const DataObjectIdentifierType & key);
538 GetInput(
const DataObjectIdentifierType & key)
const;
545 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
550 return idx < m_IndexedInputs.size() ? m_IndexedInputs[idx]->second.GetPointer() :
nullptr;
561 SetInput(
const DataObjectIdentifierType & key,
DataObject * input);
563 SetNthInput(DataObjectPointerArraySizeType idx,
DataObject * input);
593 RemoveInput(
const DataObjectIdentifierType & key);
594 virtual void RemoveInput(DataObjectPointerArraySizeType);
600 return m_IndexedInputs[0]->second;
605 return m_IndexedInputs[0]->second;
611 SetPrimaryInputName(
const DataObjectIdentifierType & key);
615 return this->m_IndexedInputs[0]->first.c_str();
630 SetNumberOfIndexedInputs(DataObjectPointerArraySizeType num);
641 virtual void SetNumberOfRequiredInputs(DataObjectPointerArraySizeType);
642 itkGetConstReferenceMacro(NumberOfRequiredInputs, DataObjectPointerArraySizeType);
650 RemoveRequiredInputName(
const DataObjectIdentifierType &);
654 IsRequiredInputName(
const DataObjectIdentifierType &)
const;
661 SetRequiredInputNames(
const NameArray &);
674 AddRequiredInputName(
const DataObjectIdentifierType &);
676 AddRequiredInputName(
const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx);
689 AddOptionalInputName(
const DataObjectIdentifierType &);
691 AddOptionalInputName(
const DataObjectIdentifierType &, DataObjectPointerArraySizeType idx);
700 GetOutput(
const DataObjectIdentifierType & key);
702 GetOutput(
const DataObjectIdentifierType & key)
const;
707 SetPrimaryOutputName(
const DataObjectIdentifierType & key);
711 return this->m_IndexedOutputs[0]->first.c_str();
717 GetOutput(DataObjectPointerArraySizeType i);
719 GetOutput(DataObjectPointerArraySizeType i)
const;
724 SetOutput(
const DataObjectIdentifierType & name,
DataObject * output);
728 RemoveOutput(
const DataObjectIdentifierType & key);
734 return m_IndexedOutputs[0]->second;
739 return m_IndexedOutputs[0]->second;
750 SetNthOutput(DataObjectPointerArraySizeType idx,
DataObject * output);
756 RemoveOutput(DataObjectPointerArraySizeType idx);
758 itkSetMacro(NumberOfRequiredOutputs, DataObjectPointerArraySizeType);
759 itkGetConstReferenceMacro(NumberOfRequiredOutputs, DataObjectPointerArraySizeType);
763 SetNumberOfIndexedOutputs(DataObjectPointerArraySizeType num);
766 DataObjectIdentifierType
767 MakeNameFromInputIndex(DataObjectPointerArraySizeType idx)
const;
768 DataObjectIdentifierType
769 MakeNameFromOutputIndex(DataObjectPointerArraySizeType idx)
const;
770 DataObjectPointerArraySizeType
771 MakeIndexFromInputName(
const DataObjectIdentifierType & name)
const;
772 DataObjectPointerArraySizeType
773 MakeIndexFromOutputName(
const DataObjectIdentifierType & name)
const;
775 IsIndexedInputName(
const DataObjectIdentifierType &)
const;
777 IsIndexedOutputName(
const DataObjectIdentifierType &)
const;
795 VerifyPreconditions()
const;
808 VerifyInputInformation()
const;
824 GenerateInputRequestedRegion();
838 GenerateOutputRequestedRegion(
DataObject * output);
851 GenerateOutputInformation();
863 PropagateResetPipeline();
888 CacheInputReleaseDataFlags();
894 RestoreInputReleaseDataFlags();
900 itkGetConstMacro(ThreaderUpdateProgress,
bool);
901 itkBooleanMacro(ThreaderUpdateProgress);
903 SetThreaderUpdateProgress(
bool arg);
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 const 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));
961 DataObjectIdentifierType MakeNameFromIndex(DataObjectPointerArraySizeType)
const;
962 DataObjectPointerArraySizeType
963 MakeIndexFromName(
const DataObjectIdentifierType &)
const;
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;