42#include "itkConfigure.h"
43#include "ITKCommonExport.h"
81#define ITK_NOOP_STATEMENT static_assert(true, "")
84#if defined(ITK_FUTURE_LEGACY_REMOVE)
86# define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
92# define ITK_MACROEND_NOOP_STATEMENT
100#define ITK_PRAGMA(x) _Pragma(#x)
108# define ITK_GCC_PRAGMA_PUSH ITK_PRAGMA(GCC diagnostic push)
109# define ITK_GCC_PRAGMA_POP ITK_PRAGMA(GCC diagnostic pop)
110# define ITK_GCC_SUPPRESS_Wfloat_equal ITK_PRAGMA(GCC diagnostic ignored "-Wfloat-equal")
111# define ITK_GCC_SUPPRESS_Wformat_nonliteral ITK_PRAGMA(GCC diagnostic ignored "-Wformat-nonliteral")
113# define ITK_GCC_PRAGMA_PUSH
114# define ITK_GCC_PRAGMA_POP
115# define ITK_GCC_SUPPRESS_Wfloat_equal
116# define ITK_GCC_SUPPRESS_Wformat_nonliteral
120#if defined(__clang__) && defined(__has_warning)
121# define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
122# define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
124# define ITK_CLANG_PRAGMA_PUSH
125# define ITK_CLANG_PRAGMA_POP
130#define CLANG_PRAGMA_PUSH ITK_CLANG_PRAGMA_PUSH
131#define CLANG_PRAGMA_POP ITK_CLANG_PRAGMA_POP
132#define CLANG_SUPPRESS_Wfloat_equal ITK_GCC_SUPPRESS_Wfloat_equal
134#if !defined(ITK_LEGACY_REMOVE)
136# define CLANG_SUPPRESS_Wcpp14_extensions \
137 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
138 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
142#if defined(__INTEL_COMPILER)
143# define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
144# define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
145# define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
147# define INTEL_PRAGMA_WARN_PUSH
148# define INTEL_PRAGMA_WARN_POP
149# define INTEL_SUPPRESS_warning_1292
160#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
161# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
162# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
163# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
165# define ITK_GCC_PRAGMA_DIAG(x)
166# define ITK_GCC_PRAGMA_DIAG_PUSH()
167# define ITK_GCC_PRAGMA_DIAG_POP()
174#if defined(_MSC_VER) && (_MSC_VER < 1920)
175# error "MSVC versions before Visual Studio 2019 are not supported under ITKv5.4"
177#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
178# error "SUNPro C++ < 5.14.0 is not supported under ITKv5 and above"
180#if defined(__CYGWIN__)
181# error "The Cygwin compiler is not supported in ITKv4 and above"
183#if defined(__BORLANDC__)
184# error "The Borland C compiler is not supported in ITKv4 and above"
186#if defined(__MWERKS__)
187# error "The MetroWerks compiler is not supported in ITKv4 and above"
189#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
190# error "GCC < 7 is not supported under ITKv5.4"
196# error "The SGI compiler is not supported under ITKv4 and above"
198#if defined(__APPLE__)
199# if defined(__clang__) && (__cplusplus < 201703L)
200# error "Apple LLVM compiling with a standard less than C++17 is not supported under ITKv5.4"
202#elif defined(__clang__) && (__clang_major__ < 5)
203# error "Clang < 5 is not supported under ITKv5.4"
205#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
206# error "Intel C++ < 19.1 is not supported under ITKv5.4"
210#if defined(_WIN32) || defined(WIN32)
211# define ITK_ABI_IMPORT __declspec(dllimport)
212# define ITK_ABI_EXPORT __declspec(dllexport)
213# define ITK_ABI_HIDDEN
216# define ITK_ABI_IMPORT __attribute__((visibility("default")))
217# define ITK_ABI_EXPORT __attribute__((visibility("default")))
218# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
220# define ITK_ABI_IMPORT
221# define ITK_ABI_EXPORT
222# define ITK_ABI_HIDDEN
227#ifndef ITK_TEMPLATE_EXPORT
228# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
229# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
231# define ITK_TEMPLATE_EXPORT
236#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
237# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
239# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
242#ifndef ITK_FORWARD_EXPORT
244# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
245 defined(USE_COMPILER_HIDDEN_VISIBILITY)
246# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
248# define ITK_FORWARD_EXPORT
256#define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
258#if !defined(ITK_LEGACY_REMOVE)
259# define ITK_DELETE_FUNCTION = delete
261# define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
268#if defined(ITK_FUTURE_LEGACY_REMOVE)
269# define ITK_CONSTEXPR_FUNC "Replace ITK_CONSTEXPR_FUNC with constexpr"
270# define ITK_CONSTEXPR_VAR "Replace ITK_CONSTEXPR_VAR with constexpr"
272# define itkExposeEnumValue(name) static_cast<int>(name)
276# define ITK_CONSTEXPR_FUNC constexpr
277# define ITK_CONSTEXPR_VAR constexpr
280# define itkExposeEnumValue(name) static_cast<int>(name)
283#if !defined(ITK_FUTURE_LEGACY_REMOVE)
284# define ITK_FALLTHROUGH [[fallthrough]]
286# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with [[fallthrough]]")
309#define itkNewMacro(x) \
310 itkSimpleNewMacro(x); \
311 itkCreateAnotherMacro(x); \
313 ITK_MACROEND_NOOP_STATEMENT
316#define itkSimpleNewMacro(x) \
317 static Pointer New() \
319 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
320 if (smartPtr == nullptr) \
322 smartPtr = new x(); \
324 smartPtr->UnRegister(); \
327 ITK_MACROEND_NOOP_STATEMENT
329#define itkCreateAnotherMacro(x) \
330 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
331 ITK_MACROEND_NOOP_STATEMENT
333#define itkCloneMacro(x) \
334 Pointer Clone() const \
336 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
339 ITK_MACROEND_NOOP_STATEMENT
344#define itkFactoryOnlyNewMacro(x) \
345 itkSimpleFactoryOnlyNewMacro(x); \
346 itkCreateAnotherMacro(x); \
348 ITK_MACROEND_NOOP_STATEMENT
351#define itkSimpleFactoryOnlyNewMacro(x) \
352 static auto New()->Pointer \
354 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
355 if (smartPtr == nullptr) \
357 itkSpecializedMessageExceptionMacro(ExceptionObject, \
358 "Object factory failed to instantiate " << typeid(x).name()); \
360 smartPtr->UnRegister(); \
363 ITK_MACROEND_NOOP_STATEMENT
377#define itkFactorylessNewMacro(x) \
378 static Pointer New() \
380 x * rawPtr = new x(); \
381 Pointer smartPtr = rawPtr; \
382 rawPtr->UnRegister(); \
385 itkCreateAnotherMacro(x); \
386 ITK_MACROEND_NOOP_STATEMENT
398#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
399 TypeName(const TypeName &) = delete; \
400 TypeName & operator=(const TypeName &) = delete; \
401 TypeName(TypeName &&) = delete; \
402 TypeName & operator=(TypeName &&) = delete
404#if !defined(ITK_FUTURE_LEGACY_REMOVE)
405# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
407# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
408 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
419#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
420 TypeName(const TypeName &) = default; \
421 TypeName & operator=(const TypeName &) = default; \
422 TypeName(TypeName &&) = default; \
423 TypeName & operator=(TypeName &&) = default
431#if __cplusplus >= 202002L
432# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
438#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
441# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
445# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
446 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
447 ITK_MACROEND_NOOP_STATEMENT
452#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
454 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
455 "The macro argument `" #thisClass \
456 "` appears incorrect! It should correspond with the name of this class!"); \
459 ITK_MACROEND_NOOP_STATEMENT
465#define itkVirtualGetNameOfClassMacro(thisClass) \
466 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
468#define itkOverrideGetNameOfClassMacro(thisClass) \
469 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
471#ifdef ITK_FUTURE_LEGACY_REMOVE
472# define itkTypeMacro(thisClass, superclass) \
473 static_assert(false, \
474 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
475 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
476# define itkTypeMacroNoParent(thisClass) \
477 static_assert(false, \
478 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
479 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
485# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
486# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
498extern ITKCommon_EXPORT
void
499OutputWindowDisplayText(
const char *);
502extern ITKCommon_EXPORT
void
503OutputWindowDisplayErrorText(
const char *);
505extern ITKCommon_EXPORT
void
506OutputWindowDisplayWarningText(
const char *);
508extern ITKCommon_EXPORT
void
509OutputWindowDisplayGenericOutputText(
const char *);
511extern ITKCommon_EXPORT
void
512OutputWindowDisplayDebugText(
const char *);
522# define itkDebugMacro(x) ITK_NOOP_STATEMENT
523# define itkDebugStatement(x) ITK_NOOP_STATEMENT
525# define itkDebugMacro(x) \
528 using namespace ::itk::print_helper; \
529 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
531 std::ostringstream itkmsg; \
532 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' \
533 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
534 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
541# define itkDebugStatement(x) x
547#define itkWarningMacro(x) \
550 if (::itk::Object::GetGlobalWarningDisplay()) \
552 std::ostringstream itkmsg; \
553 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' \
554 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
555 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
560#define itkWarningStatement(x) x
562#if defined(ITK_CPP_FUNCTION)
563# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
564# define ITK_LOCATION __FUNCSIG__
565# elif defined(__GNUC__)
566# define ITK_LOCATION __PRETTY_FUNCTION__
568# define ITK_LOCATION __FUNCTION__
571# define ITK_LOCATION "unknown"
574#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
577 class newexcp : public parentexcp \
581 static constexpr const char * const default_exception_message = whatmessage; \
583 using parentexcp::parentexcp; \
584 itkOverrideGetNameOfClassMacro(newexcp); \
587 ITK_MACROEND_NOOP_STATEMENT
590#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
592 std::ostringstream exceptionDescriptionOutputStringStream; \
593 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
594 throw ::itk::ExceptionType( \
595 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
597 ITK_MACROEND_NOOP_STATEMENT
599#define itkSpecializedExceptionMacro(ExceptionType) \
600 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
605#define itkExceptionMacro(x) \
606 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << '(' << this << "): " x)
608#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
610#define itkGenericOutputMacro(x) \
612 if (::itk::Object::GetGlobalWarningDisplay()) \
614 std::ostringstream itkmsg; \
615 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
616 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
619 ITK_MACROEND_NOOP_STATEMENT
624#define itkLogMacro(x, y) \
626 if (this->GetLogger()) \
628 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
631 ITK_MACROEND_NOOP_STATEMENT
633#define itkLogMacroStatic(obj, x, y) \
635 if (obj->GetLogger()) \
637 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
640 ITK_MACROEND_NOOP_STATEMENT
671#if defined(ITK_LEGACY_REMOVE)
672# define itkLegacyMacro(method)
674# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
676# define itkLegacyMacro(method) method
679# define itkLegacyMacro(method) [[deprecated]] method
705#if defined(ITK_LEGACY_SILENT)
706# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
707# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
708# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
709# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
711# define itkLegacyBodyMacro(method, version) \
712 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
713# define itkLegacyReplaceBodyMacro(method, version, replace) \
714 itkWarningMacro(#method " was deprecated for ITK " #version \
715 " and will be removed in a future version. Use " #replace " instead.")
716# define itkGenericLegacyBodyMacro(method, version) \
717 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
718# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
719 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
720 " and will be removed in a future version. Use " #replace " instead.")
727#define ITK_CACHE_LINE_ALIGNMENT 64
735#define itkPadStruct(mincachesize, oldtype, newtype) \
736 struct newtype : public oldtype \
738 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
745#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
746# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
747#elif defined(_MSC_VER)
748# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
750# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
753#if defined(ITK_FUTURE_LEGACY_REMOVE)
776# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
778# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
794#define itkForLoopAssignmentMacro( \
795 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
796 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
798 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
810#define itkForLoopRoundingAndAssignmentMacro( \
811 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
812 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
814 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
819#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
822# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
824# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
828# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
831#define itkAssertOrThrowMacro(test, message) \
834 std::ostringstream msgstr; \
836 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
838 ITK_MACROEND_NOOP_STATEMENT
840#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
841# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
843# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
853#ifdef ITK_FUTURE_LEGACY_REMOVE
854# define itkStaticConstMacro(name, type, value) \
855 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
856# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
872# define itkStaticConstMacro(name, type, value) static constexpr type name = value
874# define itkGetStaticConstMacro(name) (Self::name)
878#define itkSetInputMacro(name, type) \
879 virtual void Set##name(const type * _arg) \
881 itkDebugMacro("setting input " #name " to " << _arg); \
882 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
884 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
888 ITK_MACROEND_NOOP_STATEMENT
892#define itkGetInputMacro(name, type) \
893 virtual const type * Get##name() const \
895 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
896 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
898 ITK_MACROEND_NOOP_STATEMENT
903#define itkSetDecoratedInputMacro(name, type) \
904 virtual void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) \
906 itkDebugMacro("setting input " #name " to " << _arg); \
907 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
909 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
913 virtual void Set##name(const SimpleDataObjectDecorator<type> * _arg) { this->Set##name##Input(_arg); } \
914 virtual void Set##name(const type & _arg) \
916 using DecoratorType = SimpleDataObjectDecorator<type>; \
917 itkDebugMacro("setting input " #name " to " << _arg); \
918 const DecoratorType * oldInput = \
919 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
920 ITK_GCC_PRAGMA_PUSH \
921 ITK_GCC_SUPPRESS_Wfloat_equal \
922 if (oldInput && oldInput->Get() == _arg) \
927 auto newInput = DecoratorType::New(); \
928 newInput->Set(_arg); \
929 this->Set##name##Input(newInput); \
931 ITK_MACROEND_NOOP_STATEMENT
936#define itkGetDecoratedInputMacro(name, type) \
937 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
939 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
940 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
942 virtual const type & Get##name() const \
944 itkDebugMacro("Getting input " #name); \
945 using DecoratorType = SimpleDataObjectDecorator<type>; \
946 const DecoratorType * input = \
947 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
948 if (input == nullptr) \
950 itkExceptionMacro("input" #name " is not set"); \
952 return input->Get(); \
954 ITK_MACROEND_NOOP_STATEMENT
959#define itkSetGetDecoratedInputMacro(name, type) \
960 itkSetDecoratedInputMacro(name, type); \
961 itkGetDecoratedInputMacro(name, type)
967#define itkSetDecoratedObjectInputMacro(name, type) \
968 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
970 itkDebugMacro("setting input " #name " to " << _arg); \
971 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
973 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
977 virtual void Set##name(const type * _arg) \
979 using DecoratorType = DataObjectDecorator<type>; \
980 itkDebugMacro("setting input " #name " to " << _arg); \
981 const DecoratorType * oldInput = \
982 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
983 if (oldInput && oldInput->Get() == _arg) \
987 auto newInput = DecoratorType::New(); \
988 newInput->Set(_arg); \
989 this->Set##name##Input(newInput); \
991 ITK_MACROEND_NOOP_STATEMENT
998#define itkGetDecoratedObjectInputMacro(name, type) \
999 virtual const DataObjectDecorator<type> * Get##name##Input() const \
1001 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
1002 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
1004 virtual const type * Get##name() const \
1006 itkDebugMacro("Getting input " #name); \
1007 using DecoratorType = DataObjectDecorator<type>; \
1008 const DecoratorType * input = \
1009 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1010 if (input == nullptr) \
1014 return input->Get(); \
1016 ITK_MACROEND_NOOP_STATEMENT
1021#define itkSetGetDecoratedObjectInputMacro(name, type) \
1022 itkSetDecoratedObjectInputMacro(name, type); \
1023 itkGetDecoratedObjectInputMacro(name, type)
1027#define itkSetMacro(name, type) \
1028 virtual void Set##name(type _arg) \
1030 itkDebugMacro("setting " #name " to " << _arg); \
1031 ITK_GCC_PRAGMA_PUSH \
1032 ITK_GCC_SUPPRESS_Wfloat_equal \
1033 if (this->m_##name != _arg) \
1035 this->m_##name = std::move(_arg); \
1038 ITK_GCC_PRAGMA_POP \
1040 ITK_MACROEND_NOOP_STATEMENT
1044#define itkGetMacro(name, type) \
1045 virtual type Get##name() { return this->m_##name; } \
1046 ITK_MACROEND_NOOP_STATEMENT
1052#define itkGetConstMacro(name, type) \
1053 virtual type Get##name() const { return this->m_##name; } \
1054 ITK_MACROEND_NOOP_STATEMENT
1061#define itkGetConstReferenceMacro(name, type) \
1062 virtual const type & Get##name() const { return this->m_##name; } \
1063 ITK_MACROEND_NOOP_STATEMENT
1070#define itkSetEnumMacro(name, type) \
1071 virtual void Set##name(const type _arg) \
1073 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1074 if (this->m_##name != _arg) \
1076 this->m_##name = _arg; \
1080 ITK_MACROEND_NOOP_STATEMENT
1087#define itkGetEnumMacro(name, type) \
1088 virtual type Get##name() const { return this->m_##name; } \
1089 ITK_MACROEND_NOOP_STATEMENT
1095#define itkSetStringMacro(name) \
1096 virtual void Set##name(const char * _arg) \
1098 if (_arg && (_arg == this->m_##name)) \
1104 this->m_##name = _arg; \
1108 this->m_##name = ""; \
1112 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1113 ITK_MACROEND_NOOP_STATEMENT
1120#define itkGetStringMacro(name) \
1121 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1122 ITK_MACROEND_NOOP_STATEMENT
1128#define itkSetClampMacro(name, type, min, max) \
1129 virtual void Set##name(type _arg) \
1131 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1132 itkDebugMacro("setting " << #name " to " << _arg); \
1133 ITK_GCC_PRAGMA_PUSH \
1134 ITK_GCC_SUPPRESS_Wfloat_equal \
1135 if (this->m_##name != temp_extrema) \
1137 this->m_##name = temp_extrema; \
1140 ITK_GCC_PRAGMA_POP \
1142 ITK_MACROEND_NOOP_STATEMENT
1150#define itkSetObjectMacro(name, type) \
1151 virtual void Set##name(type * _arg) \
1153 itkDebugMacro("setting " << #name " to " << _arg); \
1154 if (this->m_##name != _arg) \
1156 this->m_##name = _arg; \
1160 ITK_MACROEND_NOOP_STATEMENT
1189#define itkGetConstObjectMacro(name, type) \
1190 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1191 ITK_MACROEND_NOOP_STATEMENT
1194#if defined(ITK_FUTURE_LEGACY_REMOVE)
1200# define itkGetObjectMacro(name, type) \
1201 virtual type * Get##name() \
1203 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1206# define itkGetModifiableObjectMacro(name, type) \
1207 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1208 itkGetConstObjectMacro(name, type)
1213# define itkGetObjectMacro(name, type) \
1214 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1215 ITK_MACROEND_NOOP_STATEMENT
1216# define itkGetModifiableObjectMacro(name, type) \
1217 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1218 itkGetConstObjectMacro(name, type); \
1219 itkGetObjectMacro(name, type)
1229#define itkGetConstReferenceObjectMacro(name, type) \
1230 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1231 ITK_MACROEND_NOOP_STATEMENT
1236#define itkSetConstObjectMacro(name, type) \
1237 virtual void Set##name(const type * _arg) \
1239 itkDebugMacro("setting " << #name " to " << _arg); \
1240 if (this->m_##name != _arg) \
1242 this->m_##name = _arg; \
1246 ITK_MACROEND_NOOP_STATEMENT
1251#define itkBooleanMacro(name) \
1252 virtual void name##On() { this->Set##name(true); } \
1253 virtual void name##Off() { this->Set##name(false); }
1260#define itkSetVectorMacro(name, type, count) \
1261 virtual void Set##name(type data[]) \
1264 for (i = 0; i < count; ++i) \
1266 ITK_GCC_PRAGMA_PUSH \
1267 ITK_GCC_SUPPRESS_Wfloat_equal \
1268 if (data[i] != this->m_##name[i]) \
1272 ITK_GCC_PRAGMA_POP \
1277 for (i = 0; i < count; ++i) \
1279 this->m_##name[i] = data[i]; \
1283 ITK_MACROEND_NOOP_STATEMENT
1289#define itkGetVectorMacro(name, type, count) \
1290 virtual type * Get##name() const { return this->m_##name; } \
1291 ITK_MACROEND_NOOP_STATEMENT
1297#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1304#define itkGPUKernelMacro(kernel) \
1308 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1309 kernel() = delete; \
1310 ~kernel() = delete; \
1311 static const char * GetOpenCLSource(); \
1315#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1316 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); }
1320#define itkPrintSelfObjectMacro(name) \
1321 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1323 os << indent << #name << ": (null)" << std::endl; \
1327 os << indent << #name << ": " << std::endl; \
1328 this->m_##name->Print(os, indent.GetNextIndent()); \
1330 ITK_MACROEND_NOOP_STATEMENT
1334#define itkSetDecoratedOutputMacro(name, type) \
1335 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1337 itkDebugMacro("setting output " #name " to " << _arg); \
1338 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1340 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1344 virtual void Set##name(const type & _arg) \
1346 using DecoratorType = SimpleDataObjectDecorator<type>; \
1347 itkDebugMacro("setting output " #name " to " << _arg); \
1348 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1351 if (output->Get() == _arg) \
1357 output->Set(_arg); \
1362 auto newOutput = DecoratorType::New(); \
1363 newOutput->Set(_arg); \
1364 this->Set##name##Output(newOutput); \
1367 ITK_MACROEND_NOOP_STATEMENT
1371#define itkGetDecoratedOutputMacro(name, type) \
1372 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1374 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1375 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1377 virtual const type & Get##name() const \
1379 itkDebugMacro("Getting output " #name); \
1380 using DecoratorType = SimpleDataObjectDecorator<type>; \
1381 const DecoratorType * output = \
1382 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1383 if (output == nullptr) \
1385 itkExceptionMacro("output" #name " is not set"); \
1387 return output->Get(); \
1389 ITK_MACROEND_NOOP_STATEMENT
1402#if defined(ITKV4_COMPATIBILITY)
1403# define ITK_ITERATOR_VIRTUAL virtual
1404# define ITK_ITERATOR_OVERRIDE override
1405# define ITK_ITERATOR_FINAL
1406#elif !defined(ITK_LEGACY_REMOVE)
1407# define ITK_ITERATOR_VIRTUAL virtual
1408# define ITK_ITERATOR_OVERRIDE override
1409# define ITK_ITERATOR_FINAL final
1411# define ITK_ITERATOR_VIRTUAL
1412# define ITK_ITERATOR_OVERRIDE
1413# define ITK_ITERATOR_FINAL
1416#if defined(ITKV4_COMPATIBILITY)
1421# define ITKv5_CONST const
1424#define itkExceptionObject_h
1426#undef itkExceptionObject_h
1435template <
typename TTarget,
typename TSource>
1437itkDynamicCastInDebugMode(TSource x)
1444 TTarget rval =
dynamic_cast<TTarget
>(x);
1445 if (rval ==
nullptr)
1447 itkGenericExceptionMacro(
"Failed dynamic cast to " <<
typeid(TTarget).name()
1448 <<
" object type = " << x->GetNameOfClass());
1452 return static_cast<TTarget
>(x);
1457#ifdef ITK_LEGACY_REMOVE
1458# if __cplusplus >= 202002L
1459# define ITK_NODISCARD(message) [[nodiscard(message)]]
1461# define ITK_NODISCARD(message) [[nodiscard]]
1464# define ITK_NODISCARD(message)
1468#define ITK_ALIGNAS(X) alignas(X)
1469#define ITK_ALIGNOF(X) alignof(X)
1470#define ITK_DEPRECATED [[deprecated]]
1471#define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1472#define ITK_CONSTEXPR constexpr
1473#define ITK_DELETED_FUNCTION = delete
1474#define ITK_EXTERN_TEMPLATE extern
1475#define ITK_FINAL final
1476#define ITK_NOEXCEPT noexcept
1477#define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1478#define ITK_NULLPTR nullptr
1479#define ITK_OVERRIDE override
1480#define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1481#define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1482#define ITK_THREAD_LOCAL thread_local
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....