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)
482extern ITKCommon_EXPORT
void
483OutputWindowDisplayText(
const char *);
485extern ITKCommon_EXPORT
void
486OutputWindowDisplayErrorText(
const char *);
488extern ITKCommon_EXPORT
void
489OutputWindowDisplayWarningText(
const char *);
491extern ITKCommon_EXPORT
void
492OutputWindowDisplayGenericOutputText(
const char *);
494extern ITKCommon_EXPORT
void
495OutputWindowDisplayDebugText(
const char *);
507# define itkDebugMacro(x) ITK_NOOP_STATEMENT
508# define itkDebugStatement(x) ITK_NOOP_STATEMENT
510# define itkDebugMacro(x) \
512 using namespace ::itk::print_helper; \
513 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
515 std::ostringstream itkmsg; \
516 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << '\n' \
517 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
518 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
521 ITK_MACROEND_NOOP_STATEMENT
524# define itkDebugStatement(x) x
530#define itkWarningMacro(x) \
532 if (::itk::Object::GetGlobalWarningDisplay()) \
534 std::ostringstream itkmsg; \
535 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << '\n' \
536 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
537 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
540 ITK_MACROEND_NOOP_STATEMENT
543#define itkWarningStatement(x) x
545#if defined(ITK_CPP_FUNCTION)
546# if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
547# define ITK_LOCATION __FUNCSIG__
548# elif defined(__GNUC__)
549# define ITK_LOCATION __PRETTY_FUNCTION__
551# define ITK_LOCATION __FUNCTION__
554# define ITK_LOCATION "unknown"
557#define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
560 class newexcp : public parentexcp \
564 static constexpr const char * const default_exception_message = whatmessage; \
566 using parentexcp::parentexcp; \
567 itkOverrideGetNameOfClassMacro(newexcp); \
570 ITK_MACROEND_NOOP_STATEMENT
573#define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
575 std::ostringstream exceptionDescriptionOutputStringStream; \
576 exceptionDescriptionOutputStringStream << "ITK ERROR: " x; \
577 throw ::itk::ExceptionType( \
578 std::string{ __FILE__ }, __LINE__, exceptionDescriptionOutputStringStream.str(), std::string{ ITK_LOCATION }); \
580 ITK_MACROEND_NOOP_STATEMENT
582#define itkSpecializedExceptionMacro(ExceptionType) \
583 itkSpecializedMessageExceptionMacro(ExceptionType, << ::itk::ExceptionType::default_exception_message)
588#define itkExceptionMacro(x) \
589 itkSpecializedMessageExceptionMacro(ExceptionObject, << this->GetNameOfClass() << '(' << this << "): " x)
591#define itkGenericExceptionMacro(x) itkSpecializedMessageExceptionMacro(ExceptionObject, x)
593#define itkGenericOutputMacro(x) \
595 if (::itk::Object::GetGlobalWarningDisplay()) \
597 std::ostringstream itkmsg; \
598 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
599 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
602 ITK_MACROEND_NOOP_STATEMENT
607#define itkLogMacro(x, y) \
609 if (this->GetLogger()) \
611 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
614 ITK_MACROEND_NOOP_STATEMENT
616#define itkLogMacroStatic(obj, x, y) \
618 if (obj->GetLogger()) \
620 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
623 ITK_MACROEND_NOOP_STATEMENT
654#if defined(ITK_LEGACY_REMOVE)
655# define itkLegacyMacro(method)
657# if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
659# define itkLegacyMacro(method) method
662# define itkLegacyMacro(method) [[deprecated]] method
688#if defined(ITK_LEGACY_SILENT)
689# define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
690# define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
691# define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
692# define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
694# define itkLegacyBodyMacro(method, version) \
695 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
696# define itkLegacyReplaceBodyMacro(method, version, replace) \
697 itkWarningMacro(#method " was deprecated for ITK " #version \
698 " and will be removed in a future version. Use " #replace " instead.")
699# define itkGenericLegacyBodyMacro(method, version) \
700 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
701# define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
702 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
703 " and will be removed in a future version. Use " #replace " instead.")
710constexpr size_t ITK_CACHE_LINE_ALIGNMENT = 64;
718#define itkPadStruct(mincachesize, oldtype, newtype) \
719 struct newtype : public oldtype \
721 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
728#if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
729# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
730#elif defined(_MSC_VER)
731# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
733# define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
736#if defined(ITK_FUTURE_LEGACY_REMOVE)
759# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
761# define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
777#define itkForLoopAssignmentMacro( \
778 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
779 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
781 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
783 ITK_MACROEND_NOOP_STATEMENT
794#define itkForLoopRoundingAndAssignmentMacro( \
795 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
796 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
798 DestinationArray[i] = ::itk::Math::Round<DestinationElementType>(SourceArray[i]); \
800 ITK_MACROEND_NOOP_STATEMENT
804#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
807# define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
809# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
813# define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
816#define itkAssertOrThrowMacro(test, message) \
819 std::ostringstream msgstr; \
821 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
823 ITK_MACROEND_NOOP_STATEMENT
825#if !defined(NDEBUG) && !defined(ITK_WRAPPING)
826# define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
828# define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
838#ifdef ITK_FUTURE_LEGACY_REMOVE
839# define itkStaticConstMacro(name, type, value) \
840 "Replace itkStaticConstMacro(name, type, value) with `static constexpr type name = value`"
841# define itkGetStaticConstMacro(name) "Replace itkGetStaticConstMacro(name) with `Self::name`"
857# define itkStaticConstMacro(name, type, value) static constexpr type name = value
859# define itkGetStaticConstMacro(name) (Self::name)
864#define itkSetInputMacro(name, type) \
865 virtual void Set##name(const type * _arg) \
867 itkDebugMacro("setting input " #name " to " << _arg); \
868 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
870 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
874 ITK_MACROEND_NOOP_STATEMENT
878#define itkGetInputMacro(name, type) \
879 virtual const type * Get##name() const \
881 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
882 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
884 ITK_MACROEND_NOOP_STATEMENT
889#define itkSetDecoratedInputMacro(name, type) \
890 virtual void Set## name## Input(const SimpleDataObjectDecorator<type> * _arg) \
892 itkDebugMacro("setting input " #name " to " << _arg); \
893 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
895 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
899 virtual void Set## name(const SimpleDataObjectDecorator<type> * _arg) { this->Set## name## Input(_arg); } \
900 virtual void Set## name(const type & _arg) \
902 using DecoratorType = SimpleDataObjectDecorator<type>; \
903 itkDebugMacro("setting input " #name " to " << _arg); \
904 const DecoratorType * oldInput = \
905 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
906 ITK_GCC_PRAGMA_PUSH \
907 ITK_GCC_SUPPRESS_Wfloat_equal \
908 if (oldInput && oldInput->Get() == _arg) \
913 auto newInput = DecoratorType::New(); \
914 newInput->Set(_arg); \
915 this->Set## name## Input(newInput); \
917 ITK_MACROEND_NOOP_STATEMENT
922#define itkGetDecoratedInputMacro(name, type) \
923 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
925 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
926 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
928 virtual const type & Get##name() const \
930 itkDebugMacro("Getting input " #name); \
931 using DecoratorType = SimpleDataObjectDecorator<type>; \
932 const DecoratorType * input = \
933 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
934 if (input == nullptr) \
936 itkExceptionMacro("input" #name " is not set"); \
938 return input->Get(); \
940 ITK_MACROEND_NOOP_STATEMENT
944#define itkSetGetDecoratedInputMacro(name, type) \
945 itkSetDecoratedInputMacro(name, type); \
946 itkGetDecoratedInputMacro(name, type)
953#define itkSetDecoratedObjectInputMacro(name, type) \
954 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
956 itkDebugMacro("setting input " #name " to " << _arg); \
957 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
959 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
963 virtual void Set##name(const type * _arg) \
965 using DecoratorType = DataObjectDecorator<type>; \
966 itkDebugMacro("setting input " #name " to " << _arg); \
967 const DecoratorType * oldInput = \
968 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
969 if (oldInput && oldInput->Get() == _arg) \
973 auto newInput = DecoratorType::New(); \
974 newInput->Set(_arg); \
975 this->Set##name##Input(newInput); \
977 ITK_MACROEND_NOOP_STATEMENT
984#define itkGetDecoratedObjectInputMacro(name, type) \
985 virtual const DataObjectDecorator<type> * Get##name##Input() const \
987 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
988 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
990 virtual const type * Get##name() const \
992 itkDebugMacro("Getting input " #name); \
993 using DecoratorType = DataObjectDecorator<type>; \
994 const DecoratorType * input = \
995 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
996 if (input == nullptr) \
1000 return input->Get(); \
1002 ITK_MACROEND_NOOP_STATEMENT
1006#define itkSetGetDecoratedObjectInputMacro(name, type) \
1007 itkSetDecoratedObjectInputMacro(name, type); \
1008 itkGetDecoratedObjectInputMacro(name, type)
1012#define itkSetMacro(name, type) \
1013 virtual void Set## name(type _arg) \
1015 itkDebugMacro("setting " #name " to " << _arg); \
1016 ITK_GCC_PRAGMA_PUSH \
1017 ITK_GCC_SUPPRESS_Wfloat_equal \
1018 if (this->m_## name != _arg) \
1020 this->m_## name = std::move(_arg); \
1023 ITK_GCC_PRAGMA_POP \
1025 ITK_MACROEND_NOOP_STATEMENT
1030#define itkGetMacro(name, type) \
1031 virtual type Get##name() { return this->m_##name; } \
1032 ITK_MACROEND_NOOP_STATEMENT
1038#define itkGetConstMacro(name, type) \
1039 virtual type Get##name() const { return this->m_##name; } \
1040 ITK_MACROEND_NOOP_STATEMENT
1047#define itkGetConstReferenceMacro(name, type) \
1048 virtual const type & Get##name() const { return this->m_##name; } \
1049 ITK_MACROEND_NOOP_STATEMENT
1056#define itkSetEnumMacro(name, type) \
1057 virtual void Set##name(const type _arg) \
1059 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1060 if (this->m_##name != _arg) \
1062 this->m_##name = _arg; \
1066 ITK_MACROEND_NOOP_STATEMENT
1073#define itkGetEnumMacro(name, type) \
1074 virtual type Get##name() const { return this->m_##name; } \
1075 ITK_MACROEND_NOOP_STATEMENT
1081#define itkSetStringMacro(name) \
1082 virtual void Set##name(const char * _arg) \
1084 if (_arg && (_arg == this->m_##name)) \
1090 this->m_##name = _arg; \
1094 this->m_##name = ""; \
1098 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1099 ITK_MACROEND_NOOP_STATEMENT
1105#define itkGetStringMacro(name) \
1106 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1107 ITK_MACROEND_NOOP_STATEMENT
1114#define itkSetClampMacro(name, type, min, max) \
1115 virtual void Set## name(type _arg) \
1117 const type temp_extrema = (_arg <= min ? min : (_arg >= max ? max : _arg)); \
1118 itkDebugMacro("setting " << #name " to " << _arg); \
1119 ITK_GCC_PRAGMA_PUSH \
1120 ITK_GCC_SUPPRESS_Wfloat_equal \
1121 if (this->m_## name != temp_extrema) \
1123 this->m_## name = temp_extrema; \
1126 ITK_GCC_PRAGMA_POP \
1128 ITK_MACROEND_NOOP_STATEMENT
1136#define itkSetObjectMacro(name, type) \
1137 virtual void Set## name(type * _arg) \
1139 itkDebugMacro("setting " << #name " to " << _arg); \
1140 if (this->m_## name != _arg) \
1142 this->m_## name = _arg; \
1146 ITK_MACROEND_NOOP_STATEMENT
1174#define itkGetConstObjectMacro(name, type) \
1175 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1176 ITK_MACROEND_NOOP_STATEMENT
1179#if defined(ITK_FUTURE_LEGACY_REMOVE)
1185# define itkGetObjectMacro(name, type) \
1186 virtual type * Get##name() \
1188 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1190 ITK_MACROEND_NOOP_STATEMENT
1192# define itkGetModifiableObjectMacro(name, type) \
1193 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1194 itkGetConstObjectMacro(name, type)
1200# define itkGetObjectMacro(name, type) \
1201 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1202 ITK_MACROEND_NOOP_STATEMENT
1203# define itkGetModifiableObjectMacro(name, type) \
1204 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1205 itkGetConstObjectMacro(name, type); \
1206 itkGetObjectMacro(name, type)
1216#define itkGetConstReferenceObjectMacro(name, type) \
1217 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1218 ITK_MACROEND_NOOP_STATEMENT
1224#define itkSetConstObjectMacro(name, type) \
1225 virtual void Set##name(const type * _arg) \
1227 itkDebugMacro("setting " << #name " to " << _arg); \
1228 if (this->m_##name != _arg) \
1230 this->m_##name = _arg; \
1234 ITK_MACROEND_NOOP_STATEMENT
1239#define itkBooleanMacro(name) \
1240 virtual void name##On() { this->Set##name(true); } \
1241 virtual void name##Off() { this->Set##name(false); } \
1242 ITK_MACROEND_NOOP_STATEMENT
1253template <
typename MemberContainerType,
typename CopyFromValueType,
typename LoopEndType>
1255ContainerFillWithCheck(MemberContainerType & m,
const CopyFromValueType & c,
const LoopEndType N)
1257 bool value_updated =
false;
1258 for (
unsigned int i = 0; i < N; ++i)
1261 ITK_GCC_SUPPRESS_Wfloat_equal
1265 value_updated =
true;
1269 return value_updated;
1280template <
typename MemberContainerType,
typename CopyFromContainerType,
typename LoopEndType>
1282ContainerCopyWithCheck(MemberContainerType & m,
const CopyFromContainerType & c,
const LoopEndType N)
1284 bool value_updated =
false;
1285 for (LoopEndType i = 0; i < N; ++i)
1288 ITK_GCC_SUPPRESS_Wfloat_equal
1292 value_updated =
true;
1296 return value_updated;
1304#define itkSetVectorMacro(name, type, count) \
1305 virtual void Set## name(type data[]) \
1307 if (ContainerCopyWithCheck( this->m_## name, data, count)) \
1312 ITK_MACROEND_NOOP_STATEMENT
1317#define itkGetVectorMacro(name, type, count) \
1318 virtual type * Get##name() const { return this->m_##name; } \
1319 ITK_MACROEND_NOOP_STATEMENT
1325#define itkGPUKernelClassMacro(kernel) class itkGPUKernelMacro(kernel)
1333#define itkGPUKernelMacro(kernel) \
1337 ITK_DISALLOW_COPY_AND_MOVE(kernel); \
1338 kernel() = delete; \
1339 ~kernel() = delete; \
1340 static const char * GetOpenCLSource(); \
1343#define itkGetOpenCLSourceFromKernelMacro(kernel) \
1344 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); } \
1345 ITK_MACROEND_NOOP_STATEMENT
1349#define itkPrintSelfObjectMacro(name) \
1350 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1352 os << indent << #name << ": (null)" << std::endl; \
1356 os << indent << #name << ": " << std::endl; \
1357 this->m_##name->Print(os, indent.GetNextIndent()); \
1359 ITK_MACROEND_NOOP_STATEMENT
1364#define itkPrintSelfBooleanMacro(name) \
1365 os << indent << #name << ": " << (this->m_##name ? "On" : "Off") << std::endl; \
1366 ITK_MACROEND_NOOP_STATEMENT
1371#define itkSetDecoratedOutputMacro(name, type) \
1372 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1374 itkDebugMacro("setting output " #name " to " << _arg); \
1375 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1377 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1381 virtual void Set##name(const type & _arg) \
1383 using DecoratorType = SimpleDataObjectDecorator<type>; \
1384 itkDebugMacro("setting output " #name " to " << _arg); \
1385 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1388 if (output->Get() == _arg) \
1394 output->Set(_arg); \
1399 auto newOutput = DecoratorType::New(); \
1400 newOutput->Set(_arg); \
1401 this->Set##name##Output(newOutput); \
1404 ITK_MACROEND_NOOP_STATEMENT
1408#define itkGetDecoratedOutputMacro(name, type) \
1409 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1411 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1412 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1414 virtual const type & Get##name() const \
1416 itkDebugMacro("Getting output " #name); \
1417 using DecoratorType = SimpleDataObjectDecorator<type>; \
1418 const DecoratorType * output = \
1419 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1420 if (output == nullptr) \
1422 itkExceptionMacro("output" #name " is not set"); \
1424 return output->Get(); \
1426 ITK_MACROEND_NOOP_STATEMENT
1430#if defined(ITK_LEGACY_REMOVE) && !defined(ITK_LEGACY_SILENT)
1431# define ITK_FUTURE_DEPRECATED(message) [[deprecated(message)]]
1433# define ITK_FUTURE_DEPRECATED(message)
1436#if __cplusplus >= 202002L
1437# define ITK_NODISCARD(message) [[nodiscard(message)]]
1439# define ITK_NODISCARD(message) [[nodiscard]]
1444#if defined(ITK_LEGACY_REMOVE)
1445# define itkExposeEnumValue(name) \
1446 static_assert(false, "ERROR: Replace static_cast<int>(name) with with proper enumeration instead of integer")
1448# define ITK_NOEXCEPT_OR_THROW static_assert(false, "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT")
1450# define ITK_DELETE_FUNCTION static_assert(false, "ERROR: ITK_DELETE_FUNCTION must be replaced with `= delete`"
1451# define ITK_CONSTEXPR_FUNC static_assert(false, "ERROR: ITK_CONSTEXPR_FUNC must be replaced with 'constexpr'")
1452# define ITK_CONSTEXPR_VAR static_assert(false, "ERROR: ITK_CONSTEXPR_VAR must be replaced with 'constexpr'")
1454# define ITK_FALLTHROUGH static_assert(false, "ERROR: ITK_FALLTHROUGH must be replaced with '[[fallthrough]]'")
1457# define ITK_ALIGNAS static_assert(false, "ERROR: ITK_ALIGNAS must be replaced with 'alignas'")
1458# define ITK_ALIGNOF static_assert(false, "ERROR: ITK_ALIGNOF must be replaced with 'alignof'")
1459# define ITK_DEPRECATED static_assert(false, "ERROR: ITK_DEPRECATED must be replaced with '[[deprecated]]'")
1460# define ITK_DEPRECATED_MSG \
1461 static_assert(false, "ERROR: ITK_DEPRECATED_MSG must be replaced with '[[deprecated(MSG)]]'")
1462# define ITK_CONSTEXPR static_assert(false, "ERROR: ITK_CONSTEXPR must be replaced with 'constexpr'")
1463# define ITK_DELETED_FUNCTION static_assert(false, "ERROR: ITK_DELETED_FUNCTION must be replaced with '= delete'")
1464# define ITK_EXTERN_TEMPLATE static_assert(false, "ERROR: ITK_EXTERN_TEMPLATE must be replaced with 'extern'")
1465# define ITK_FINAL static_assert(false, "ERROR: ITK_FINAL must be replaced with 'final'")
1466# define ITK_NOEXCEPT static_assert(false, "ERROR: ITK_NOEXCEPT must be replaced with 'noexcept'")
1467# define ITK_NOEXCEPT_EXPR static_assert(false, "ERROR: ITK_NOEXCEPT_EXPR must be replaced with 'noexcept'")
1468# define ITK_NULLPTR static_assert(false, "ERROR: ITK_NULLPTR must be replaced with 'nullptr'")
1469# define ITK_OVERRIDE static_assert(false, "ERROR: ITK_OVERRIDE must be replaced with 'override'")
1470# define ITK_STATIC_ASSERT static_assert(false, "ERROR: ITK_STATIC_ASSERT must be replaced with 'static_assert'")
1471# define ITK_STATIC_ASSERT_MSG \
1472 static_assert(false, "ERROR: ITK_STATIC_ASSERT_MSG must be replaced with 'static_assert'")
1473# define ITK_THREAD_LOCAL static_assert(false, "ERROR: ITK_THREAD_LOCAL must be replaced with 'thread_local'")
1476# define ITKv5_CONST static_assert(false, "ERROR: ITKv5_CONST must be replaced with 'const'")
1478# define ITK_ITERATOR_VIRTUAL static_assert(false, "ERROR: ITK_ITERATOR_VIRTUAL must be removed'")
1479# define ITK_ITERATOR_OVERRIDE static_assert(false, "ERROR: ITK_ITERATOR_OVERRIDE must be removed")
1480# define ITK_ITERATOR_FINAL static_assert(false, "ERROR: ITK_ITERATOR_FINAL must be removed")
1489# define itkExposeEnumValue(name) static_cast<int>(name)
1492# define ITK_NOEXCEPT_OR_THROW ITK_NOEXCEPT
1494# define ITK_FALLTHROUGH [[fallthrough]]
1496# define ITK_DELETE_FUNCTION = delete
1498# define ITK_CONSTEXPR_FUNC constexpr
1499# define ITK_CONSTEXPR_VAR constexpr
1502# define ITK_ALIGNAS(X) alignas(X)
1503# define ITK_ALIGNOF(X) alignof(X)
1504# define ITK_DEPRECATED [[deprecated]]
1505# define ITK_DEPRECATED_MSG(MSG) [[deprecated(MSG)]]
1506# define ITK_CONSTEXPR constexpr
1507# define ITK_DELETED_FUNCTION = delete
1508# define ITK_EXTERN_TEMPLATE extern
1509# define ITK_FINAL final
1510# define ITK_NOEXCEPT noexcept
1511# define ITK_NOEXCEPT_EXPR(X) noexcept(X)
1512# define ITK_NULLPTR nullptr
1513# define ITK_OVERRIDE override
1514# define ITK_STATIC_ASSERT(X) static_assert(X, #X)
1515# define ITK_STATIC_ASSERT_MSG(X, MSG) static_assert(X, MSG)
1516# define ITK_THREAD_LOCAL thread_local
1519# define ITKv5_CONST const
1521# define ITK_ITERATOR_VIRTUAL
1522# define ITK_ITERATOR_OVERRIDE
1523# define ITK_ITERATOR_FINAL
1526#define allow_inclusion_of_itkExceptionObject_h
1532#undef allow_inclusion_of_itkExceptionObject_h
The "itk" namespace contains all Insight Segmentation and Registration Toolkit (ITK) classes....