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
122#if defined(__GNUC__) && !defined(__clang__)
123# define ITK_GCC_SUPPRESS_Wmaybe_uninitialized ITK_PRAGMA(GCC diagnostic ignored "-Wmaybe-uninitialized")
125# define ITK_GCC_SUPPRESS_Wmaybe_uninitialized
129#if defined(__clang__) && defined(__has_warning)
130# define ITK_CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
131# define ITK_CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
132# if __has_warning("-Wzero-as-null-pointer-constant")
133# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant \
134 ITK_PRAGMA(clang diagnostic ignored "-Wzero-as-null-pointer-constant")
136# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
138# if __has_warning("-Wduplicate-enum")
139# define ITK_CLANG_SUPPRESS_Wduplicate_enum ITK_PRAGMA(clang diagnostic ignored "-Wduplicate-enum")
141# define ITK_CLANG_SUPPRESS_Wduplicate_enum
144# define ITK_CLANG_PRAGMA_PUSH
145# define ITK_CLANG_PRAGMA_POP
146# define ITK_CLANG_SUPPRESS_Wzero_as_null_pointer_constant
147# define ITK_CLANG_SUPPRESS_Wduplicate_enum
152#define CLANG_PRAGMA_PUSH ITK_CLANG_PRAGMA_PUSH
153#define CLANG_PRAGMA_POP ITK_CLANG_PRAGMA_POP
154#define CLANG_SUPPRESS_Wfloat_equal ITK_GCC_SUPPRESS_Wfloat_equal
158# define ITK_FORMAT_PRINTF(a, b) __attribute__((format(printf, a, b)))
160# define ITK_FORMAT_PRINTF(a, b)
163#if !defined(ITK_LEGACY_REMOVE)
165# define CLANG_SUPPRESS_Wcpp14_extensions \
166 [[deprecated("Remove deprecated CLANG_SUPPRESS_Wcpp14_extensions c++14 warning suppression")]] void * \
167 CLANG_SUPPRESS_Wcpp14_extensions = nullptr;
171#if defined(__INTEL_COMPILER)
172# define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
173# define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
174# define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
176# define INTEL_PRAGMA_WARN_PUSH
177# define INTEL_PRAGMA_WARN_POP
178# define INTEL_SUPPRESS_warning_1292
189#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
190# define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
191# define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
192# define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
194# define ITK_GCC_PRAGMA_DIAG(x)
195# define ITK_GCC_PRAGMA_DIAG_PUSH()
196# define ITK_GCC_PRAGMA_DIAG_POP()
203#if defined(_MSC_VER) && (_MSC_VER < 1920)
204# error "MSVC versions before Visual Studio 2019 are not supported"
206#if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
207# error "SUNPro C++ < 5.14.0 is not supported"
209#if defined(__CYGWIN__)
210# error "The Cygwin compiler is not supported"
212#if defined(__BORLANDC__)
213# error "The Borland C compiler is not supported"
215#if defined(__MWERKS__)
216# error "The MetroWerks compiler is not supported"
218#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && (__GNUC__ < 7)
219# error "GCC < 7 is not supported"
225# error "The SGI compiler is not supported"
227#if defined(__apple_build_version__) && (__apple_build_version__ < 12000032)
228# error "AppleClang < Xcode 12.4 is not supported"
229#elif defined(__clang__) && (__clang_major__ < 5)
230# error "Clang < 5 is not supported"
232#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1910)
233# error "Intel C++ < 19.1 is not supported4"
237#if defined(_WIN32) || defined(WIN32)
238# define ITK_ABI_IMPORT __declspec(dllimport)
239# define ITK_ABI_EXPORT __declspec(dllexport)
240# define ITK_ABI_HIDDEN
243# define ITK_ABI_IMPORT __attribute__((visibility("default")))
244# define ITK_ABI_EXPORT __attribute__((visibility("default")))
245# define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
247# define ITK_ABI_IMPORT
248# define ITK_ABI_EXPORT
249# define ITK_ABI_HIDDEN
254#ifndef ITK_TEMPLATE_EXPORT
255# ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
256# define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
258# define ITK_TEMPLATE_EXPORT
263#ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
264# define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
266# define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
269#ifndef ITK_FORWARD_EXPORT
271# if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
272 defined(USE_COMPILER_HIDDEN_VISIBILITY)
273# define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
275# define ITK_FORWARD_EXPORT
301#define itkNewMacro(x) \
302 itkSimpleNewMacro(x); \
303 itkCreateAnotherMacro(x); \
305 ITK_MACROEND_NOOP_STATEMENT
307#define itkSimpleNewMacro(x) \
308 static Pointer New() \
310 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
311 if (smartPtr == nullptr) \
313 smartPtr = new x(); \
315 smartPtr->UnRegister(); \
318 ITK_MACROEND_NOOP_STATEMENT
320#define itkCreateAnotherMacro(x) \
321 ::itk::LightObject::Pointer CreateAnother() const override { return x::New().GetPointer(); } \
322 ITK_MACROEND_NOOP_STATEMENT
324#define itkCloneMacro(x) \
325 Pointer Clone() const \
327 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
330 ITK_MACROEND_NOOP_STATEMENT
336#define itkFactoryOnlyNewMacro(x) \
337 itkSimpleFactoryOnlyNewMacro(x); \
338 itkCreateAnotherMacro(x); \
340 ITK_MACROEND_NOOP_STATEMENT
342#define itkSimpleFactoryOnlyNewMacro(x) \
343 static auto New() -> Pointer \
345 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
346 if (smartPtr == nullptr) \
348 itkSpecializedMessageExceptionMacro(ExceptionObject, \
349 "Object factory failed to instantiate " << typeid(x).name()); \
351 smartPtr->UnRegister(); \
354 ITK_MACROEND_NOOP_STATEMENT
369#define itkFactorylessNewMacro(x) \
370 static Pointer New() \
372 auto * rawPtr = new x(); \
373 Pointer smartPtr = rawPtr; \
374 rawPtr->UnRegister(); \
377 itkCreateAnotherMacro(x); \
378 ITK_MACROEND_NOOP_STATEMENT
389#define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
390 TypeName(const TypeName &) = delete; \
391 TypeName & operator=(const TypeName &) = delete; \
392 TypeName(TypeName &&) = delete; \
393 TypeName & operator=(TypeName &&) = delete
395#if !defined(ITK_LEGACY_REMOVE)
396# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
398# define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) \
399 static_assert(false, "Replace deprecated ITK_DISALLOW_COPY_AND_ASSIGN with modern ITK_DISALLOW_COPY_AND_MOVE")
411#define ITK_DEFAULT_COPY_AND_MOVE(TypeName) \
412 TypeName(const TypeName &) = default; \
413 TypeName & operator=(const TypeName &) = default; \
414 TypeName(TypeName &&) = default; \
415 TypeName & operator=(TypeName &&) = default
422#if __cplusplus >= 202002L
423# define ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
429#ifdef ITK_EXPERIMENTAL_CXX20_REWRITTEN_UNEQUAL_OPERATOR
432# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) ITK_MACROEND_NOOP_STATEMENT
436# define ITK_UNEQUAL_OPERATOR_MEMBER_FUNCTION(TypeName) \
437 bool operator!=(const TypeName & other) const { return !(this->operator==(other)); } \
438 ITK_MACROEND_NOOP_STATEMENT
443#define itkInternalGetNameOfClassImplementationMacro(thisClass) \
445 static_assert(std::is_same_v<thisClass, std::remove_const_t<std::remove_reference_t<decltype(*this)>>>, \
446 "The macro argument `" #thisClass \
447 "` appears incorrect! It should correspond with the name of this class!"); \
450 ITK_MACROEND_NOOP_STATEMENT
456#define itkVirtualGetNameOfClassMacro(thisClass) \
457 virtual const char * GetNameOfClass() const itkInternalGetNameOfClassImplementationMacro(thisClass)
459#define itkOverrideGetNameOfClassMacro(thisClass) \
460 const char * GetNameOfClass() const override itkInternalGetNameOfClassImplementationMacro(thisClass)
462#ifdef ITK_FUTURE_LEGACY_REMOVE
463# define itkTypeMacro(thisClass, superclass) \
464 static_assert(false, \
465 "In a future revision of ITK, the macro `itkTypeMacro(thisClass, superclass)` will be removed. " \
466 "Please call `itkOverrideGetNameOfClassMacro(thisClass)` instead!")
467# define itkTypeMacroNoParent(thisClass) \
468 static_assert(false, \
469 "In a future revision of ITK, the macro `itkTypeMacroNoParent(thisClass)` will be removed. " \
470 "Please call `itkVirtualGetNameOfClassMacro(thisClass)` instead!")
476# define itkTypeMacro(thisClass, superclass) itkOverrideGetNameOfClassMacro(thisClass)
477# define itkTypeMacroNoParent(thisClass) itkVirtualGetNameOfClassMacro(thisClass)
490#ifndef ITK_FUTURE_LEGACY_REMOVE
491extern ITKCommon_EXPORT
void
492OutputWindowDisplayText(
const char *);
494extern ITKCommon_EXPORT
void
495OutputWindowDisplayErrorText(
const char *);
497extern ITKCommon_EXPORT
void
498OutputWindowDisplayWarningText(
const char *);
500extern ITKCommon_EXPORT
void
501OutputWindowDisplayGenericOutputText(
const char *);
503extern ITKCommon_EXPORT
void
504OutputWindowDisplayDebugText(
const char *);
508extern ITKCommon_EXPORT
void
509OutputWindowDisplayDebugText(
const char * file,
511 const char * className,
512 const void * objectAddress,
513 const char * message);
515extern ITKCommon_EXPORT
void
516OutputWindowDisplayWarningText(
const char * file,
518 const char * className,
519 const void * objectAddress,
520 const char * message);
522extern ITKCommon_EXPORT
void
523OutputWindowDisplayErrorText(
const char * file,
525 const char * className,
526 const void * objectAddress,
527 const char * message);
529extern ITKCommon_EXPORT
void
530OutputWindowDisplayGenericOutputText(
const char * file,
unsigned int line,
const char * message);
542# define itkDebugMacro(x) ITK_NOOP_STATEMENT
543# define itkDebugStatement(x) ITK_NOOP_STATEMENT
545# define itkDebugMacro(x) \
547 using namespace ::itk::print_helper; \
548 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
550 std::ostringstream itkmsg; \
552 ::itk::OutputWindowDisplayDebugText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
555 ITK_MACROEND_NOOP_STATEMENT
558# define itkDebugStatement(x) x
564#define itkWarningMacro(x) \
566 if (::itk::Object::GetGlobalWarningDisplay()) \
568 std::ostringstream itkmsg; \
570 ::itk::OutputWindowDisplayWarningText(__FILE__, __LINE__, this->GetNameOfClass(), this, itkmsg.str().c_str()); \
573 ITK_MACROEND_NOOP_STATEMENT
576#define itkWarningStatement(x) x
578#if defined(ITK_CPP_FUNCTION)
579# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
580# define ITK_LOCATION __FUNCSIG__
581# elif defined(__GNUC__)
582# define ITK_LOCATION __PRETTY_FUNCTION__
584# define ITK_LOCATION __FUNCTION__
587# define ITK_LOCATION "unknown"
590#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
593 class newexcp : public parentexcp \
597 static constexpr const char * const default_exception_message = whatmessage; \
599 using parentexcp::parentexcp; \
600 itkOverrideGetNameOfClassMacro(newexcp); \
603 ITK_MACROEND_NOOP_STATEMENT
606#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
608 std::ostringstream exceptionDescriptionOutputStringStream; \
609 exceptionDescriptionOutputStringStream << "" x; \
610 throw ::itk::ExceptionType( \
611 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
613 ITK_MACROEND_NOOP_STATEMENT
615#define itkSpecializedExceptionMacro(ExceptionType) \
616 throw ::itk::ExceptionType( \
617 std::string{ __FILE__ }, __LINE__, ::itk::ExceptionType::default_exception_message, std::string{ ITK_LOCATION });
623#define itkExceptionMacro(x) \
625 std::ostringstream exceptionDescriptionOutputStringStream; \
626 exceptionDescriptionOutputStringStream << "" x; \
627 throw ::itk::ExceptionObject(std::string{ __FILE__ }, \
629 exceptionDescriptionOutputStringStream.str(), \
630 std::string{ ITK_LOCATION }, \
633 ITK_MACROEND_NOOP_STATEMENT
635#define itkExceptionStringMacro(x) \
637 throw ::itk::ExceptionObject( \
638 std::string{ __FILE__ }, __LINE__, std::string{ x }, std::string{ ITK_LOCATION }, this); \
640 ITK_MACROEND_NOOP_STATEMENT
642#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
644#define itkGenericOutputMacro(x) \
646 if (::itk::Object::GetGlobalWarningDisplay()) \
648 std::ostringstream itkmsg; \
650 ::itk::OutputWindowDisplayGenericOutputText(__FILE__, __LINE__, itkmsg.str().c_str()); \
653 ITK_MACROEND_NOOP_STATEMENT
658#define itkLogMacro(x, y) \
660 if (this->GetLogger()) \
662 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
665 ITK_MACROEND_NOOP_STATEMENT
667#define itkLogMacroStatic(obj, x, y) \
669 if (obj->GetLogger()) \
671 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
674 ITK_MACROEND_NOOP_STATEMENT
705#if defined(ITK_LEGACY_REMOVE)
706# define itkLegacyMacro(method)
708# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
710# define itkLegacyMacro(method) method
713# define itkLegacyMacro(method) [[deprecated]] method
739#if defined(ITK_LEGACY_SILENT)
740# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
741# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
742# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
743# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
745# define itkLegacyBodyMacro(method, version) \
746 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
747# define itkLegacyReplaceBodyMacro(method, version, replace) \
748 itkWarningMacro(#method " was deprecated for ITK " #version \
749 " and will be removed in a future version. Use " #replace " instead.")
750# define itkGenericLegacyBodyMacro(method, version) \
751 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
752# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
753 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
754 " and will be removed in a future version. Use " #replace " instead.")
761constexpr size_t ITK_CACHE_LINE_ALIGNMENT{ 64 };
769#define itkPadStruct(mincachesize, oldtype, newtype) \
770 struct newtype : public oldtype \
772 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
779#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
780# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
781#elif defined(_MSC_VER)
782# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
784# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
787#if defined(ITK_FUTURE_LEGACY_REMOVE)
810# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
812# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
828#define itkForLoopAssignmentMacro( \
829 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
830 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
832 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
834 ITK_MACROEND_NOOP_STATEMENT
845#define itkForLoopRoundingAndAssignmentMacro( \
846 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
847 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
849 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
851 ITK_MACROEND_NOOP_STATEMENT
855#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
858# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
860# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
864# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
867#define itkAssertOrThrowMacro(test, message) \
870 std::ostringstream msgstr; \
872 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
874 ITK_MACROEND_NOOP_STATEMENT
876#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
877# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
879# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
889#ifdef ITK_FUTURE_LEGACY_REMOVE
890# define itkStaticConstMacro(name, type, value) \
891 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
892# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
908# define itkStaticConstMacro(name, type, value) static constexpr type name = value
910# define itkGetStaticConstMacro(name) (Self::name)
915#define itkSetInputMacro(name, type) \
916 virtual void Set##name(const type * _arg) \
918 itkDebugMacro("setting input " #name " to " << _arg); \
919 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
921 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
925 ITK_MACROEND_NOOP_STATEMENT
929#define itkGetInputMacro(name, type) \
930 virtual const type * Get##name() const \
932 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
933 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
935 ITK_MACROEND_NOOP_STATEMENT
940#define itkSetDecoratedInputMacro(name, type) \
941 virtual void Set## name## Input(const SimpleDataObjectDecorator<type> * _arg) \
943 itkDebugMacro("setting input " #name " to " << _arg); \
944 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
946 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
950 virtual void Set## name(const SimpleDataObjectDecorator<type> * _arg) { this->Set## name## Input(_arg); } \
951 virtual void Set## name(const type & _arg) \
953 using DecoratorType = SimpleDataObjectDecorator<type>; \
954 itkDebugMacro("setting input " #name " to " << _arg); \
955 const DecoratorType * oldInput = \
956 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
957 ITK_GCC_PRAGMA_PUSH \
958 ITK_GCC_SUPPRESS_Wfloat_equal \
959 if (oldInput && oldInput->Get() == _arg) \
964 auto newInput = DecoratorType::New(); \
965 newInput->Set(_arg); \
966 this->Set## name## Input(newInput); \
968 ITK_MACROEND_NOOP_STATEMENT
973#define itkGetDecoratedInputMacro(name, type) \
974 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
976 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
977 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
979 virtual const type & Get##name() const \
981 itkDebugMacro("Getting input " #name); \
982 using DecoratorType = SimpleDataObjectDecorator<type>; \
983 const DecoratorType * input = \
984 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
985 if (input == nullptr) \
987 itkExceptionStringMacro("input" #name " is not set"); \
989 return input->Get(); \
991 ITK_MACROEND_NOOP_STATEMENT
995#define itkSetGetDecoratedInputMacro(name, type) \
996 itkSetDecoratedInputMacro(name, type); \
997 itkGetDecoratedInputMacro(name, type)
1004#define itkSetDecoratedObjectInputMacro(name, type) \
1005 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
1007 itkDebugMacro("setting input " #name " to " << _arg); \
1008 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
1010 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
1014 virtual void Set##name(const type * _arg) \
1016 using DecoratorType = DataObjectDecorator<type>; \
1017 itkDebugMacro("setting input " #name " to " << _arg); \
1018 const DecoratorType * oldInput = \
1019 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1020 if (oldInput && oldInput->Get() == _arg) \
1024 auto newInput = DecoratorType::New(); \
1025 newInput->Set(_arg); \
1026 this->Set##name##Input(newInput); \
1028 ITK_MACROEND_NOOP_STATEMENT
1035#define itkGetDecoratedObjectInputMacro(name, type) \
1036 virtual const DataObjectDecorator<type> * Get##name##Input() const \
1038 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
1039 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
1041 virtual const type * Get##name() const \
1043 itkDebugMacro("Getting input " #name); \
1044 using DecoratorType = DataObjectDecorator<type>; \
1045 const DecoratorType * input = \
1046 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
1047 if (input == nullptr) \
1051 return input->Get(); \
1053 ITK_MACROEND_NOOP_STATEMENT
1057#define itkSetGetDecoratedObjectInputMacro(name, type) \
1058 itkSetDecoratedObjectInputMacro(name, type); \
1059 itkGetDecoratedObjectInputMacro(name, type)
1063#define itkSetMacro(name, type) \
1064 virtual void Set## name(type _arg) \
1066 itkDebugMacro("setting " #name " to " << _arg); \
1067 ITK_GCC_PRAGMA_PUSH \
1068 ITK_GCC_SUPPRESS_Wfloat_equal \
1069 if (this->m_## name != _arg) \
1071 this->m_## name = std::move(_arg); \
1074 ITK_GCC_PRAGMA_POP \
1076 ITK_MACROEND_NOOP_STATEMENT
1081#define itkGetMacro(name, type) \
1082 virtual type Get##name() { return this->m_##name; } \
1083 ITK_MACROEND_NOOP_STATEMENT
1089#define itkGetConstMacro(name, type) \
1090 virtual type Get##name() const { return this->m_##name; } \
1091 ITK_MACROEND_NOOP_STATEMENT
1098#define itkGetConstReferenceMacro(name, type) \
1099 virtual const type & Get##name() const { return this->m_##name; } \
1100 ITK_MACROEND_NOOP_STATEMENT
1107#define itkSetEnumMacro(name, type) \
1108 virtual void Set##name(const type _arg) \
1110 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1111 if (this->m_##name != _arg) \
1113 this->m_##name = _arg; \
1117 ITK_MACROEND_NOOP_STATEMENT
1124#define itkGetEnumMacro(name, type) \
1125 virtual type Get##name() const { return this->m_##name; } \
1126 ITK_MACROEND_NOOP_STATEMENT
1132#define itkSetStringMacro(name) \
1133 virtual void Set##name(const char * _arg) \
1135 if (_arg && (_arg == this->m_##name)) \
1141 this->m_##name = _arg; \
1145 this->m_##name = ""; \
1149 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1150 ITK_MACROEND_NOOP_STATEMENT
1156#define itkGetStringMacro(name) \
1157 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1158 ITK_MACROEND_NOOP_STATEMENT
1165#define itkSetClampMacro(name, type, min, max) \
1166 virtual void Set## name(type _arg) \
1168 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1169 itkDebugMacro("setting " << #name " to " << _arg); \
1170 ITK_GCC_PRAGMA_PUSH \
1171 ITK_GCC_SUPPRESS_Wfloat_equal \
1172 if (this->m_## name != temp_extrema) \
1174 this->m_## name = temp_extrema; \
1177 ITK_GCC_PRAGMA_POP \
1179 ITK_MACROEND_NOOP_STATEMENT
1187#define itkSetObjectMacro(name, type) \
1188 virtual void Set## name(type * _arg) \
1190 itkDebugMacro("setting " << #name " to " << _arg); \
1191 if (this->m_## name != _arg) \
1193 this->m_## name = _arg; \
1197 ITK_MACROEND_NOOP_STATEMENT
1225#define itkGetConstObjectMacro(name, type) \
1226 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1227 ITK_MACROEND_NOOP_STATEMENT
1230#if defined(ITK_FUTURE_LEGACY_REMOVE)
1236# define itkGetObjectMacro(name, type) \
1237 virtual type * Get##name() \
1239 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1241 ITK_MACROEND_NOOP_STATEMENT
1243# define itkGetModifiableObjectMacro(name, type) \
1244 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1245 itkGetConstObjectMacro(name, type)
1251# define itkGetObjectMacro(name, type) \
1252 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1253 ITK_MACROEND_NOOP_STATEMENT
1254# define itkGetModifiableObjectMacro(name, type) \
1255 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1256 itkGetConstObjectMacro(name, type); \
1257 itkGetObjectMacro(name, type)
1267#define itkGetConstReferenceObjectMacro(name, type) \
1268 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1269 ITK_MACROEND_NOOP_STATEMENT
1275#define itkSetConstObjectMacro(name, type) \
1276 virtual void Set##name(const type * _arg) \
1278 itkDebugMacro("setting " << #name " to " << _arg); \
1279 if (this->m_##name != _arg) \
1281 this->m_##name = _arg; \
1285 ITK_MACROEND_NOOP_STATEMENT
1290#define itkBooleanMacro(name) \
1291 virtual void name##On() { this->Set##name(true); } \
1292 virtual void name##Off() { this->Set##name(false); } \
1293 ITK_MACROEND_NOOP_STATEMENT
1304template <
typename MemberContainerType,
typename CopyFromValueType,
typename LoopEndType>
1306ContainerFillWithCheck(MemberContainerType & m,
const CopyFromValueType & c,
const LoopEndType N)
1308 bool value_updated =
false;
1309 for (
unsigned int i = 0; i < N; ++i)
1312 ITK_GCC_SUPPRESS_Wfloat_equal
1316 value_updated =
true;
1320 return value_updated;
1331template <
typename MemberContainerType,
typename CopyFromContainerType,
typename LoopEndType>
1333ContainerCopyWithCheck(MemberContainerType & m,
const CopyFromContainerType & c,
const LoopEndType N)
1335 bool value_updated =
false;
1336 for (LoopEndType i = 0; i < N; ++i)
1339 ITK_GCC_SUPPRESS_Wfloat_equal
1343 value_updated =
true;
1347 return value_updated;
1355#define itkSetVectorMacro(name, type, count) \
1356 virtual void Set## name(type data[]) \
1358 if (ContainerCopyWithCheck( this->m_## name, data, count)) \
1363 ITK_MACROEND_NOOP_STATEMENT
1368#define itkGetVectorMacro(name, type, count) \
1369 virtual type * Get##name() const { return this->m_##name; } \
1370 ITK_MACROEND_NOOP_STATEMENT
1376#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1384#define itkGPUKernelMacro(kernel) \
1388 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1389 kernel() = delete; \
1390 ~kernel() = delete; \
1391 static const char * GetOpenCLSource(); \
1394#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1395 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1396 ITK_MACROEND_NOOP_STATEMENT
1400#define itkPrintSelfObjectMacro(name) \
1401 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1403 os << indent << #name << ": (null)" << std::endl; \
1407 os << indent << #name << ": " << std::endl; \
1408 this->m_##name->Print(os, indent.GetNextIndent()); \
1410 ITK_MACROEND_NOOP_STATEMENT
1415#define itkPrintSelfBooleanMacro(name) \
1416 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1417 ITK_MACROEND_NOOP_STATEMENT
1422#define itkSetDecoratedOutputMacro(name, type) \
1423 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1425 itkDebugMacro("setting output " #name " to " << _arg); \
1426 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1428 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1432 virtual void Set##name(const type & _arg) \
1434 using DecoratorType = SimpleDataObjectDecorator<type>; \
1435 itkDebugMacro("setting output " #name " to " << _arg); \
1436 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1439 if (output->Get() == _arg) \
1445 output->Set(_arg); \
1450 auto newOutput = DecoratorType::New(); \
1451 newOutput->Set(_arg); \
1452 this->Set##name##Output(newOutput); \
1455 ITK_MACROEND_NOOP_STATEMENT
1459#define itkGetDecoratedOutputMacro(name, type) \
1460 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1462 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1463 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1465 virtual const type & Get##name() const \
1467 itkDebugMacro("Getting output " #name); \
1468 using DecoratorType = SimpleDataObjectDecorator<type>; \
1469 const DecoratorType * output = \
1470 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1471 if (output == nullptr) \
1473 itkExceptionStringMacro("output" #name " is not set"); \
1475 return output->Get(); \
1477 ITK_MACROEND_NOOP_STATEMENT
1481#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1482# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1484# define ITK_FUTURE_DEPRECATED(message)
1487#if __cplusplus >= 202002L
1488# define ITK_NODISCARD(message) [[nodiscard(message)]]
1490# define ITK_NODISCARD(message) [[nodiscard]]
1495#if defined(ITK_LEGACY_REMOVE)
1496# define itkExposeEnumValue(name) \
1497 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1499# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1501# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1502# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1503# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1505# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1508# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1509# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1510# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1511# define ITK_DEPRECATED_MSG \
1512 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1513# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1514# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1515# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1516# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1517# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1518# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1519# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1520# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1521# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1522# define ITK_STATIC_ASSERT_MSG \
1523 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1524# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1527# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1529# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1530# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1531# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1540# define itkExposeEnumValue(name) static_cast<int>(name)
1543# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1545# define ITK_FALLTHROUGH [[fallthrough]]
1547# define ITK_DELETE_FUNCTION = delete
1549# define ITK_CONSTEXPR_FUNC constexpr
1550# define ITK_CONSTEXPR_VAR constexpr
1553# define ITK_ALIGNAS(X) alignas(X)
1554# define ITK_ALIGNOF(X) alignof(X)
1555# define ITK_DEPRECATED [[deprecated]]
1556# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1557# define ITK_CONSTEXPR constexpr
1558# define ITK_DELETED_FUNCTION = delete
1559# define ITK_EXTERN_TEMPLATE extern
1560# define ITK_FINAL final
1561# define ITK_NOEXCEPT noexcept
1562# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1563# define ITK_NULLPTR nullptr
1564# define ITK_OVERRIDE override
1565# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1566# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1567# define ITK_THREAD_LOCAL thread_local
1570# define ITKv5_CONST const
1572# define ITK_ITERATOR_VIRTUAL
1573# define ITK_ITERATOR_OVERRIDE
1574# define ITK_ITERATOR_FINAL
1577#define allow_inclusion_of_itkExceptionObject_h
1583#undef allow_inclusion_of_itkExceptionObject_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....