42#include "itkConfigure.h"
43#include "ITKCommonExport.h"
81#define ITK_NOOP_STATEMENT static_assert(true, "")
92#define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
99#define ITK_PRAGMA(x) _Pragma(#x)
107# define ITK_GCC_PRAGMA_PUSH ITK_PRAGMA(GCC diagnostic push)
108# define ITK_GCC_PRAGMA_POP ITK_PRAGMA(GCC diagnostic pop)
109# define ITK_GCC_SUPPRESS_Wfloat_equal ITK_PRAGMA(GCC diagnostic ignored "-Wfloat-equal")
110# define ITK_GCC_SUPPRESS_Wformat_nonliteral ITK_PRAGMA(GCC diagnostic ignored "-Wformat-nonliteral")
111# define ITK_GCC_SUPPRESS_Warray_bounds ITK_PRAGMA(GCC diagnostic ignored "-Warray-bounds")
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
117# define ITK_GCC_SUPPRESS_Warray_bounds
121#if defined(__clang__) && defined(__has_warning)
122# define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
123# define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
124# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
125 ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
127# define ITK_CLANG_PRAGMA_PUSH
128# define ITK_CLANG_PRAGMA_POP
129# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
134#define CLANG_PRAGMA_PUSH ITK_CLANG_PRAGMA_PUSH
135#define CLANG_PRAGMA_POP ITK_CLANG_PRAGMA_POP
136#define CLANG_SUPPRESS_Wfloat_equal ITK_GCC_SUPPRESS_Wfloat_equal
138#if !defined(ITK_LEGACY_REMOVE)
140# define CLANG_SUPPRESS_Wcpp14_extensions \
141 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
142 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
146#if defined(__INTEL_COMPILER)
147# define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
148# define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
149# define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
151# define INTEL_PRAGMA_WARN_PUSH
152# define INTEL_PRAGMA_WARN_POP
153# define INTEL_SUPPRESS_warning_1292
164#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
165# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
166# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
167# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
169# define ITK_GCC_PRAGMA_DIAG(x)
170# define ITK_GCC_PRAGMA_DIAG_PUSH()
171# define ITK_GCC_PRAGMA_DIAG_POP()
178#if defined(_MSC_VER) && (_MSC_VER < 1920)
179# error "MSVC versions before Visual Studio 2019 are not supported"
181#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
182# error "SUNPro C++ < 5.14.0 is not supported"
184#if defined(__CYGWIN__)
185# error "The Cygwin compiler is not supported"
187#if defined(__BORLANDC__)
188# error "The Borland C compiler is not supported"
190#if defined(__MWERKS__)
191# error "The MetroWerks compiler is not supported"
193#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
194# error "GCC < 7 is not supported"
200# error "The SGI compiler is not supported"
202#if defined(__APPLE__)
203# if defined(__clang__) && (__cplusplus < 201703L)
204# error "Apple LLVM compiling with a standard less than C++17 is not supported"
206#elif defined(__clang__) && (__clang_major__ < 5)
207# error "Clang < 5 is not supported"
209#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
210# error "Intel C++ < 19.1 is not supported4"
214#if defined(_WIN32) || defined(WIN32)
215# define ITK_ABI_IMPORT __declspec(dllimport)
216# define ITK_ABI_EXPORT __declspec(dllexport)
217# define ITK_ABI_HIDDEN
220# define ITK_ABI_IMPORT __attribute__((visibility("default")))
221# define ITK_ABI_EXPORT __attribute__((visibility("default")))
222# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
224# define ITK_ABI_IMPORT
225# define ITK_ABI_EXPORT
226# define ITK_ABI_HIDDEN
231#ifndef ITK_TEMPLATE_EXPORT
232# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
233# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
235# define ITK_TEMPLATE_EXPORT
240#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
241# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
243# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
246#ifndef ITK_FORWARD_EXPORT
248# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
249 defined(USE_COMPILER_HIDDEN_VISIBILITY)
250# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
252# define ITK_FORWARD_EXPORT
278#define itkNewMacro(x) \
279 itkSimpleNewMacro(x); \
280 itkCreateAnotherMacro(x); \
282 ITK_MACROEND_NOOP_STATEMENT
284#define itkSimpleNewMacro(x) \
285 static Pointer New() \
287 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
288 if (smartPtr == nullptr) \
290 smartPtr = new x(); \
292 smartPtr->UnRegister(); \
295 ITK_MACROEND_NOOP_STATEMENT
297#define itkCreateAnotherMacro(x) \
298 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
299 ITK_MACROEND_NOOP_STATEMENT
301#define itkCloneMacro(x) \
302 Pointer Clone() const \
304 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
307 ITK_MACROEND_NOOP_STATEMENT
313#define itkFactoryOnlyNewMacro(x) \
314 itkSimpleFactoryOnlyNewMacro(x); \
315 itkCreateAnotherMacro(x); \
317 ITK_MACROEND_NOOP_STATEMENT
319#define itkSimpleFactoryOnlyNewMacro(x) \
320 static auto New() -> Pointer \
322 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
323 if (smartPtr == nullptr) \
325 itkSpecializedMessageExceptionMacro(ExceptionObject, \
326 "Object factory failed to instantiate " << typeid(x).name()); \
328 smartPtr->UnRegister(); \
331 ITK_MACROEND_NOOP_STATEMENT
346#define itkFactorylessNewMacro(x) \
347 static Pointer New() \
349 auto * rawPtr = new x(); \
350 Pointer smartPtr = rawPtr; \
351 rawPtr->UnRegister(); \
354 itkCreateAnotherMacro(x); \
355 ITK_MACROEND_NOOP_STATEMENT
366#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
367 TypeName(const TypeName &) = delete; \
368 TypeName & operator=(const TypeName &) = delete; \
369 TypeName(TypeName &&) = delete; \
370 TypeName & operator=(TypeName &&) = delete
372#if !defined(ITK_LEGACY_REMOVE)
373# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
375# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
376 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
388#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
389 TypeName(const TypeName &) = default; \
390 TypeName & operator=(const TypeName &) = default; \
391 TypeName(TypeName &&) = default; \
392 TypeName & operator=(TypeName &&) = default
399#if __cplusplus >= 202002L
400# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
406#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
409# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
413# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
414 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
415 ITK_MACROEND_NOOP_STATEMENT
420#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
422 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
423 "The macro argument `" #thisClass \
424 "` appears incorrect! It should correspond with the name of this class!"); \
427 ITK_MACROEND_NOOP_STATEMENT
433#define itkVirtualGetNameOfClassMacro(thisClass) \
434 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
436#define itkOverrideGetNameOfClassMacro(thisClass) \
437 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
439#ifdef ITK_FUTURE_LEGACY_REMOVE
440# define itkTypeMacro(thisClass, superclass) \
441 static_assert(false, \
442 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
443 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
444# define itkTypeMacroNoParent(thisClass) \
445 static_assert(false, \
446 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
447 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
453# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
454# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
467extern ITKCommon_EXPORT
void
468OutputWindowDisplayText(
const char *);
470extern ITKCommon_EXPORT
void
471OutputWindowDisplayErrorText(
const char *);
473extern ITKCommon_EXPORT
void
474OutputWindowDisplayWarningText(
const char *);
476extern ITKCommon_EXPORT
void
477OutputWindowDisplayGenericOutputText(
const char *);
479extern ITKCommon_EXPORT
void
480OutputWindowDisplayDebugText(
const char *);
492# define itkDebugMacro(x) ITK_NOOP_STATEMENT
493# define itkDebugStatement(x) ITK_NOOP_STATEMENT
495# define itkDebugMacro(x) \
497 using namespace ::itk::print_helper; \
498 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
500 std::ostringstream itkmsg; \
501 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' \
502 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
503 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
506 ITK_MACROEND_NOOP_STATEMENT
509# define itkDebugStatement(x) x
515#define itkWarningMacro(x) \
517 if (::itk::Object::GetGlobalWarningDisplay()) \
519 std::ostringstream itkmsg; \
520 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' \
521 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
522 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
525 ITK_MACROEND_NOOP_STATEMENT
528#define itkWarningStatement(x) x
530#if defined(ITK_CPP_FUNCTION)
531# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
532# define ITK_LOCATION __FUNCSIG__
533# elif defined(__GNUC__)
534# define ITK_LOCATION __PRETTY_FUNCTION__
536# define ITK_LOCATION __FUNCTION__
539# define ITK_LOCATION "unknown"
542#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
545 class newexcp : public parentexcp \
549 static constexpr const char * const default_exception_message = whatmessage; \
551 using parentexcp::parentexcp; \
552 itkOverrideGetNameOfClassMacro(newexcp); \
555 ITK_MACROEND_NOOP_STATEMENT
558#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
560 std::ostringstream exceptionDescriptionOutputStringStream; \
561 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
562 throw ::itk::ExceptionType( \
563 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
565 ITK_MACROEND_NOOP_STATEMENT
567#define itkSpecializedExceptionMacro(ExceptionType) \
568 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
573#define itkExceptionMacro(x) \
574 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << '(' << this << "): " x)
576#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
578#define itkGenericOutputMacro(x) \
580 if (::itk::Object::GetGlobalWarningDisplay()) \
582 std::ostringstream itkmsg; \
583 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
584 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
587 ITK_MACROEND_NOOP_STATEMENT
592#define itkLogMacro(x, y) \
594 if (this->GetLogger()) \
596 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
599 ITK_MACROEND_NOOP_STATEMENT
601#define itkLogMacroStatic(obj, x, y) \
603 if (obj->GetLogger()) \
605 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
608 ITK_MACROEND_NOOP_STATEMENT
639#if defined(ITK_LEGACY_REMOVE)
640# define itkLegacyMacro(method)
642# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
644# define itkLegacyMacro(method) method
647# define itkLegacyMacro(method) [[deprecated]] method
673#if defined(ITK_LEGACY_SILENT)
674# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
675# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
676# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
677# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
679# define itkLegacyBodyMacro(method, version) \
680 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
681# define itkLegacyReplaceBodyMacro(method, version, replace) \
682 itkWarningMacro(#method " was deprecated for ITK " #version \
683 " and will be removed in a future version. Use " #replace " instead.")
684# define itkGenericLegacyBodyMacro(method, version) \
685 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
686# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
687 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
688 " and will be removed in a future version. Use " #replace " instead.")
695#define ITK_CACHE_LINE_ALIGNMENT 64
703#define itkPadStruct(mincachesize, oldtype, newtype) \
704 struct newtype : public oldtype \
706 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
713#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
714# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
715#elif defined(_MSC_VER)
716# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
718# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
721#if defined(ITK_FUTURE_LEGACY_REMOVE)
744# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
746# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
762#define itkForLoopAssignmentMacro( \
763 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
764 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
766 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
768 ITK_MACROEND_NOOP_STATEMENT
779#define itkForLoopRoundingAndAssignmentMacro( \
780 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
781 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
783 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
785 ITK_MACROEND_NOOP_STATEMENT
789#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
792# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
794# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
798# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
801#define itkAssertOrThrowMacro(test, message) \
804 std::ostringstream msgstr; \
806 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
808 ITK_MACROEND_NOOP_STATEMENT
810#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
811# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
813# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
823#ifdef ITK_FUTURE_LEGACY_REMOVE
824# define itkStaticConstMacro(name, type, value) \
825 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
826# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
842# define itkStaticConstMacro(name, type, value) static constexpr type name = value
844# define itkGetStaticConstMacro(name) (Self::name)
849#define itkSetInputMacro(name, type) \
850 virtual void Set##name(const type * _arg) \
852 itkDebugMacro("setting input " #name " to " << _arg); \
853 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
855 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
859 ITK_MACROEND_NOOP_STATEMENT
863#define itkGetInputMacro(name, type) \
864 virtual const type * Get##name() const \
866 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
867 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
869 ITK_MACROEND_NOOP_STATEMENT
874#define itkSetDecoratedInputMacro(name, type) \
875 virtual void Set## name## Input(const SimpleDataObjectDecorator<type> * _arg) \
877 itkDebugMacro("setting input " #name " to " << _arg); \
878 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
880 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
884 virtual void Set## name(const SimpleDataObjectDecorator<type> * _arg) { this->Set## name## Input(_arg); } \
885 virtual void Set## name(const type & _arg) \
887 using DecoratorType = SimpleDataObjectDecorator<type>; \
888 itkDebugMacro("setting input " #name " to " << _arg); \
889 const DecoratorType * oldInput = \
890 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
891 ITK_GCC_PRAGMA_PUSH \
892 ITK_GCC_SUPPRESS_Wfloat_equal \
893 if (oldInput && oldInput->Get() == _arg) \
898 auto newInput = DecoratorType::New(); \
899 newInput->Set(_arg); \
900 this->Set## name## Input(newInput); \
902 ITK_MACROEND_NOOP_STATEMENT
907#define itkGetDecoratedInputMacro(name, type) \
908 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
910 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
911 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
913 virtual const type & Get##name() const \
915 itkDebugMacro("Getting input " #name); \
916 using DecoratorType = SimpleDataObjectDecorator<type>; \
917 const DecoratorType * input = \
918 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
919 if (input == nullptr) \
921 itkExceptionMacro("input" #name " is not set"); \
923 return input->Get(); \
925 ITK_MACROEND_NOOP_STATEMENT
929#define itkSetGetDecoratedInputMacro(name, type) \
930 itkSetDecoratedInputMacro(name, type); \
931 itkGetDecoratedInputMacro(name, type)
938#define itkSetDecoratedObjectInputMacro(name, type) \
939 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
941 itkDebugMacro("setting input " #name " to " << _arg); \
942 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
944 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
948 virtual void Set##name(const type * _arg) \
950 using DecoratorType = DataObjectDecorator<type>; \
951 itkDebugMacro("setting input " #name " to " << _arg); \
952 const DecoratorType * oldInput = \
953 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
954 if (oldInput && oldInput->Get() == _arg) \
958 auto newInput = DecoratorType::New(); \
959 newInput->Set(_arg); \
960 this->Set##name##Input(newInput); \
962 ITK_MACROEND_NOOP_STATEMENT
969#define itkGetDecoratedObjectInputMacro(name, type) \
970 virtual const DataObjectDecorator<type> * Get##name##Input() const \
972 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
973 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
975 virtual const type * Get##name() const \
977 itkDebugMacro("Getting input " #name); \
978 using DecoratorType = DataObjectDecorator<type>; \
979 const DecoratorType * input = \
980 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
981 if (input == nullptr) \
985 return input->Get(); \
987 ITK_MACROEND_NOOP_STATEMENT
991#define itkSetGetDecoratedObjectInputMacro(name, type) \
992 itkSetDecoratedObjectInputMacro(name, type); \
993 itkGetDecoratedObjectInputMacro(name, type)
997#define itkSetMacro(name, type) \
998 virtual void Set## name(type _arg) \
1000 itkDebugMacro("setting " #name " to " << _arg); \
1001 ITK_GCC_PRAGMA_PUSH \
1002 ITK_GCC_SUPPRESS_Wfloat_equal \
1003 if (this->m_## name != _arg) \
1005 this->m_## name = std::move(_arg); \
1008 ITK_GCC_PRAGMA_POP \
1010 ITK_MACROEND_NOOP_STATEMENT
1015#define itkGetMacro(name, type) \
1016 virtual type Get##name() { return this->m_##name; } \
1017 ITK_MACROEND_NOOP_STATEMENT
1023#define itkGetConstMacro(name, type) \
1024 virtual type Get##name() const { return this->m_##name; } \
1025 ITK_MACROEND_NOOP_STATEMENT
1032#define itkGetConstReferenceMacro(name, type) \
1033 virtual const type & Get##name() const { return this->m_##name; } \
1034 ITK_MACROEND_NOOP_STATEMENT
1041#define itkSetEnumMacro(name, type) \
1042 virtual void Set##name(const type _arg) \
1044 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1045 if (this->m_##name != _arg) \
1047 this->m_##name = _arg; \
1051 ITK_MACROEND_NOOP_STATEMENT
1058#define itkGetEnumMacro(name, type) \
1059 virtual type Get##name() const { return this->m_##name; } \
1060 ITK_MACROEND_NOOP_STATEMENT
1066#define itkSetStringMacro(name) \
1067 virtual void Set##name(const char * _arg) \
1069 if (_arg && (_arg == this->m_##name)) \
1075 this->m_##name = _arg; \
1079 this->m_##name = ""; \
1083 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1084 ITK_MACROEND_NOOP_STATEMENT
1090#define itkGetStringMacro(name) \
1091 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1092 ITK_MACROEND_NOOP_STATEMENT
1099#define itkSetClampMacro(name, type, min, max) \
1100 virtual void Set## name(type _arg) \
1102 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1103 itkDebugMacro("setting " << #name " to " << _arg); \
1104 ITK_GCC_PRAGMA_PUSH \
1105 ITK_GCC_SUPPRESS_Wfloat_equal \
1106 if (this->m_## name != temp_extrema) \
1108 this->m_## name = temp_extrema; \
1111 ITK_GCC_PRAGMA_POP \
1113 ITK_MACROEND_NOOP_STATEMENT
1121#define itkSetObjectMacro(name, type) \
1122 virtual void Set## name(type * _arg) \
1124 itkDebugMacro("setting " << #name " to " << _arg); \
1125 if (this->m_## name != _arg) \
1127 this->m_## name = _arg; \
1131 ITK_MACROEND_NOOP_STATEMENT
1159#define itkGetConstObjectMacro(name, type) \
1160 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1161 ITK_MACROEND_NOOP_STATEMENT
1164#if defined(ITK_FUTURE_LEGACY_REMOVE)
1170# define itkGetObjectMacro(name, type) \
1171 virtual type * Get##name() \
1173 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1175 ITK_MACROEND_NOOP_STATEMENT
1177# define itkGetModifiableObjectMacro(name, type) \
1178 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1179 itkGetConstObjectMacro(name, type)
1185# define itkGetObjectMacro(name, type) \
1186 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1187 ITK_MACROEND_NOOP_STATEMENT
1188# define itkGetModifiableObjectMacro(name, type) \
1189 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1190 itkGetConstObjectMacro(name, type); \
1191 itkGetObjectMacro(name, type)
1201#define itkGetConstReferenceObjectMacro(name, type) \
1202 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1203 ITK_MACROEND_NOOP_STATEMENT
1209#define itkSetConstObjectMacro(name, type) \
1210 virtual void Set##name(const type * _arg) \
1212 itkDebugMacro("setting " << #name " to " << _arg); \
1213 if (this->m_##name != _arg) \
1215 this->m_##name = _arg; \
1219 ITK_MACROEND_NOOP_STATEMENT
1224#define itkBooleanMacro(name) \
1225 virtual void name##On() { this->Set##name(true); } \
1226 virtual void name##Off() { this->Set##name(false); } \
1227 ITK_MACROEND_NOOP_STATEMENT
1238template <
typename MemberContainerType,
typename CopyFromValueType,
typename LoopEndType>
1240ContainerFillWithCheck(MemberContainerType & m,
const CopyFromValueType & c,
const LoopEndType N)
1242 bool value_updated =
false;
1243 for (
unsigned int i = 0; i < N; ++i)
1246 ITK_GCC_SUPPRESS_Wfloat_equal
1250 value_updated =
true;
1254 return value_updated;
1265template <
typename MemberContainerType,
typename CopyFromContainerType,
typename LoopEndType>
1267ContainerCopyWithCheck(MemberContainerType & m,
const CopyFromContainerType & c,
const LoopEndType N)
1269 bool value_updated =
false;
1270 for (LoopEndType i = 0; i < N; ++i)
1273 ITK_GCC_SUPPRESS_Wfloat_equal
1277 value_updated =
true;
1281 return value_updated;
1289#define itkSetVectorMacro(name, type, count) \
1290 virtual void Set## name(type data[]) \
1292 if (ContainerCopyWithCheck( this->m_## name, data, count)) \
1297 ITK_MACROEND_NOOP_STATEMENT
1302#define itkGetVectorMacro(name, type, count) \
1303 virtual type * Get##name() const { return this->m_##name; } \
1304 ITK_MACROEND_NOOP_STATEMENT
1310#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1318#define itkGPUKernelMacro(kernel) \
1322 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1323 kernel() = delete; \
1324 ~kernel() = delete; \
1325 static const char * GetOpenCLSource(); \
1328#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1329 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1330 ITK_MACROEND_NOOP_STATEMENT
1334#define itkPrintSelfObjectMacro(name) \
1335 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1337 os << indent << #name << ": (null)" << std::endl; \
1341 os << indent << #name << ": " << std::endl; \
1342 this->m_##name->Print(os, indent.GetNextIndent()); \
1344 ITK_MACROEND_NOOP_STATEMENT
1349#define itkPrintSelfBooleanMacro(name) \
1350 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1351 ITK_MACROEND_NOOP_STATEMENT
1356#define itkSetDecoratedOutputMacro(name, type) \
1357 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1359 itkDebugMacro("setting output " #name " to " << _arg); \
1360 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1362 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1366 virtual void Set##name(const type & _arg) \
1368 using DecoratorType = SimpleDataObjectDecorator<type>; \
1369 itkDebugMacro("setting output " #name " to " << _arg); \
1370 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1373 if (output->Get() == _arg) \
1379 output->Set(_arg); \
1384 auto newOutput = DecoratorType::New(); \
1385 newOutput->Set(_arg); \
1386 this->Set##name##Output(newOutput); \
1389 ITK_MACROEND_NOOP_STATEMENT
1393#define itkGetDecoratedOutputMacro(name, type) \
1394 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1396 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1397 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1399 virtual const type & Get##name() const \
1401 itkDebugMacro("Getting output " #name); \
1402 using DecoratorType = SimpleDataObjectDecorator<type>; \
1403 const DecoratorType * output = \
1404 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1405 if (output == nullptr) \
1407 itkExceptionMacro("output" #name " is not set"); \
1409 return output->Get(); \
1411 ITK_MACROEND_NOOP_STATEMENT
1415#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1416# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1418# define ITK_FUTURE_DEPRECATED(message)
1421#if __cplusplus >= 202002L
1422# define ITK_NODISCARD(message) [[nodiscard(message)]]
1424# define ITK_NODISCARD(message) [[nodiscard]]
1429#if defined(ITK_LEGACY_REMOVE)
1430# define itkExposeEnumValue(name) \
1431 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1433# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1435# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1436# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1437# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1439# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1442# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1443# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1444# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1445# define ITK_DEPRECATED_MSG \
1446 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1447# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1448# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1449# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1450# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1451# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1452# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1453# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1454# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1455# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1456# define ITK_STATIC_ASSERT_MSG \
1457 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1458# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1461# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1463# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1464# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1465# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1474# define itkExposeEnumValue(name) static_cast<int>(name)
1477# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1479# define ITK_FALLTHROUGH [[fallthrough]]
1481# define ITK_DELETE_FUNCTION = delete
1483# define ITK_CONSTEXPR_FUNC constexpr
1484# define ITK_CONSTEXPR_VAR constexpr
1487# define ITK_ALIGNAS(X) alignas(X)
1488# define ITK_ALIGNOF(X) alignof(X)
1489# define ITK_DEPRECATED [[deprecated]]
1490# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1491# define ITK_CONSTEXPR constexpr
1492# define ITK_DELETED_FUNCTION = delete
1493# define ITK_EXTERN_TEMPLATE extern
1494# define ITK_FINAL final
1495# define ITK_NOEXCEPT noexcept
1496# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1497# define ITK_NULLPTR nullptr
1498# define ITK_OVERRIDE override
1499# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1500# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1501# define ITK_THREAD_LOCAL thread_local
1504# define ITKv5_CONST const
1506# define ITK_ITERATOR_VIRTUAL
1507# define ITK_ITERATOR_OVERRIDE
1508# define ITK_ITERATOR_FINAL
1511#define allow_inclusion_of_itkExceptionObject_h
1517#undef allow_inclusion_of_itkExceptionObject_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....