42 #include "itkConfigure.h"
43 #include "ITKCommonExport.h"
79 # define ITK_NOOP_STATEMENT static_assert(true, "")
82 #if defined(ITK_FUTURE_LEGACY_REMOVE)
84 # define ITK_MACROEND_NOOP_STATEMENT ITK_NOOP_STATEMENT
90 # define ITK_MACROEND_NOOP_STATEMENT
98 #define ITK_PRAGMA(x) _Pragma(#x)
104 #if defined(__clang__) && defined(__has_warning)
105 # define CLANG_PRAGMA_PUSH ITK_PRAGMA(clang diagnostic push)
106 # define CLANG_PRAGMA_POP ITK_PRAGMA(clang diagnostic pop)
107 # if __has_warning("-Wfloat-equal")
108 # define CLANG_SUPPRESS_Wfloat_equal ITK_PRAGMA(clang diagnostic ignored "-Wfloat-equal")
110 # define CLANG_SUPPRESS_Wfloat_equal
112 # if __has_warning("-Wc++14-extensions")
113 # define CLANG_SUPPRESS_Wc__14_extensions ITK_PRAGMA(clang diagnostic ignored "-Wc++14-extensions")
115 # define CLANG_SUPPRESS_Wc__14_extensions
118 # define CLANG_PRAGMA_PUSH
119 # define CLANG_PRAGMA_POP
120 # define CLANG_SUPPRESS_Wfloat_equal
121 # define CLANG_SUPPRESS_Wc__14_extensions
125 #if defined(__INTEL_COMPILER)
126 # define INTEL_PRAGMA_WARN_PUSH ITK_PRAGMA(warning push)
127 # define INTEL_PRAGMA_WARN_POP ITK_PRAGMA(warning pop)
128 # define INTEL_SUPPRESS_warning_1292 ITK_PRAGMA(warning disable 1292)
130 # define INTEL_PRAGMA_WARN_PUSH
131 # define INTEL_PRAGMA_WARN_POP
132 # define INTEL_SUPPRESS_warning_1292
143 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
144 # define ITK_GCC_PRAGMA_DIAG(x) ITK_PRAGMA(GCC diagnostic x)
145 # define ITK_GCC_PRAGMA_DIAG_PUSH() ITK_GCC_PRAGMA_DIAG(push)
146 # define ITK_GCC_PRAGMA_DIAG_POP() ITK_GCC_PRAGMA_DIAG(pop)
148 # define ITK_GCC_PRAGMA_DIAG(x)
149 # define ITK_GCC_PRAGMA_DIAG_PUSH()
150 # define ITK_GCC_PRAGMA_DIAG_POP()
165 #if defined(_MSC_VER) && (_MSC_VER < 1900)
166 # error "Visual Studio < 2015 is not supported under ITKv5"
168 #if defined(__SUNPRO_CC) && (__SUNPRO_CC < 0x5140)
169 # error "SUNPro C++ < 5.14.0 is not supported under ITKv5 and above"
171 #if defined(__CYGWIN__)
172 # error "The Cygwin compiler is not supported in ITKv4 and above"
174 #if defined(__BORLANDC__)
175 # error "The Borland C compiler is not supported in ITKv4 and above"
177 #if defined(__MWERKS__)
178 # error "The MetroWerks compiler is not supported in ITKv4 and above"
180 #if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER) && \
181 ((__GNUC__ < 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ < 8)))
182 # error "GCC < 4.8 is not supported under ITKv5"
188 # error "The SGI compiler is not supported under ITKv4 and above"
190 #if defined(__APPLE__)
191 # if defined(__clang__) && (__cplusplus < 201103L)
192 # error "Apple LLVM < 5.0 (clang < 3.3) is not supported under ITKv5"
194 #elif defined(__clang__) && ((__clang_major__ < 3) || ((__clang_major__ == 3) && (__clang_minor__ < 3)))
195 # error "Clang < 3.3 is not supported under ITKv5"
197 #if defined(__INTEL_COMPILER) && (__INTEL_COMPILER < 1504)
198 # error "Intel C++ < 15.0.4 is not supported under ITKv5"
202 #if defined(_WIN32) || defined(WIN32)
203 # define ITK_ABI_IMPORT __declspec(dllimport)
204 # define ITK_ABI_EXPORT __declspec(dllexport)
205 # define ITK_ABI_HIDDEN
208 # define ITK_ABI_IMPORT __attribute__((visibility("default")))
209 # define ITK_ABI_EXPORT __attribute__((visibility("default")))
210 # define ITK_ABI_HIDDEN __attribute__((visibility("hidden")))
212 # define ITK_ABI_IMPORT
213 # define ITK_ABI_EXPORT
214 # define ITK_ABI_HIDDEN
219 #ifndef ITK_TEMPLATE_EXPORT
220 # ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
221 # define ITK_TEMPLATE_EXPORT __attribute__((visibility("default")))
223 # define ITK_TEMPLATE_EXPORT
228 #ifdef ITK_TEMPLATE_VISIBILITY_DEFAULT
229 # define ITK_FORCE_EXPORT_MACRO(moduleName) __attribute__((visibility("default")))
231 # define ITK_FORCE_EXPORT_MACRO(moduleName) moduleName##_EXPORT
234 #ifndef ITK_FORWARD_EXPORT
236 # if defined(__APPLE__) && defined(ITK_TEMPLATE_VISIBILITY_DEFAULT) && defined(ITK_BUILD_SHARED_LIBS) && \
237 defined(USE_COMPILER_HIDDEN_VISIBILITY)
238 # define ITK_FORWARD_EXPORT __attribute__((visibility("default")))
240 # define ITK_FORWARD_EXPORT
248 #define ITK_NOEXCEPT_OR_THROW error "Replace ITK_NOEXCEPT_OR_THROW with ITK_NOEXCEPT"
250 #if !defined(ITK_LEGACY_REMOVE)
251 # define ITK_DELETE_FUNCTION = delete
253 # define ITK_DELETE_FUNCTION error "Replace ITK_DELETE_FUNCTION with = delete"
260 #if defined(ITK_FUTURE_LEGACY_REMOVE)
261 # define ITK_CONSTEXPR_FUNC "Replace ITK_CONSTEXPR_FUNC with constexpr"
262 # define ITK_CONSTEXPR_VAR "Replace ITK_CONSTEXPR_VAR with constexpr"
264 # define itkExposeEnumValue(name) static_cast<int>(name)
268 # define ITK_CONSTEXPR_FUNC constexpr
269 # define ITK_CONSTEXPR_VAR constexpr
272 # define itkExposeEnumValue(name) static_cast<int>(name)
277 #if defined(__GNUC__) && !defined(__INTEL_COMPILER)
279 # define ITK_FALLTHROUGH __attribute__((fallthrough))
281 #elif defined(__has_warning)
282 # if __has_feature(cxx_attributes) && __has_warning("-Wimplicit-fallthrough")
283 # define ITK_FALLTHROUGH [[clang::fallthrough]]
287 #ifndef ITK_FALLTHROUGH
288 # define ITK_FALLTHROUGH ((void)0)
311 #define itkNewMacro(x) \
312 itkSimpleNewMacro(x); \
313 itkCreateAnotherMacro(x); \
315 ITK_MACROEND_NOOP_STATEMENT
318 #define itkSimpleNewMacro(x) \
319 static Pointer New() \
321 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
322 if (smartPtr == nullptr) \
326 smartPtr->UnRegister(); \
329 ITK_MACROEND_NOOP_STATEMENT
331 #define itkCreateAnotherMacro(x) \
332 ::itk::LightObject::Pointer CreateAnother() const override \
334 ::itk::LightObject::Pointer smartPtr; \
335 smartPtr = x::New().GetPointer(); \
338 ITK_MACROEND_NOOP_STATEMENT
340 #define itkCloneMacro(x) \
341 Pointer Clone() const \
343 Pointer rval = dynamic_cast<x *>(this->InternalClone().GetPointer()); \
346 ITK_MACROEND_NOOP_STATEMENT
360 #define itkFactorylessNewMacro(x) \
361 static Pointer New() \
364 x * rawPtr = new x; \
366 rawPtr->UnRegister(); \
369 ::itk::LightObject::Pointer CreateAnother() const override \
371 ::itk::LightObject::Pointer smartPtr; \
372 smartPtr = x::New().GetPointer(); \
375 ITK_MACROEND_NOOP_STATEMENT
387 #define ITK_DISALLOW_COPY_AND_MOVE(TypeName) \
388 TypeName(const TypeName &) = delete; \
389 TypeName & operator=(const TypeName &) = delete; \
390 TypeName(TypeName &&) = delete; \
391 TypeName & operator=(TypeName &&) = delete
393 #if !defined(ITK_FUTURE_LEGACY_REMOVE)
394 # define ITK_DISALLOW_COPY_AND_ASSIGN(TypeName) ITK_DISALLOW_COPY_AND_MOVE(TypeName)
399 #define itkTypeMacro(thisClass, superclass) \
400 const char * GetNameOfClass() const override { return #thisClass; } \
401 ITK_MACROEND_NOOP_STATEMENT
403 #define itkTypeMacroNoParent(thisClass) \
404 virtual const char * GetNameOfClass() const { return #thisClass; } \
405 ITK_MACROEND_NOOP_STATEMENT
415 extern ITKCommon_EXPORT
void
416 OutputWindowDisplayText(
const char *);
419 extern ITKCommon_EXPORT
void
420 OutputWindowDisplayErrorText(
const char *);
422 extern ITKCommon_EXPORT
void
423 OutputWindowDisplayWarningText(
const char *);
425 extern ITKCommon_EXPORT
void
426 OutputWindowDisplayGenericOutputText(
const char *);
428 extern ITKCommon_EXPORT
void
429 OutputWindowDisplayDebugText(
const char *);
437 # define itkDebugMacro(x) ITK_NOOP_STATEMENT
438 # define itkDebugStatement(x) ITK_NOOP_STATEMENT
440 # define itkDebugMacro(x) \
443 if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
445 std::ostringstream itkmsg; \
446 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
447 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
448 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str()); \
455 # define itkDebugStatement(x) x
461 #define itkWarningMacro(x) \
464 if (::itk::Object::GetGlobalWarningDisplay()) \
466 std::ostringstream itkmsg; \
467 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
468 << this->GetNameOfClass() << " (" << this << "): " x << "\n\n"; \
469 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str()); \
474 #define itkWarningStatement(x) x
476 #if defined(ITK_CPP_FUNCTION)
477 # if defined(_WIN32) && !defined(__MINGW32__) && !defined(ITK_WRAPPING_PARSER)
478 # define ITK_LOCATION __FUNCSIG__
479 # elif defined(__GNUC__)
480 # define ITK_LOCATION __PRETTY_FUNCTION__
482 # define ITK_LOCATION __FUNCTION__
485 # define ITK_LOCATION "unknown"
488 #define itkDeclareExceptionMacro(newexcp, parentexcp, whatmessage) \
491 class newexcp : public parentexcp \
495 static constexpr const char * const default_exception_message = whatmessage; \
496 explicit newexcp(const char * file, \
497 unsigned int lineNumber = 0, \
498 const char * desc = "None", \
499 const char * loc = "Unknown") \
500 : parentexcp(std::string{ file }, lineNumber, std::string{ desc }, std::string{ loc }) \
502 explicit newexcp(std::string file, \
503 unsigned int lineNumber = 0, \
504 std::string desc = std::string{ "None" }, \
505 std::string loc = std::string{ "Unknown" }) \
506 : parentexcp(std::move(file), lineNumber, std::move(desc), std::move(loc)) \
508 itkTypeMacro(newexcp, parentexcp); \
511 ITK_MACROEND_NOOP_STATEMENT
514 #define itkSpecializedMessageExceptionMacro(ExceptionType, x) \
516 std::ostringstream message; \
517 message << "itk::ERROR: " x; \
518 throw ::itk::ExceptionType( \
519 std::string{ __FILE__ }, __LINE__, std::string{ message.str() }, std::string{ ITK_LOCATION }); \
521 ITK_MACROEND_NOOP_STATEMENT
523 #define itkSpecializedExceptionMacro(ExceptionType) \
525 itkSpecializedMessageExceptionMacro(ExceptionType, \
526 "itk::ERROR: " << ::itk::ExceptionType::default_exception_message); \
528 ITK_MACROEND_NOOP_STATEMENT
533 #define itkExceptionMacro(x) \
535 itkSpecializedMessageExceptionMacro(ExceptionObject, \
536 "itk::ERROR: " << this->GetNameOfClass() << "(" << this << "): " x); \
538 ITK_MACROEND_NOOP_STATEMENT
541 #define itkGenericExceptionMacro(x) \
543 itkSpecializedMessageExceptionMacro(ExceptionObject, x); \
545 ITK_MACROEND_NOOP_STATEMENT
547 #define itkGenericOutputMacro(x) \
549 if (::itk::Object::GetGlobalWarningDisplay()) \
551 std::ostringstream itkmsg; \
552 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" x << "\n\n"; \
553 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str()); \
556 ITK_MACROEND_NOOP_STATEMENT
561 #define itkLogMacro(x, y) \
563 if (this->GetLogger()) \
565 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
568 ITK_MACROEND_NOOP_STATEMENT
570 #define itkLogMacroStatic(obj, x, y) \
572 if (obj->GetLogger()) \
574 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
577 ITK_MACROEND_NOOP_STATEMENT
608 #if defined(ITK_LEGACY_REMOVE)
609 # define itkLegacyMacro(method)
611 # if defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST)
613 # define itkLegacyMacro(method) method
617 # if defined(__GNUC__) && !defined(__INTEL_COMPILER)
618 # define itkLegacyMacro(method) method __attribute__((deprecated))
619 # elif defined(_MSC_VER)
620 # define itkLegacyMacro(method) __declspec(deprecated) method
622 # define itkLegacyMacro(method) method
649 #if defined(ITK_LEGACY_SILENT)
650 # define itkLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
651 # define itkLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
652 # define itkGenericLegacyBodyMacro(method, version) ITK_NOOP_STATEMENT
653 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) ITK_NOOP_STATEMENT
655 # define itkLegacyBodyMacro(method, version) \
656 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
657 # define itkLegacyReplaceBodyMacro(method, version, replace) \
658 itkWarningMacro(#method " was deprecated for ITK " #version \
659 " and will be removed in a future version. Use " #replace " instead.")
660 # define itkGenericLegacyBodyMacro(method, version) \
661 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
662 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
663 itkGenericOutputMacro(#method " was deprecated for ITK " #version \
664 " and will be removed in a future version. Use " #replace " instead.")
671 #define ITK_CACHE_LINE_ALIGNMENT 64
679 #define itkPadStruct(mincachesize, oldtype, newtype) \
680 struct newtype : public oldtype \
682 char _StructPadding[mincachesize - (sizeof(oldtype) % mincachesize)]; \
689 #if defined(ITK_HAS_GNU_ATTRIBUTE_ALIGNED)
690 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype __attribute__((aligned(alignment)))
691 #elif defined(_MSC_VER)
692 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = __declspec(align(alignment)) oldtype
694 # define itkAlignedTypedef(alignment, oldtype, newtype) using newtype = oldtype
697 #if defined(ITK_FUTURE_LEGACY_REMOVE)
720 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) < >
721 #else // LEGACY_REMOVE
722 # define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) "Macro remove use C++11 compliant declaration of "
738 #define itkForLoopAssignmentMacro( \
739 DestinationType, SourceType, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
740 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
742 DestinationArray[i] = static_cast<DestinationElementType>(SourceArray[i]); \
754 #define itkForLoopRoundingAndAssignmentMacro( \
755 DestinationType, Sourcrnd_halfintup, DestinationElementType, DestinationArray, SourceArray, NumberOfIterations) \
756 for (unsigned int i = 0; i < NumberOfIterations; ++i) \
758 DestinationArray[i] = itk::Math::Round<DestinationElementType>(SourceArray[i]); \
765 # ifdef _POSIX_SOURCE
766 # define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail(msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
768 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
772 # define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro(<< msg);
775 #define itkAssertOrThrowMacro(test, message) \
778 std::ostringstream msgstr; \
780 itkAssertInDebugOrThrowInReleaseMacro(msgstr.str().c_str()); \
782 ITK_MACROEND_NOOP_STATEMENT
785 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) assert(X)
787 # define itkAssertInDebugAndIgnoreInReleaseMacro(X) ITK_NOOP_STATEMENT
810 #define itkStaticConstMacro(name, type, value) static constexpr type name = value
812 #define itkGetStaticConstMacro(name) (Self::name)
815 #define itkSetInputMacro(name, type) \
816 virtual void Set##name(const type * _arg) \
818 itkDebugMacro("setting input " #name " to " << _arg); \
819 if (_arg != itkDynamicCastInDebugMode<type *>(this->ProcessObject::GetInput(#name))) \
821 this->ProcessObject::SetInput(#name, const_cast<type *>(_arg)); \
825 ITK_MACROEND_NOOP_STATEMENT
829 #define itkGetInputMacro(name, type) \
830 virtual const type * Get##name() const \
832 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
833 return itkDynamicCastInDebugMode<const type *>(this->ProcessObject::GetInput(#name)); \
835 ITK_MACROEND_NOOP_STATEMENT
840 #define itkSetDecoratedInputMacro(name, type) \
841 virtual void Set##name##Input(const SimpleDataObjectDecorator<type> * _arg) \
843 itkDebugMacro("setting input " #name " to " << _arg); \
844 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
846 this->ProcessObject::SetInput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
850 virtual void Set##name(const SimpleDataObjectDecorator<type> * _arg) { this->Set##name##Input(_arg); } \
851 virtual void Set##name(const type & _arg) \
853 using DecoratorType = SimpleDataObjectDecorator<type>; \
854 itkDebugMacro("setting input " #name " to " << _arg); \
855 const DecoratorType * oldInput = \
856 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
858 CLANG_SUPPRESS_Wfloat_equal \
859 if (oldInput && oldInput->Get() == _arg) \
864 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
865 newInput->Set(_arg); \
866 this->Set##name##Input(newInput); \
868 ITK_MACROEND_NOOP_STATEMENT
873 #define itkGetDecoratedInputMacro(name, type) \
874 virtual const SimpleDataObjectDecorator<type> * Get##name##Input() const \
876 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
877 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
879 virtual const type & Get##name() const \
881 itkDebugMacro("Getting input " #name); \
882 using DecoratorType = SimpleDataObjectDecorator<type>; \
883 const DecoratorType * input = \
884 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
885 if (input == nullptr) \
887 itkExceptionMacro(<< "input" #name " is not set"); \
889 return input->Get(); \
891 ITK_MACROEND_NOOP_STATEMENT
896 #define itkSetGetDecoratedInputMacro(name, type) \
897 itkSetDecoratedInputMacro(name, type); \
898 itkGetDecoratedInputMacro(name, type)
904 #define itkSetDecoratedObjectInputMacro(name, type) \
905 virtual void Set##name##Input(const DataObjectDecorator<type> * _arg) \
907 itkDebugMacro("setting input " #name " to " << _arg); \
908 if (_arg != itkDynamicCastInDebugMode<DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name))) \
910 this->ProcessObject::SetInput(#name, const_cast<DataObjectDecorator<type> *>(_arg)); \
914 virtual void Set##name(const type * _arg) \
916 using DecoratorType = DataObjectDecorator<type>; \
917 itkDebugMacro("setting input " #name " to " << _arg); \
918 const DecoratorType * oldInput = \
919 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
920 if (oldInput && oldInput->Get() == _arg) \
924 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
925 newInput->Set(_arg); \
926 this->Set##name##Input(newInput); \
928 ITK_MACROEND_NOOP_STATEMENT
935 #define itkGetDecoratedObjectInputMacro(name, type) \
936 virtual const DataObjectDecorator<type> * Get##name##Input() const \
938 itkDebugMacro("returning input " << #name " of " << this->ProcessObject::GetInput(#name)); \
939 return itkDynamicCastInDebugMode<const DataObjectDecorator<type> *>(this->ProcessObject::GetInput(#name)); \
941 virtual const type * Get##name() const \
943 itkDebugMacro("Getting input " #name); \
944 using DecoratorType = DataObjectDecorator<type>; \
945 const DecoratorType * input = \
946 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetInput(#name)); \
947 if (input == nullptr) \
951 return input->Get(); \
953 ITK_MACROEND_NOOP_STATEMENT
958 #define itkSetGetDecoratedObjectInputMacro(name, type) \
959 itkSetDecoratedObjectInputMacro(name, type); \
960 itkGetDecoratedObjectInputMacro(name, type)
964 #define itkSetMacro(name, type) \
965 virtual void Set##name(const type _arg) \
967 itkDebugMacro("setting " #name " to " << _arg); \
969 CLANG_SUPPRESS_Wfloat_equal \
970 if (this->m_##name != _arg) \
972 this->m_##name = _arg; \
977 ITK_MACROEND_NOOP_STATEMENT
981 #define itkGetMacro(name, type) \
982 virtual type Get##name() { return this->m_##name; } \
983 ITK_MACROEND_NOOP_STATEMENT
989 #define itkGetConstMacro(name, type) \
990 virtual type Get##name() const { return this->m_##name; } \
991 ITK_MACROEND_NOOP_STATEMENT
998 #define itkGetConstReferenceMacro(name, type) \
999 virtual const type & Get##name() const { return this->m_##name; } \
1000 ITK_MACROEND_NOOP_STATEMENT
1007 #define itkSetEnumMacro(name, type) \
1008 virtual void Set##name(const type _arg) \
1010 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
1011 if (this->m_##name != _arg) \
1013 this->m_##name = _arg; \
1017 ITK_MACROEND_NOOP_STATEMENT
1024 #define itkGetEnumMacro(name, type) \
1025 virtual type Get##name() const { return this->m_##name; } \
1026 ITK_MACROEND_NOOP_STATEMENT
1032 #define itkSetStringMacro(name) \
1033 virtual void Set##name(const char * _arg) \
1035 if (_arg && (_arg == this->m_##name)) \
1041 this->m_##name = _arg; \
1045 this->m_##name = ""; \
1049 virtual void Set##name(const std::string & _arg) { this->Set##name(_arg.c_str()); } \
1050 ITK_MACROEND_NOOP_STATEMENT
1057 #define itkGetStringMacro(name) \
1058 virtual const char * Get##name() const { return this->m_##name.c_str(); } \
1059 ITK_MACROEND_NOOP_STATEMENT
1065 #define itkSetClampMacro(name, type, min, max) \
1066 virtual void Set##name(type _arg) \
1068 const type temp_extrema = (_arg < min ? min : (_arg > max ? max : _arg)); \
1069 itkDebugMacro("setting " << #name " to " << _arg); \
1071 CLANG_SUPPRESS_Wfloat_equal \
1072 if (this->m_##name != temp_extrema) \
1074 this->m_##name = temp_extrema; \
1079 ITK_MACROEND_NOOP_STATEMENT
1089 #define itkSetObjectMacro(name, type) \
1090 virtual void Set##name(type * _arg) \
1092 itkDebugMacro("setting " << #name " to " << _arg); \
1094 CLANG_SUPPRESS_Wfloat_equal \
1095 if (this->m_##name != _arg) \
1097 this->m_##name = _arg; \
1102 ITK_MACROEND_NOOP_STATEMENT
1131 #define itkGetConstObjectMacro(name, type) \
1132 virtual const type * Get##name() const { return this->m_##name.GetPointer(); } \
1133 ITK_MACROEND_NOOP_STATEMENT
1136 #if defined(ITK_FUTURE_LEGACY_REMOVE)
1142 # define itkGetObjectMacro(name, type) \
1143 virtual type * Get##name() \
1145 purposeful_error("itkGetObjectMacro should be replaced with itkGetModifiableObjectMacro."); \
1148 # define itkGetModifiableObjectMacro(name, type) \
1149 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1150 itkGetConstObjectMacro(name, type)
1152 #else // defined ( ITK_FUTURE_LEGACY_REMOVE )
1155 # define itkGetObjectMacro(name, type) \
1156 virtual type * Get##name() { return this->m_##name.GetPointer(); } \
1157 ITK_MACROEND_NOOP_STATEMENT
1158 # define itkGetModifiableObjectMacro(name, type) \
1159 virtual type * GetModifiable##name() { return this->m_##name.GetPointer(); } \
1160 itkGetConstObjectMacro(name, type); \
1161 itkGetObjectMacro(name, type)
1162 #endif // defined ( ITK_FUTURE_LEGACY_REMOVE )
1171 #define itkGetConstReferenceObjectMacro(name, type) \
1172 virtual const typename type::Pointer & Get##name() const { return this->m_##name; } \
1173 ITK_MACROEND_NOOP_STATEMENT
1179 #define itkSetConstObjectMacro(name, type) \
1180 virtual void Set##name(const type * _arg) \
1182 itkDebugMacro("setting " << #name " to " << _arg); \
1183 if (this->m_##name != _arg) \
1185 this->m_##name = _arg; \
1189 ITK_MACROEND_NOOP_STATEMENT
1194 #define itkBooleanMacro(name) \
1195 virtual void name##On() { this->Set##name(true); } \
1196 virtual void name##Off() { this->Set##name(false); }
1203 #define itkSetVectorMacro(name, type, count) \
1204 virtual void Set##name(type data[]) \
1207 for (i = 0; i < count; i++) \
1210 CLANG_SUPPRESS_Wfloat_equal \
1211 if (data[i] != this->m_##name[i]) \
1220 for (i = 0; i < count; i++) \
1222 this->m_##name[i] = data[i]; \
1226 ITK_MACROEND_NOOP_STATEMENT
1232 #define itkGetVectorMacro(name, type, count) \
1233 virtual type * Get##name() const { return this->m_##name; } \
1234 ITK_MACROEND_NOOP_STATEMENT
1240 #define itkGPUKernelClassMacro(kernel) \
1244 static const char * GetOpenCLSource(); \
1248 virtual ~kernel(); \
1249 kernel(const kernel &); \
1250 void operator=(const kernel &); \
1254 #define itkGetOpenCLSourceFromKernelMacro(kernel) \
1255 static const char * GetOpenCLSource() { return kernel::GetOpenCLSource(); }
1259 #define itkPrintSelfObjectMacro(name) \
1260 if (static_cast<const LightObject *>(this->m_##name) == nullptr) \
1262 os << indent << #name << ": (null)" << std::endl; \
1266 os << indent << #name << ": " << std::endl; \
1267 this->m_##name->Print(os, indent.GetNextIndent()); \
1269 ITK_MACROEND_NOOP_STATEMENT
1273 #define itkSetDecoratedOutputMacro(name, type) \
1274 virtual void Set##name##Output(const SimpleDataObjectDecorator<type> * _arg) \
1276 itkDebugMacro("setting output " #name " to " << _arg); \
1277 if (_arg != itkDynamicCastInDebugMode<SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name))) \
1279 this->ProcessObject::SetOutput(#name, const_cast<SimpleDataObjectDecorator<type> *>(_arg)); \
1283 virtual void Set##name(const type & _arg) \
1285 using DecoratorType = SimpleDataObjectDecorator<type>; \
1286 itkDebugMacro("setting output " #name " to " << _arg); \
1287 DecoratorType * output = itkDynamicCastInDebugMode<DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1290 if (output->Get() == _arg) \
1296 output->Set(_arg); \
1301 typename DecoratorType::Pointer newOutput = DecoratorType::New(); \
1302 newOutput->Set(_arg); \
1303 this->Set##name##Output(newOutput); \
1306 ITK_MACROEND_NOOP_STATEMENT
1310 #define itkGetDecoratedOutputMacro(name, type) \
1311 virtual const SimpleDataObjectDecorator<type> * Get##name##Output() const \
1313 itkDebugMacro("returning output " << #name " of " << this->ProcessObject::GetOutput(#name)); \
1314 return itkDynamicCastInDebugMode<const SimpleDataObjectDecorator<type> *>(this->ProcessObject::GetOutput(#name)); \
1316 virtual const type & Get##name() const \
1318 itkDebugMacro("Getting output " #name); \
1319 using DecoratorType = SimpleDataObjectDecorator<type>; \
1320 const DecoratorType * output = \
1321 itkDynamicCastInDebugMode<const DecoratorType *>(this->ProcessObject::GetOutput(#name)); \
1322 if (output == nullptr) \
1324 itkExceptionMacro(<< "output" #name " is not set"); \
1326 return output->Get(); \
1328 ITK_MACROEND_NOOP_STATEMENT
1341 #if defined(ITKV4_COMPATIBILITY)
1342 # define ITK_ITERATOR_VIRTUAL virtual
1343 # define ITK_ITERATOR_OVERRIDE override
1344 # define ITK_ITERATOR_FINAL
1345 #elif !defined(ITK_LEGACY_REMOVE)
1346 # define ITK_ITERATOR_VIRTUAL virtual
1347 # define ITK_ITERATOR_OVERRIDE override
1348 # define ITK_ITERATOR_FINAL final
1350 # define ITK_ITERATOR_VIRTUAL
1351 # define ITK_ITERATOR_OVERRIDE
1352 # define ITK_ITERATOR_FINAL
1355 #if defined(ITKV4_COMPATIBILITY)
1357 # define ITKv5_CONST
1360 # define ITKv5_CONST const
1363 #define itkExceptionObject_h
1365 #undef itkExceptionObject_h