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# if __has_warning("-Wzero-as-null-pointer-constant")
125# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
126 ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
128# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
130# if __has_warning("-Wduplicate-enum")
131# define ITK_CLANG_SUPPRESS_Wduplicate_enum ITK_PRAGMA(clang diagnostic ignored "-Wduplicate-enum")
133# define ITK_CLANG_SUPPRESS_Wduplicate_enum
136# define ITK_CLANG_PRAGMA_PUSH
137# define ITK_CLANG_PRAGMA_POP
138# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
139# define ITK_CLANG_SUPPRESS_Wduplicate_enum
144#define CLANG_PRAGMA_PUSH ITK_CLANG_PRAGMA_PUSH
145#define CLANG_PRAGMA_POP ITK_CLANG_PRAGMA_POP
146#define CLANG_SUPPRESS_Wfloat_equal ITK_GCC_SUPPRESS_Wfloat_equal
150# define ITK_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
152# define ITK_FORMAT_PRINTF(a, b)
155#if !defined(ITK_LEGACY_REMOVE)
157# define CLANG_SUPPRESS_Wcpp14_extensions \
158 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
159 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
163#if defined(__INTEL_COMPILER)
164# define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
165# define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
166# define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
168# define INTEL_PRAGMA_WARN_PUSH
169# define INTEL_PRAGMA_WARN_POP
170# define INTEL_SUPPRESS_warning_1292
181#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
182# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
183# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
184# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
186# define ITK_GCC_PRAGMA_DIAG(x)
187# define ITK_GCC_PRAGMA_DIAG_PUSH()
188# define ITK_GCC_PRAGMA_DIAG_POP()
195#if defined(_MSC_VER) && (_MSC_VER < 1920)
196# error "MSVC versions before Visual Studio 2019 are not supported"
198#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
199# error "SUNPro C++ < 5.14.0 is not supported"
201#if defined(__CYGWIN__)
202# error "The Cygwin compiler is not supported"
204#if defined(__BORLANDC__)
205# error "The Borland C compiler is not supported"
207#if defined(__MWERKS__)
208# error "The MetroWerks compiler is not supported"
210#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
211# error "GCC < 7 is not supported"
217# error "The SGI compiler is not supported"
219#if defined(__apple_build_version__) && (__apple_build_version__ < 12000032)
220# error "AppleClang < Xcode 12.4 is not supported"
221#elif defined(__clang__) && (__clang_major__ < 5)
222# error "Clang < 5 is not supported"
224#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
225# error "Intel C++ < 19.1 is not supported4"
229#if defined(_WIN32) || defined(WIN32)
230# define ITK_ABI_IMPORT __declspec(dllimport)
231# define ITK_ABI_EXPORT __declspec(dllexport)
232# define ITK_ABI_HIDDEN
235# define ITK_ABI_IMPORT __attribute__((visibility("default")))
236# define ITK_ABI_EXPORT __attribute__((visibility("default")))
237# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
239# define ITK_ABI_IMPORT
240# define ITK_ABI_EXPORT
241# define ITK_ABI_HIDDEN
246#ifndef ITK_TEMPLATE_EXPORT
247# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
248# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
250# define ITK_TEMPLATE_EXPORT
255#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
256# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
258# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
261#ifndef ITK_FORWARD_EXPORT
263# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
264 defined(USE_COMPILER_HIDDEN_VISIBILITY)
265# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
267# define ITK_FORWARD_EXPORT
293#define itkNewMacro(x) \
294 itkSimpleNewMacro(x); \
295 itkCreateAnotherMacro(x); \
297 ITK_MACROEND_NOOP_STATEMENT
299#define itkSimpleNewMacro(x) \
300 static Pointer New() \
302 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
303 if (smartPtr == nullptr) \
305 smartPtr = new x(); \
307 smartPtr->UnRegister(); \
310 ITK_MACROEND_NOOP_STATEMENT
312#define itkCreateAnotherMacro(x) \
313 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
314 ITK_MACROEND_NOOP_STATEMENT
316#define itkCloneMacro(x) \
317 Pointer Clone() const \
319 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
322 ITK_MACROEND_NOOP_STATEMENT
328#define itkFactoryOnlyNewMacro(x) \
329 itkSimpleFactoryOnlyNewMacro(x); \
330 itkCreateAnotherMacro(x); \
332 ITK_MACROEND_NOOP_STATEMENT
334#define itkSimpleFactoryOnlyNewMacro(x) \
335 static auto New() -> Pointer \
337 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
338 if (smartPtr == nullptr) \
340 itkSpecializedMessageExceptionMacro(ExceptionObject, \
341 "Object factory failed to instantiate " << typeid(x).name()); \
343 smartPtr->UnRegister(); \
346 ITK_MACROEND_NOOP_STATEMENT
361#define itkFactorylessNewMacro(x) \
362 static Pointer New() \
364 auto * rawPtr = new x(); \
365 Pointer smartPtr = rawPtr; \
366 rawPtr->UnRegister(); \
369 itkCreateAnotherMacro(x); \
370 ITK_MACROEND_NOOP_STATEMENT
381#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
382 TypeName(const TypeName &) = delete; \
383 TypeName & operator=(const TypeName &) = delete; \
384 TypeName(TypeName &&) = delete; \
385 TypeName & operator=(TypeName &&) = delete
387#if !defined(ITK_LEGACY_REMOVE)
388# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
390# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
391 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
403#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
404 TypeName(const TypeName &) = default; \
405 TypeName & operator=(const TypeName &) = default; \
406 TypeName(TypeName &&) = default; \
407 TypeName & operator=(TypeName &&) = default
414#if __cplusplus >= 202002L
415# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
421#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
424# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
428# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
429 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
430 ITK_MACROEND_NOOP_STATEMENT
435#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
437 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
438 "The macro argument `" #thisClass \
439 "` appears incorrect! It should correspond with the name of this class!"); \
442 ITK_MACROEND_NOOP_STATEMENT
448#define itkVirtualGetNameOfClassMacro(thisClass) \
449 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
451#define itkOverrideGetNameOfClassMacro(thisClass) \
452 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
454#ifdef ITK_FUTURE_LEGACY_REMOVE
455# define itkTypeMacro(thisClass, superclass) \
456 static_assert(false, \
457 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
458 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
459# define itkTypeMacroNoParent(thisClass) \
460 static_assert(false, \
461 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
462 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
468# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
469# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
482#ifndef ITK_FUTURE_LEGACY_REMOVE
483extern ITKCommon_EXPORT
void
484OutputWindowDisplayText(
const char *);
486extern ITKCommon_EXPORT
void
487OutputWindowDisplayErrorText(
const char *);
489extern ITKCommon_EXPORT
void
490OutputWindowDisplayWarningText(
const char *);
492extern ITKCommon_EXPORT
void
493OutputWindowDisplayGenericOutputText(
const char *);
495extern ITKCommon_EXPORT
void
496OutputWindowDisplayDebugText(
const char *);
500extern ITKCommon_EXPORT
void
501OutputWindowDisplayDebugText(
const char * file,
503 const char * className,
504 const void * objectAddress,
505 const char * message);
507extern ITKCommon_EXPORT
void
508OutputWindowDisplayWarningText(
const char * file,
510 const char * className,
511 const void * objectAddress,
512 const char * message);
514extern ITKCommon_EXPORT
void
515OutputWindowDisplayErrorText(
const char * file,
517 const char * className,
518 const void * objectAddress,
519 const char * message);
521extern ITKCommon_EXPORT
void
522OutputWindowDisplayGenericOutputText(
const char * file,
unsigned int line,
const char * message);
534# define itkDebugMacro(x) ITK_NOOP_STATEMENT
535# define itkDebugStatement(x) ITK_NOOP_STATEMENT
537# define itkDebugMacro(x) \
539 using namespace ::itk::print_helper; \
540 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
542 std::ostringstream itkmsg; \
544 ::itk::OutputWindowDisplayDebugText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
547 ITK_MACROEND_NOOP_STATEMENT
550# define itkDebugStatement(x) x
556#define itkWarningMacro(x) \
558 if (::itk::Object::GetGlobalWarningDisplay()) \
560 std::ostringstream itkmsg; \
562 ::itk::OutputWindowDisplayWarningText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
565 ITK_MACROEND_NOOP_STATEMENT
568#define itkWarningStatement(x) x
570#if defined(ITK_CPP_FUNCTION)
571# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
572# define ITK_LOCATION __FUNCSIG__
573# elif defined(__GNUC__)
574# define ITK_LOCATION __PRETTY_FUNCTION__
576# define ITK_LOCATION __FUNCTION__
579# define ITK_LOCATION "unknown"
582#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
585 class newexcp : public parentexcp \
589 static constexpr const char * const default_exception_message = whatmessage; \
591 using parentexcp::parentexcp; \
592 itkOverrideGetNameOfClassMacro(newexcp); \
595 ITK_MACROEND_NOOP_STATEMENT
598#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
600 std::ostringstream exceptionDescriptionOutputStringStream; \
601 exceptionDescriptionOutputStringStream << "" x; \
602 throw ::itk::ExceptionType( \
603 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
605 ITK_MACROEND_NOOP_STATEMENT
607#define itkSpecializedExceptionMacro(ExceptionType) \
608 throw ::itk::ExceptionType( \
609 std::string{ __FILE__ }, __LINE__, ::itk::ExceptionType::default_exception_message, std::string{ ITK_LOCATION });
615#define itkExceptionMacro(x) \
617 std::ostringstream exceptionDescriptionOutputStringStream; \
618 exceptionDescriptionOutputStringStream << "" x; \
619 throw ::itk::ExceptionObject(std::string{ __FILE__ }, \
621 exceptionDescriptionOutputStringStream.str(), \
622 std::string{ ITK_LOCATION }, \
625 ITK_MACROEND_NOOP_STATEMENT
627#define itkExceptionStringMacro(x) \
629 throw ::itk::ExceptionObject( \
630 std::string{ __FILE__ }, __LINE__, std::string{ x }, std::string{ ITK_LOCATION }, this); \
632 ITK_MACROEND_NOOP_STATEMENT
634#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
636#define itkGenericOutputMacro(x) \
638 if (::itk::Object::GetGlobalWarningDisplay()) \
640 std::ostringstream itkmsg; \
642 ::itk::OutputWindowDisplayGenericOutputText(__FILE__, __LINE__, itkmsg.str().c_str()); \
645 ITK_MACROEND_NOOP_STATEMENT
650#define itkLogMacro(x, y) \
652 if (this->GetLogger()) \
654 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
657 ITK_MACROEND_NOOP_STATEMENT
659#define itkLogMacroStatic(obj, x, y) \
661 if (obj->GetLogger()) \
663 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
666 ITK_MACROEND_NOOP_STATEMENT
697#if defined(ITK_LEGACY_REMOVE)
698# define itkLegacyMacro(method)
700# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
702# define itkLegacyMacro(method) method
705# define itkLegacyMacro(method) [[deprecated]] method
731#if defined(ITK_LEGACY_SILENT)
732# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
733# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
734# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
735# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
737# define itkLegacyBodyMacro(method, version) \
738 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
739# define itkLegacyReplaceBodyMacro(method, version, replace) \
740 itkWarningMacro(#method " was deprecated for ITK " #version \
741 " and will be removed in a future version. Use " #replace " instead.")
742# define itkGenericLegacyBodyMacro(method, version) \
743 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
744# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
745 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
746 " and will be removed in a future version. Use " #replace " instead.")
753constexpr size_t ITK_CACHE_LINE_ALIGNMENT = 64;
761#define itkPadStruct(mincachesize, oldtype, newtype) \
762 struct newtype : public oldtype \
764 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
771#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
772# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
773#elif defined(_MSC_VER)
774# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
776# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
779#if defined(ITK_FUTURE_LEGACY_REMOVE)
802# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
804# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
820#define itkForLoopAssignmentMacro( \
821 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
822 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
824 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
826 ITK_MACROEND_NOOP_STATEMENT
837#define itkForLoopRoundingAndAssignmentMacro( \
838 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
839 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
841 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
843 ITK_MACROEND_NOOP_STATEMENT
847#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
850# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
852# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
856# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
859#define itkAssertOrThrowMacro(test, message) \
862 std::ostringstream msgstr; \
864 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
866 ITK_MACROEND_NOOP_STATEMENT
868#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
869# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
871# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
881#ifdef ITK_FUTURE_LEGACY_REMOVE
882# define itkStaticConstMacro(name, type, value) \
883 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
884# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
900# define itkStaticConstMacro(name, type, value) static constexpr type name = value
902# define itkGetStaticConstMacro(name) (Self::name)
907#define itkSetInputMacro(name, type) \
908 virtual void Set##name(const type * _arg) \
910 itkDebugMacro("setting input " #name " to " << _arg); \
911 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
913 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
917 ITK_MACROEND_NOOP_STATEMENT
921#define itkGetInputMacro(name, type) \
922 virtual const type * Get##name() const \
924 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
925 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
927 ITK_MACROEND_NOOP_STATEMENT
932#define itkSetDecoratedInputMacro(name, type) \
933 virtual void Set## name## Input(const SimpleDataObjectDecorator<type> * _arg) \
935 itkDebugMacro("setting input " #name " to " << _arg); \
936 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
938 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
942 virtual void Set## name(const SimpleDataObjectDecorator<type> * _arg) { this->Set## name## Input(_arg); } \
943 virtual void Set## name(const type & _arg) \
945 using DecoratorType = SimpleDataObjectDecorator<type>; \
946 itkDebugMacro("setting input " #name " to " << _arg); \
947 const DecoratorType * oldInput = \
948 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
949 ITK_GCC_PRAGMA_PUSH \
950 ITK_GCC_SUPPRESS_Wfloat_equal \
951 if (oldInput && oldInput->Get() == _arg) \
956 auto newInput = DecoratorType::New(); \
957 newInput->Set(_arg); \
958 this->Set## name## Input(newInput); \
960 ITK_MACROEND_NOOP_STATEMENT
965#define itkGetDecoratedInputMacro(name, type) \
966 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
968 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
969 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
971 virtual const type & Get##name() const \
973 itkDebugMacro("Getting input " #name); \
974 using DecoratorType = SimpleDataObjectDecorator<type>; \
975 const DecoratorType * input = \
976 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
977 if (input == nullptr) \
979 itkExceptionStringMacro("input" #name " is not set"); \
981 return input->Get(); \
983 ITK_MACROEND_NOOP_STATEMENT
987#define itkSetGetDecoratedInputMacro(name, type) \
988 itkSetDecoratedInputMacro(name, type); \
989 itkGetDecoratedInputMacro(name, type)
996#define itkSetDecoratedObjectInputMacro(name, type) \
997 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
999 itkDebugMacro("setting input " #name " to " << _arg); \
1000 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
1002 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
1006 virtual void Set##name(const type * _arg) \
1008 using DecoratorType = DataObjectDecorator<type>; \
1009 itkDebugMacro("setting input " #name " to " << _arg); \
1010 const DecoratorType * oldInput = \
1011 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1012 if (oldInput && oldInput->Get() == _arg) \
1016 auto newInput = DecoratorType::New(); \
1017 newInput->Set(_arg); \
1018 this->Set##name##Input(newInput); \
1020 ITK_MACROEND_NOOP_STATEMENT
1027#define itkGetDecoratedObjectInputMacro(name, type) \
1028 virtual const DataObjectDecorator<type> * Get##name##Input() const \
1030 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
1031 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
1033 virtual const type * Get##name() const \
1035 itkDebugMacro("Getting input " #name); \
1036 using DecoratorType = DataObjectDecorator<type>; \
1037 const DecoratorType * input = \
1038 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1039 if (input == nullptr) \
1043 return input->Get(); \
1045 ITK_MACROEND_NOOP_STATEMENT
1049#define itkSetGetDecoratedObjectInputMacro(name, type) \
1050 itkSetDecoratedObjectInputMacro(name, type); \
1051 itkGetDecoratedObjectInputMacro(name, type)
1055#define itkSetMacro(name, type) \
1056 virtual void Set## name(type _arg) \
1058 itkDebugMacro("setting " #name " to " << _arg); \
1059 ITK_GCC_PRAGMA_PUSH \
1060 ITK_GCC_SUPPRESS_Wfloat_equal \
1061 if (this->m_## name != _arg) \
1063 this->m_## name = std::move(_arg); \
1066 ITK_GCC_PRAGMA_POP \
1068 ITK_MACROEND_NOOP_STATEMENT
1073#define itkGetMacro(name, type) \
1074 virtual type Get##name() { return this->m_##name; } \
1075 ITK_MACROEND_NOOP_STATEMENT
1081#define itkGetConstMacro(name, type) \
1082 virtual type Get##name() const { return this->m_##name; } \
1083 ITK_MACROEND_NOOP_STATEMENT
1090#define itkGetConstReferenceMacro(name, type) \
1091 virtual const type & Get##name() const { return this->m_##name; } \
1092 ITK_MACROEND_NOOP_STATEMENT
1099#define itkSetEnumMacro(name, type) \
1100 virtual void Set##name(const type _arg) \
1102 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1103 if (this->m_##name != _arg) \
1105 this->m_##name = _arg; \
1109 ITK_MACROEND_NOOP_STATEMENT
1116#define itkGetEnumMacro(name, type) \
1117 virtual type Get##name() const { return this->m_##name; } \
1118 ITK_MACROEND_NOOP_STATEMENT
1124#define itkSetStringMacro(name) \
1125 virtual void Set##name(const char * _arg) \
1127 if (_arg && (_arg == this->m_##name)) \
1133 this->m_##name = _arg; \
1137 this->m_##name = ""; \
1141 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1142 ITK_MACROEND_NOOP_STATEMENT
1148#define itkGetStringMacro(name) \
1149 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1150 ITK_MACROEND_NOOP_STATEMENT
1157#define itkSetClampMacro(name, type, min, max) \
1158 virtual void Set## name(type _arg) \
1160 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1161 itkDebugMacro("setting " << #name " to " << _arg); \
1162 ITK_GCC_PRAGMA_PUSH \
1163 ITK_GCC_SUPPRESS_Wfloat_equal \
1164 if (this->m_## name != temp_extrema) \
1166 this->m_## name = temp_extrema; \
1169 ITK_GCC_PRAGMA_POP \
1171 ITK_MACROEND_NOOP_STATEMENT
1179#define itkSetObjectMacro(name, type) \
1180 virtual void Set## name(type * _arg) \
1182 itkDebugMacro("setting " << #name " to " << _arg); \
1183 if (this->m_## name != _arg) \
1185 this->m_## name = _arg; \
1189 ITK_MACROEND_NOOP_STATEMENT
1217#define itkGetConstObjectMacro(name, type) \
1218 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1219 ITK_MACROEND_NOOP_STATEMENT
1222#if defined(ITK_FUTURE_LEGACY_REMOVE)
1228# define itkGetObjectMacro(name, type) \
1229 virtual type * Get##name() \
1231 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1233 ITK_MACROEND_NOOP_STATEMENT
1235# define itkGetModifiableObjectMacro(name, type) \
1236 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1237 itkGetConstObjectMacro(name, type)
1243# define itkGetObjectMacro(name, type) \
1244 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1245 ITK_MACROEND_NOOP_STATEMENT
1246# define itkGetModifiableObjectMacro(name, type) \
1247 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1248 itkGetConstObjectMacro(name, type); \
1249 itkGetObjectMacro(name, type)
1259#define itkGetConstReferenceObjectMacro(name, type) \
1260 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1261 ITK_MACROEND_NOOP_STATEMENT
1267#define itkSetConstObjectMacro(name, type) \
1268 virtual void Set##name(const type * _arg) \
1270 itkDebugMacro("setting " << #name " to " << _arg); \
1271 if (this->m_##name != _arg) \
1273 this->m_##name = _arg; \
1277 ITK_MACROEND_NOOP_STATEMENT
1282#define itkBooleanMacro(name) \
1283 virtual void name##On() { this->Set##name(true); } \
1284 virtual void name##Off() { this->Set##name(false); } \
1285 ITK_MACROEND_NOOP_STATEMENT
1296template <
typename MemberContainerType,
typename CopyFromValueType,
typename LoopEndType>
1298ContainerFillWithCheck(MemberContainerType & m,
const CopyFromValueType & c,
const LoopEndType N)
1300 bool value_updated =
false;
1301 for (
unsigned int i = 0; i < N; ++i)
1304 ITK_GCC_SUPPRESS_Wfloat_equal
1308 value_updated =
true;
1312 return value_updated;
1323template <
typename MemberContainerType,
typename CopyFromContainerType,
typename LoopEndType>
1325ContainerCopyWithCheck(MemberContainerType & m,
const CopyFromContainerType & c,
const LoopEndType N)
1327 bool value_updated =
false;
1328 for (LoopEndType i = 0; i < N; ++i)
1331 ITK_GCC_SUPPRESS_Wfloat_equal
1335 value_updated =
true;
1339 return value_updated;
1347#define itkSetVectorMacro(name, type, count) \
1348 virtual void Set## name(type data[]) \
1350 if (ContainerCopyWithCheck( this->m_## name, data, count)) \
1355 ITK_MACROEND_NOOP_STATEMENT
1360#define itkGetVectorMacro(name, type, count) \
1361 virtual type * Get##name() const { return this->m_##name; } \
1362 ITK_MACROEND_NOOP_STATEMENT
1368#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1376#define itkGPUKernelMacro(kernel) \
1380 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1381 kernel() = delete; \
1382 ~kernel() = delete; \
1383 static const char * GetOpenCLSource(); \
1386#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1387 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1388 ITK_MACROEND_NOOP_STATEMENT
1392#define itkPrintSelfObjectMacro(name) \
1393 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1395 os << indent << #name << ": (null)" << std::endl; \
1399 os << indent << #name << ": " << std::endl; \
1400 this->m_##name->Print(os, indent.GetNextIndent()); \
1402 ITK_MACROEND_NOOP_STATEMENT
1407#define itkPrintSelfBooleanMacro(name) \
1408 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1409 ITK_MACROEND_NOOP_STATEMENT
1414#define itkSetDecoratedOutputMacro(name, type) \
1415 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1417 itkDebugMacro("setting output " #name " to " << _arg); \
1418 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1420 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1424 virtual void Set##name(const type & _arg) \
1426 using DecoratorType = SimpleDataObjectDecorator<type>; \
1427 itkDebugMacro("setting output " #name " to " << _arg); \
1428 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1431 if (output->Get() == _arg) \
1437 output->Set(_arg); \
1442 auto newOutput = DecoratorType::New(); \
1443 newOutput->Set(_arg); \
1444 this->Set##name##Output(newOutput); \
1447 ITK_MACROEND_NOOP_STATEMENT
1451#define itkGetDecoratedOutputMacro(name, type) \
1452 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1454 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1455 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1457 virtual const type & Get##name() const \
1459 itkDebugMacro("Getting output " #name); \
1460 using DecoratorType = SimpleDataObjectDecorator<type>; \
1461 const DecoratorType * output = \
1462 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1463 if (output == nullptr) \
1465 itkExceptionStringMacro("output" #name " is not set"); \
1467 return output->Get(); \
1469 ITK_MACROEND_NOOP_STATEMENT
1473#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1474# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1476# define ITK_FUTURE_DEPRECATED(message)
1479#if __cplusplus >= 202002L
1480# define ITK_NODISCARD(message) [[nodiscard(message)]]
1482# define ITK_NODISCARD(message) [[nodiscard]]
1487#if defined(ITK_LEGACY_REMOVE)
1488# define itkExposeEnumValue(name) \
1489 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1491# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1493# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1494# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1495# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1497# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1500# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1501# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1502# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1503# define ITK_DEPRECATED_MSG \
1504 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1505# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1506# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1507# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1508# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1509# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1510# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1511# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1512# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1513# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1514# define ITK_STATIC_ASSERT_MSG \
1515 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1516# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1519# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1521# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1522# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1523# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1532# define itkExposeEnumValue(name) static_cast<int>(name)
1535# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1537# define ITK_FALLTHROUGH [[fallthrough]]
1539# define ITK_DELETE_FUNCTION = delete
1541# define ITK_CONSTEXPR_FUNC constexpr
1542# define ITK_CONSTEXPR_VAR constexpr
1545# define ITK_ALIGNAS(X) alignas(X)
1546# define ITK_ALIGNOF(X) alignof(X)
1547# define ITK_DEPRECATED [[deprecated]]
1548# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1549# define ITK_CONSTEXPR constexpr
1550# define ITK_DELETED_FUNCTION = delete
1551# define ITK_EXTERN_TEMPLATE extern
1552# define ITK_FINAL final
1553# define ITK_NOEXCEPT noexcept
1554# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1555# define ITK_NULLPTR nullptr
1556# define ITK_OVERRIDE override
1557# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1558# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1559# define ITK_THREAD_LOCAL thread_local
1562# define ITKv5_CONST const
1564# define ITK_ITERATOR_VIRTUAL
1565# define ITK_ITERATOR_OVERRIDE
1566# define ITK_ITERATOR_FINAL
1569#define allow_inclusion_of_itkExceptionObject_h
1575#undef allow_inclusion_of_itkExceptionObject_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....