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
140# define ITK_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
142# define ITK_FORMAT_PRINTF(a, b)
145#if !defined(ITK_LEGACY_REMOVE)
147# define CLANG_SUPPRESS_Wcpp14_extensions \
148 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
149 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
153#if defined(__INTEL_COMPILER)
154# define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
155# define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
156# define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
158# define INTEL_PRAGMA_WARN_PUSH
159# define INTEL_PRAGMA_WARN_POP
160# define INTEL_SUPPRESS_warning_1292
171#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
172# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
173# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
174# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
176# define ITK_GCC_PRAGMA_DIAG(x)
177# define ITK_GCC_PRAGMA_DIAG_PUSH()
178# define ITK_GCC_PRAGMA_DIAG_POP()
185#if defined(_MSC_VER) && (_MSC_VER < 1920)
186# error "MSVC versions before Visual Studio 2019 are not supported"
188#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
189# error "SUNPro C++ < 5.14.0 is not supported"
191#if defined(__CYGWIN__)
192# error "The Cygwin compiler is not supported"
194#if defined(__BORLANDC__)
195# error "The Borland C compiler is not supported"
197#if defined(__MWERKS__)
198# error "The MetroWerks compiler is not supported"
200#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
201# error "GCC < 7 is not supported"
207# error "The SGI compiler is not supported"
209#if defined(__APPLE__)
210# if defined(__clang__) && (__cplusplus < 201703L)
211# error "Apple LLVM compiling with a standard less than C++17 is not supported"
213#elif defined(__clang__) && (__clang_major__ < 5)
214# error "Clang < 5 is not supported"
216#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
217# error "Intel C++ < 19.1 is not supported4"
221#if defined(_WIN32) || defined(WIN32)
222# define ITK_ABI_IMPORT __declspec(dllimport)
223# define ITK_ABI_EXPORT __declspec(dllexport)
224# define ITK_ABI_HIDDEN
227# define ITK_ABI_IMPORT __attribute__((visibility("default")))
228# define ITK_ABI_EXPORT __attribute__((visibility("default")))
229# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
231# define ITK_ABI_IMPORT
232# define ITK_ABI_EXPORT
233# define ITK_ABI_HIDDEN
238#ifndef ITK_TEMPLATE_EXPORT
239# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
240# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
242# define ITK_TEMPLATE_EXPORT
247#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
248# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
250# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
253#ifndef ITK_FORWARD_EXPORT
255# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
256 defined(USE_COMPILER_HIDDEN_VISIBILITY)
257# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
259# define ITK_FORWARD_EXPORT
285#define itkNewMacro(x) \
286 itkSimpleNewMacro(x); \
287 itkCreateAnotherMacro(x); \
289 ITK_MACROEND_NOOP_STATEMENT
291#define itkSimpleNewMacro(x) \
292 static Pointer New() \
294 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
295 if (smartPtr == nullptr) \
297 smartPtr = new x(); \
299 smartPtr->UnRegister(); \
302 ITK_MACROEND_NOOP_STATEMENT
304#define itkCreateAnotherMacro(x) \
305 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
306 ITK_MACROEND_NOOP_STATEMENT
308#define itkCloneMacro(x) \
309 Pointer Clone() const \
311 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
314 ITK_MACROEND_NOOP_STATEMENT
320#define itkFactoryOnlyNewMacro(x) \
321 itkSimpleFactoryOnlyNewMacro(x); \
322 itkCreateAnotherMacro(x); \
324 ITK_MACROEND_NOOP_STATEMENT
326#define itkSimpleFactoryOnlyNewMacro(x) \
327 static auto New() -> Pointer \
329 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
330 if (smartPtr == nullptr) \
332 itkSpecializedMessageExceptionMacro(ExceptionObject, \
333 "Object factory failed to instantiate " << typeid(x).name()); \
335 smartPtr->UnRegister(); \
338 ITK_MACROEND_NOOP_STATEMENT
353#define itkFactorylessNewMacro(x) \
354 static Pointer New() \
356 auto * rawPtr = new x(); \
357 Pointer smartPtr = rawPtr; \
358 rawPtr->UnRegister(); \
361 itkCreateAnotherMacro(x); \
362 ITK_MACROEND_NOOP_STATEMENT
373#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
374 TypeName(const TypeName &) = delete; \
375 TypeName & operator=(const TypeName &) = delete; \
376 TypeName(TypeName &&) = delete; \
377 TypeName & operator=(TypeName &&) = delete
379#if !defined(ITK_LEGACY_REMOVE)
380# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
382# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
383 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
395#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
396 TypeName(const TypeName &) = default; \
397 TypeName & operator=(const TypeName &) = default; \
398 TypeName(TypeName &&) = default; \
399 TypeName & operator=(TypeName &&) = default
406#if __cplusplus >= 202002L
407# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
413#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
416# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
420# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
421 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
422 ITK_MACROEND_NOOP_STATEMENT
427#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
429 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
430 "The macro argument `" #thisClass \
431 "` appears incorrect! It should correspond with the name of this class!"); \
434 ITK_MACROEND_NOOP_STATEMENT
440#define itkVirtualGetNameOfClassMacro(thisClass) \
441 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
443#define itkOverrideGetNameOfClassMacro(thisClass) \
444 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
446#ifdef ITK_FUTURE_LEGACY_REMOVE
447# define itkTypeMacro(thisClass, superclass) \
448 static_assert(false, \
449 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
450 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
451# define itkTypeMacroNoParent(thisClass) \
452 static_assert(false, \
453 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
454 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
460# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
461# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
474extern ITKCommon_EXPORT
void
475OutputWindowDisplayText(
const char *);
477extern ITKCommon_EXPORT
void
478OutputWindowDisplayErrorText(
const char *);
480extern ITKCommon_EXPORT
void
481OutputWindowDisplayWarningText(
const char *);
483extern ITKCommon_EXPORT
void
484OutputWindowDisplayGenericOutputText(
const char *);
486extern ITKCommon_EXPORT
void
487OutputWindowDisplayDebugText(
const char *);
499# define itkDebugMacro(x) ITK_NOOP_STATEMENT
500# define itkDebugStatement(x) ITK_NOOP_STATEMENT
502# define itkDebugMacro(x) \
504 using namespace ::itk::print_helper; \
505 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
507 std::ostringstream itkmsg; \
508 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' \
509 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
510 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
513 ITK_MACROEND_NOOP_STATEMENT
516# define itkDebugStatement(x) x
522#define itkWarningMacro(x) \
524 if (::itk::Object::GetGlobalWarningDisplay()) \
526 std::ostringstream itkmsg; \
527 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' \
528 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
529 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
532 ITK_MACROEND_NOOP_STATEMENT
535#define itkWarningStatement(x) x
537#if defined(ITK_CPP_FUNCTION)
538# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
539# define ITK_LOCATION __FUNCSIG__
540# elif defined(__GNUC__)
541# define ITK_LOCATION __PRETTY_FUNCTION__
543# define ITK_LOCATION __FUNCTION__
546# define ITK_LOCATION "unknown"
549#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
552 class newexcp : public parentexcp \
556 static constexpr const char * const default_exception_message = whatmessage; \
558 using parentexcp::parentexcp; \
559 itkOverrideGetNameOfClassMacro(newexcp); \
562 ITK_MACROEND_NOOP_STATEMENT
565#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
567 std::ostringstream exceptionDescriptionOutputStringStream; \
568 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
569 throw ::itk::ExceptionType( \
570 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
572 ITK_MACROEND_NOOP_STATEMENT
574#define itkSpecializedExceptionMacro(ExceptionType) \
575 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
580#define itkExceptionMacro(x) \
581 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << '(' << this << "): " x)
583#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
585#define itkGenericOutputMacro(x) \
587 if (::itk::Object::GetGlobalWarningDisplay()) \
589 std::ostringstream itkmsg; \
590 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
591 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
594 ITK_MACROEND_NOOP_STATEMENT
599#define itkLogMacro(x, y) \
601 if (this->GetLogger()) \
603 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
606 ITK_MACROEND_NOOP_STATEMENT
608#define itkLogMacroStatic(obj, x, y) \
610 if (obj->GetLogger()) \
612 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
615 ITK_MACROEND_NOOP_STATEMENT
646#if defined(ITK_LEGACY_REMOVE)
647# define itkLegacyMacro(method)
649# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
651# define itkLegacyMacro(method) method
654# define itkLegacyMacro(method) [[deprecated]] method
680#if defined(ITK_LEGACY_SILENT)
681# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
682# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
683# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
684# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
686# define itkLegacyBodyMacro(method, version) \
687 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
688# define itkLegacyReplaceBodyMacro(method, version, replace) \
689 itkWarningMacro(#method " was deprecated for ITK " #version \
690 " and will be removed in a future version. Use " #replace " instead.")
691# define itkGenericLegacyBodyMacro(method, version) \
692 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
693# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
694 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
695 " and will be removed in a future version. Use " #replace " instead.")
702#define ITK_CACHE_LINE_ALIGNMENT 64
710#define itkPadStruct(mincachesize, oldtype, newtype) \
711 struct newtype : public oldtype \
713 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
720#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
721# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
722#elif defined(_MSC_VER)
723# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
725# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
728#if defined(ITK_FUTURE_LEGACY_REMOVE)
751# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
753# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
769#define itkForLoopAssignmentMacro( \
770 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
771 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
773 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
775 ITK_MACROEND_NOOP_STATEMENT
786#define itkForLoopRoundingAndAssignmentMacro( \
787 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
788 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
790 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
792 ITK_MACROEND_NOOP_STATEMENT
796#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
799# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
801# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
805# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
808#define itkAssertOrThrowMacro(test, message) \
811 std::ostringstream msgstr; \
813 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
815 ITK_MACROEND_NOOP_STATEMENT
817#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
818# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
820# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
830#ifdef ITK_FUTURE_LEGACY_REMOVE
831# define itkStaticConstMacro(name, type, value) \
832 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
833# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
849# define itkStaticConstMacro(name, type, value) static constexpr type name = value
851# define itkGetStaticConstMacro(name) (Self::name)
856#define itkSetInputMacro(name, type) \
857 virtual void Set##name(const type * _arg) \
859 itkDebugMacro("setting input " #name " to " << _arg); \
860 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
862 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
866 ITK_MACROEND_NOOP_STATEMENT
870#define itkGetInputMacro(name, type) \
871 virtual const type * Get##name() const \
873 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
874 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
876 ITK_MACROEND_NOOP_STATEMENT
881#define itkSetDecoratedInputMacro(name, type) \
882 virtual void Set## name## Input(const SimpleDataObjectDecorator<type> * _arg) \
884 itkDebugMacro("setting input " #name " to " << _arg); \
885 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
887 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
891 virtual void Set## name(const SimpleDataObjectDecorator<type> * _arg) { this->Set## name## Input(_arg); } \
892 virtual void Set## name(const type & _arg) \
894 using DecoratorType = SimpleDataObjectDecorator<type>; \
895 itkDebugMacro("setting input " #name " to " << _arg); \
896 const DecoratorType * oldInput = \
897 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
898 ITK_GCC_PRAGMA_PUSH \
899 ITK_GCC_SUPPRESS_Wfloat_equal \
900 if (oldInput && oldInput->Get() == _arg) \
905 auto newInput = DecoratorType::New(); \
906 newInput->Set(_arg); \
907 this->Set## name## Input(newInput); \
909 ITK_MACROEND_NOOP_STATEMENT
914#define itkGetDecoratedInputMacro(name, type) \
915 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
917 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
918 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
920 virtual const type & Get##name() const \
922 itkDebugMacro("Getting input " #name); \
923 using DecoratorType = SimpleDataObjectDecorator<type>; \
924 const DecoratorType * input = \
925 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
926 if (input == nullptr) \
928 itkExceptionMacro("input" #name " is not set"); \
930 return input->Get(); \
932 ITK_MACROEND_NOOP_STATEMENT
936#define itkSetGetDecoratedInputMacro(name, type) \
937 itkSetDecoratedInputMacro(name, type); \
938 itkGetDecoratedInputMacro(name, type)
945#define itkSetDecoratedObjectInputMacro(name, type) \
946 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
948 itkDebugMacro("setting input " #name " to " << _arg); \
949 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
951 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
955 virtual void Set##name(const type * _arg) \
957 using DecoratorType = DataObjectDecorator<type>; \
958 itkDebugMacro("setting input " #name " to " << _arg); \
959 const DecoratorType * oldInput = \
960 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
961 if (oldInput && oldInput->Get() == _arg) \
965 auto newInput = DecoratorType::New(); \
966 newInput->Set(_arg); \
967 this->Set##name##Input(newInput); \
969 ITK_MACROEND_NOOP_STATEMENT
976#define itkGetDecoratedObjectInputMacro(name, type) \
977 virtual const DataObjectDecorator<type> * Get##name##Input() const \
979 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
980 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
982 virtual const type * Get##name() const \
984 itkDebugMacro("Getting input " #name); \
985 using DecoratorType = DataObjectDecorator<type>; \
986 const DecoratorType * input = \
987 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
988 if (input == nullptr) \
992 return input->Get(); \
994 ITK_MACROEND_NOOP_STATEMENT
998#define itkSetGetDecoratedObjectInputMacro(name, type) \
999 itkSetDecoratedObjectInputMacro(name, type); \
1000 itkGetDecoratedObjectInputMacro(name, type)
1004#define itkSetMacro(name, type) \
1005 virtual void Set## name(type _arg) \
1007 itkDebugMacro("setting " #name " to " << _arg); \
1008 ITK_GCC_PRAGMA_PUSH \
1009 ITK_GCC_SUPPRESS_Wfloat_equal \
1010 if (this->m_## name != _arg) \
1012 this->m_## name = std::move(_arg); \
1015 ITK_GCC_PRAGMA_POP \
1017 ITK_MACROEND_NOOP_STATEMENT
1022#define itkGetMacro(name, type) \
1023 virtual type Get##name() { return this->m_##name; } \
1024 ITK_MACROEND_NOOP_STATEMENT
1030#define itkGetConstMacro(name, type) \
1031 virtual type Get##name() const { return this->m_##name; } \
1032 ITK_MACROEND_NOOP_STATEMENT
1039#define itkGetConstReferenceMacro(name, type) \
1040 virtual const type & Get##name() const { return this->m_##name; } \
1041 ITK_MACROEND_NOOP_STATEMENT
1048#define itkSetEnumMacro(name, type) \
1049 virtual void Set##name(const type _arg) \
1051 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1052 if (this->m_##name != _arg) \
1054 this->m_##name = _arg; \
1058 ITK_MACROEND_NOOP_STATEMENT
1065#define itkGetEnumMacro(name, type) \
1066 virtual type Get##name() const { return this->m_##name; } \
1067 ITK_MACROEND_NOOP_STATEMENT
1073#define itkSetStringMacro(name) \
1074 virtual void Set##name(const char * _arg) \
1076 if (_arg && (_arg == this->m_##name)) \
1082 this->m_##name = _arg; \
1086 this->m_##name = ""; \
1090 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1091 ITK_MACROEND_NOOP_STATEMENT
1097#define itkGetStringMacro(name) \
1098 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1099 ITK_MACROEND_NOOP_STATEMENT
1106#define itkSetClampMacro(name, type, min, max) \
1107 virtual void Set## name(type _arg) \
1109 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1110 itkDebugMacro("setting " << #name " to " << _arg); \
1111 ITK_GCC_PRAGMA_PUSH \
1112 ITK_GCC_SUPPRESS_Wfloat_equal \
1113 if (this->m_## name != temp_extrema) \
1115 this->m_## name = temp_extrema; \
1118 ITK_GCC_PRAGMA_POP \
1120 ITK_MACROEND_NOOP_STATEMENT
1128#define itkSetObjectMacro(name, type) \
1129 virtual void Set## name(type * _arg) \
1131 itkDebugMacro("setting " << #name " to " << _arg); \
1132 if (this->m_## name != _arg) \
1134 this->m_## name = _arg; \
1138 ITK_MACROEND_NOOP_STATEMENT
1166#define itkGetConstObjectMacro(name, type) \
1167 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1168 ITK_MACROEND_NOOP_STATEMENT
1171#if defined(ITK_FUTURE_LEGACY_REMOVE)
1177# define itkGetObjectMacro(name, type) \
1178 virtual type * Get##name() \
1180 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1182 ITK_MACROEND_NOOP_STATEMENT
1184# define itkGetModifiableObjectMacro(name, type) \
1185 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1186 itkGetConstObjectMacro(name, type)
1192# define itkGetObjectMacro(name, type) \
1193 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1194 ITK_MACROEND_NOOP_STATEMENT
1195# define itkGetModifiableObjectMacro(name, type) \
1196 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1197 itkGetConstObjectMacro(name, type); \
1198 itkGetObjectMacro(name, type)
1208#define itkGetConstReferenceObjectMacro(name, type) \
1209 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1210 ITK_MACROEND_NOOP_STATEMENT
1216#define itkSetConstObjectMacro(name, type) \
1217 virtual void Set##name(const type * _arg) \
1219 itkDebugMacro("setting " << #name " to " << _arg); \
1220 if (this->m_##name != _arg) \
1222 this->m_##name = _arg; \
1226 ITK_MACROEND_NOOP_STATEMENT
1231#define itkBooleanMacro(name) \
1232 virtual void name##On() { this->Set##name(true); } \
1233 virtual void name##Off() { this->Set##name(false); } \
1234 ITK_MACROEND_NOOP_STATEMENT
1245template <
typename MemberContainerType,
typename CopyFromValueType,
typename LoopEndType>
1247ContainerFillWithCheck(MemberContainerType & m,
const CopyFromValueType & c,
const LoopEndType N)
1249 bool value_updated =
false;
1250 for (
unsigned int i = 0; i < N; ++i)
1253 ITK_GCC_SUPPRESS_Wfloat_equal
1257 value_updated =
true;
1261 return value_updated;
1272template <
typename MemberContainerType,
typename CopyFromContainerType,
typename LoopEndType>
1274ContainerCopyWithCheck(MemberContainerType & m,
const CopyFromContainerType & c,
const LoopEndType N)
1276 bool value_updated =
false;
1277 for (LoopEndType i = 0; i < N; ++i)
1280 ITK_GCC_SUPPRESS_Wfloat_equal
1284 value_updated =
true;
1288 return value_updated;
1296#define itkSetVectorMacro(name, type, count) \
1297 virtual void Set## name(type data[]) \
1299 if (ContainerCopyWithCheck( this->m_## name, data, count)) \
1304 ITK_MACROEND_NOOP_STATEMENT
1309#define itkGetVectorMacro(name, type, count) \
1310 virtual type * Get##name() const { return this->m_##name; } \
1311 ITK_MACROEND_NOOP_STATEMENT
1317#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1325#define itkGPUKernelMacro(kernel) \
1329 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1330 kernel() = delete; \
1331 ~kernel() = delete; \
1332 static const char * GetOpenCLSource(); \
1335#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1336 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1337 ITK_MACROEND_NOOP_STATEMENT
1341#define itkPrintSelfObjectMacro(name) \
1342 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1344 os << indent << #name << ": (null)" << std::endl; \
1348 os << indent << #name << ": " << std::endl; \
1349 this->m_##name->Print(os, indent.GetNextIndent()); \
1351 ITK_MACROEND_NOOP_STATEMENT
1356#define itkPrintSelfBooleanMacro(name) \
1357 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1358 ITK_MACROEND_NOOP_STATEMENT
1363#define itkSetDecoratedOutputMacro(name, type) \
1364 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1366 itkDebugMacro("setting output " #name " to " << _arg); \
1367 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1369 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1373 virtual void Set##name(const type & _arg) \
1375 using DecoratorType = SimpleDataObjectDecorator<type>; \
1376 itkDebugMacro("setting output " #name " to " << _arg); \
1377 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1380 if (output->Get() == _arg) \
1386 output->Set(_arg); \
1391 auto newOutput = DecoratorType::New(); \
1392 newOutput->Set(_arg); \
1393 this->Set##name##Output(newOutput); \
1396 ITK_MACROEND_NOOP_STATEMENT
1400#define itkGetDecoratedOutputMacro(name, type) \
1401 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1403 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1404 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1406 virtual const type & Get##name() const \
1408 itkDebugMacro("Getting output " #name); \
1409 using DecoratorType = SimpleDataObjectDecorator<type>; \
1410 const DecoratorType * output = \
1411 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1412 if (output == nullptr) \
1414 itkExceptionMacro("output" #name " is not set"); \
1416 return output->Get(); \
1418 ITK_MACROEND_NOOP_STATEMENT
1422#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1423# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1425# define ITK_FUTURE_DEPRECATED(message)
1428#if __cplusplus >= 202002L
1429# define ITK_NODISCARD(message) [[nodiscard(message)]]
1431# define ITK_NODISCARD(message) [[nodiscard]]
1436#if defined(ITK_LEGACY_REMOVE)
1437# define itkExposeEnumValue(name) \
1438 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1440# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1442# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1443# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1444# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1446# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1449# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1450# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1451# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1452# define ITK_DEPRECATED_MSG \
1453 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1454# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1455# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1456# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1457# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1458# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1459# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1460# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1461# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1462# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1463# define ITK_STATIC_ASSERT_MSG \
1464 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1465# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1468# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1470# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1471# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1472# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1481# define itkExposeEnumValue(name) static_cast<int>(name)
1484# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1486# define ITK_FALLTHROUGH [[fallthrough]]
1488# define ITK_DELETE_FUNCTION = delete
1490# define ITK_CONSTEXPR_FUNC constexpr
1491# define ITK_CONSTEXPR_VAR constexpr
1494# define ITK_ALIGNAS(X) alignas(X)
1495# define ITK_ALIGNOF(X) alignof(X)
1496# define ITK_DEPRECATED [[deprecated]]
1497# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1498# define ITK_CONSTEXPR constexpr
1499# define ITK_DELETED_FUNCTION = delete
1500# define ITK_EXTERN_TEMPLATE extern
1501# define ITK_FINAL final
1502# define ITK_NOEXCEPT noexcept
1503# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1504# define ITK_NULLPTR nullptr
1505# define ITK_OVERRIDE override
1506# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1507# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1508# define ITK_THREAD_LOCAL thread_local
1511# define ITKv5_CONST const
1513# define ITK_ITERATOR_VIRTUAL
1514# define ITK_ITERATOR_OVERRIDE
1515# define ITK_ITERATOR_FINAL
1518#define allow_inclusion_of_itkExceptionObject_h
1524#undef allow_inclusion_of_itkExceptionObject_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....