00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00030 #ifndef __itkMacro_h
00031 #define __itkMacro_h
00032
00033 #include "itkWin32Header.h"
00034 #include "itkConfigure.h"
00035
00036 #include <string>
00037 #include <cstdlib>
00038 #ifndef NDEBUG
00039 #include <cassert>
00040 #endif
00041
00042 #include "vnl/vnl_math.h"
00043
00044
00045 #if !defined(CMAKE_NO_ANSI_STRING_STREAM)
00046 # include <sstream>
00047 #elif !defined(CMAKE_NO_ANSI_STREAM_HEADERS)
00048 # include <strstream>
00049 # define ITK_NO_ANSI_STRING_STREAM
00050 #else
00051 # include <strstream.h>
00052 # define ITK_NO_ANSI_STRING_STREAM
00053 #endif
00054
00059 namespace itk
00060 {
00061 }
00062
00065 #define itkNotUsed(x)
00066
00081 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
00082 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00083 #endif
00084 #if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x540)
00085 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00086 #endif
00087 #if defined(__SVR4) && !defined(__SUNPRO_CC)
00088 # define ITK_NO_INCLASS_MEMBER_INITIALIZATION
00089 #endif
00090
00091
00092
00093
00094
00095
00096
00097
00098 #if defined(__GNUC__)
00099 # define ITK_NO_SIZEOF_CONSTANT_LOOKUP
00100 #endif
00101
00102 #if defined(_MSC_VER) && (_MSC_VER <= 1300)
00103 #define ITK_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
00104 #endif
00105
00106 #if defined(ITK_NO_INCLASS_MEMBER_INITIALIZATION) || \
00107 defined(ITK_NO_SIZEOF_CONSTANT_LOOKUP)
00108 # define itkStaticConstMacro(name,type,value) enum { name = value }
00109 #else
00110 # define itkStaticConstMacro(name,type,value) static const type name = value
00111 #endif
00112
00113 #ifdef ITK_NO_SELF_AS_TRAIT_IN_TEMPLATE_ARGUMENTS
00114 # define itkGetStaticConstMacro(name) name
00115 #else
00116 # define itkGetStaticConstMacro(name) (Self::name)
00117 #endif
00118
00120 #define itkSetInputMacro(name, type, number) \
00121 virtual void Set##name##Input(const type *_arg) \
00122 { \
00123 itkDebugMacro("setting input " #name " to " << _arg); \
00124 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
00125 { \
00126 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
00127 this->Modified(); \
00128 } \
00129 } \
00130 virtual void SetInput##number(const type *_arg) \
00131 { \
00132 itkDebugMacro("setting input " #number " to " << _arg); \
00133 if (_arg != static_cast<type *>(this->ProcessObject::GetInput( number ))) \
00134 { \
00135 this->ProcessObject::SetNthInput( number, const_cast<type *>(_arg) ); \
00136 this->Modified(); \
00137 } \
00138 }
00139
00140
00142 #define itkSuperclassTraitMacro(traitnameType) \
00143 typedef typename Superclass::traitnameType traitnameType;
00144
00146 #define itkGetInputMacro(name, type, number) \
00147 virtual const type * Get##name##Input() const \
00148 { \
00149 itkDebugMacro("returning input " << #name " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
00150 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
00151 } \
00152 virtual const type * GetInput##number() const \
00153 { \
00154 itkDebugMacro("returning input " << #number " of " << static_cast<const type *>(this->ProcessObject::GetInput( number )) ); \
00155 return static_cast<const type *>(this->ProcessObject::GetInput( number )); \
00156 }
00157
00158
00161 #define itkSetDecoratedInputMacro(name, type, number) \
00162 itkSetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
00163 itkGetInputMacro(name, SimpleDataObjectDecorator<type>, number); \
00164 virtual void Set##name(const type &_arg) \
00165 { \
00166 typedef SimpleDataObjectDecorator< type > DecoratorType; \
00167 itkDebugMacro("setting input " #name " to " << _arg); \
00168 const DecoratorType * oldInput = \
00169 static_cast< const DecoratorType * >( \
00170 this->ProcessObject::GetInput(number) ); \
00171 if( oldInput && oldInput->Get() == _arg ) \
00172 { \
00173 return; \
00174 } \
00175 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
00176 newInput->Set( _arg ); \
00177 this->Set##name##Input( newInput ); \
00178 }
00179
00180
00184 #define itkSetDecoratedObjectInputMacro(name, type, number) \
00185 itkSetInputMacro(name, DataObjectDecorator<type>, number); \
00186 itkGetInputMacro(name, DataObjectDecorator<type>, number); \
00187 virtual void Set##name(const type *_arg) \
00188 { \
00189 typedef DataObjectDecorator< type > DecoratorType; \
00190 itkDebugMacro("setting input " #name " to " << _arg); \
00191 const DecoratorType * oldInput = \
00192 static_cast< const DecoratorType * >( \
00193 this->ProcessObject::GetInput(number) ); \
00194 if( oldInput && oldInput->Get() == _arg ) \
00195 { \
00196 return; \
00197 } \
00198 typename DecoratorType::Pointer newInput = DecoratorType::New(); \
00199 newInput->Set( _arg ); \
00200 this->Set##name##Input( newInput ); \
00201 }
00202
00203
00204
00206 #define itkSetMacro(name,type) \
00207 virtual void Set##name (const type _arg) \
00208 { \
00209 itkDebugMacro("setting " #name " to " << _arg); \
00210 if (this->m_##name != _arg) \
00211 { \
00212 this->m_##name = _arg; \
00213 this->Modified(); \
00214 } \
00215 }
00216
00217
00219 #define itkGetMacro(name,type) \
00220 virtual type Get##name () \
00221 { \
00222 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00223 return this->m_##name; \
00224 }
00225
00226
00230 #define itkGetConstMacro(name,type) \
00231 virtual type Get##name () const \
00232 { \
00233 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00234 return this->m_##name; \
00235 }
00236
00237
00242 #define itkGetConstReferenceMacro(name,type) \
00243 virtual const type & Get##name () const \
00244 { \
00245 itkDebugMacro("returning " << #name " of " << this->m_##name ); \
00246 return this->m_##name; \
00247 }
00248
00249
00254 #define itkSetEnumMacro(name,type) \
00255 virtual void Set##name (const type _arg) \
00256 { \
00257 itkDebugMacro("setting " #name " to " << static_cast<long>(_arg)); \
00258 if (this->m_##name != _arg) \
00259 { \
00260 this->m_##name = _arg; \
00261 this->Modified(); \
00262 } \
00263 }
00264
00265
00270 #define itkGetEnumMacro(name,type) \
00271 virtual type Get##name () const \
00272 { \
00273 itkDebugMacro("returning " << #name " of " << static_cast<long>(this->m_##name) ); \
00274 return this->m_##name; \
00275 }
00276
00277
00281 #define itkSetStringMacro(name) \
00282 virtual void Set##name (const char* _arg) \
00283 { \
00284 if ( _arg && (_arg == this->m_##name) ) { return;} \
00285 if (_arg) \
00286 { \
00287 this->m_##name = _arg;\
00288 } \
00289 else \
00290 { \
00291 this->m_##name = ""; \
00292 } \
00293 this->Modified(); \
00294 } \
00295 virtual void Set##name (const std::string & _arg) \
00296 { \
00297 this->Set##name( _arg.c_str() ); \
00298 } \
00299
00300
00301
00305 #define itkGetStringMacro(name) \
00306 virtual const char* Get##name () const \
00307 { \
00308 return this->m_##name.c_str(); \
00309 }
00310
00314 #define itkSetClampMacro(name,type,min,max) \
00315 virtual void Set##name (type _arg) \
00316 { \
00317 itkDebugMacro("setting " << #name " to " << _arg ); \
00318 if (this->m_##name != (_arg<min?min:(_arg>max?max:_arg))) \
00319 { \
00320 this->m_##name = (_arg<min?min:(_arg>max?max:_arg)); \
00321 this->Modified(); \
00322 } \
00323 }
00324
00325
00330 #define itkSetObjectMacro(name,type) \
00331 virtual void Set##name (type* _arg) \
00332 { \
00333 itkDebugMacro("setting " << #name " to " << _arg ); \
00334 if (this->m_##name != _arg) \
00335 { \
00336 this->m_##name = _arg; \
00337 this->Modified(); \
00338 } \
00339 }
00340
00341
00344 #define itkGetObjectMacro(name,type) \
00345 virtual type * Get##name () \
00346 { \
00347 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00348 return this->m_##name.GetPointer(); \
00349 }
00350
00351
00356 #define itkSetConstObjectMacro(name,type) \
00357 virtual void Set##name (const type* _arg) \
00358 { \
00359 itkDebugMacro("setting " << #name " to " << _arg ); \
00360 if (this->m_##name != _arg) \
00361 { \
00362 this->m_##name = _arg; \
00363 this->Modified(); \
00364 } \
00365 }
00366
00367
00368
00371 #define itkGetConstObjectMacro(name,type) \
00372 virtual const type * Get##name () const \
00373 { \
00374 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00375 return this->m_##name.GetPointer(); \
00376 }
00377
00378
00381 #define itkGetConstReferenceObjectMacro(name,type) \
00382 virtual const typename type::Pointer & Get##name () const \
00383 { \
00384 itkDebugMacro("returning " #name " address " << this->m_##name ); \
00385 return this->m_##name; \
00386 }
00387
00388
00391 #define itkBooleanMacro(name) \
00392 virtual void name##On () { this->Set##name(true);} \
00393 virtual void name##Off () { this->Set##name(false);}
00394
00395
00399 #define itkSetVectorMacro(name,type,count) \
00400 virtual void Set##name(type data[]) \
00401 { \
00402 unsigned int i; \
00403 for (i=0; i<count; i++) { if ( data[i] != this->m_##name[i] ) { break; }} \
00404 if ( i < count ) \
00405 { \
00406 this->Modified(); \
00407 for (i=0; i<count; i++) { this->m_##name[i] = data[i]; }\
00408 } \
00409 }
00410
00411
00414 #define itkGetVectorMacro(name,type,count) \
00415 virtual type *Get##name () const \
00416 { \
00417 return this->m_##name; \
00418 }
00419
00436 #define itkNewMacro(x) \
00437 static Pointer New(void) \
00438 { \
00439 Pointer smartPtr = ::itk::ObjectFactory<x>::Create(); \
00440 if(smartPtr.GetPointer() == NULL) \
00441 { \
00442 smartPtr = new x; \
00443 } \
00444 smartPtr->UnRegister(); \
00445 return smartPtr; \
00446 } \
00447 virtual ::itk::LightObject::Pointer CreateAnother(void) const \
00448 { \
00449 ::itk::LightObject::Pointer smartPtr; \
00450 smartPtr = x::New().GetPointer(); \
00451 return smartPtr; \
00452 }
00453
00454
00455
00472 #define itkFactorylessNewMacro(x) \
00473 static Pointer New(void) \
00474 { \
00475 Pointer smartPtr; \
00476 x *rawPtr = new x; \
00477 smartPtr = rawPtr; \
00478 rawPtr->UnRegister(); \
00479 return smartPtr; \
00480 } \
00481 virtual ::itk::LightObject::Pointer CreateAnother(void) const \
00482 { \
00483 ::itk::LightObject::Pointer smartPtr; \
00484 smartPtr = x::New().GetPointer(); \
00485 return smartPtr; \
00486 }
00487
00488
00491 #define itkTypeMacro(thisClass,superclass) \
00492 virtual const char *GetNameOfClass() const \
00493 {return #thisClass;}
00494
00495
00496 namespace itk
00497 {
00504 extern ITKCommon_EXPORT void OutputWindowDisplayText(const char*);
00505 extern ITKCommon_EXPORT void OutputWindowDisplayErrorText(const char*);
00506 extern ITKCommon_EXPORT void OutputWindowDisplayWarningText(const char*);
00507 extern ITKCommon_EXPORT void OutputWindowDisplayGenericOutputText(const char*);
00508 extern ITKCommon_EXPORT void OutputWindowDisplayDebugText(const char*);
00509 }
00511
00515 #if defined(ITK_LEAN_AND_MEAN) || defined(__BORLANDC__) || defined(NDEBUG)
00516 #define itkDebugMacro(x)
00517 #else
00518 #define itkDebugMacro(x) \
00519 { if (this->GetDebug() && ::itk::Object::GetGlobalWarningDisplay()) \
00520 { ::itk::OStringStream itkmsg; \
00521 itkmsg << "Debug: In " __FILE__ ", line " << __LINE__ << "\n" \
00522 << this->GetNameOfClass() << " (" << this << "): " x \
00523 << "\n\n"; \
00524 ::itk::OutputWindowDisplayDebugText(itkmsg.str().c_str());} \
00525 }
00526 #endif
00527
00528
00529
00533 #ifdef ITK_LEAN_AND_MEAN
00534 #define itkWarningMacro(x)
00535 #else
00536 #define itkWarningMacro(x) \
00537 { if (::itk::Object::GetGlobalWarningDisplay()) \
00538 { ::itk::OStringStream itkmsg; \
00539 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00540 << this->GetNameOfClass() << " (" << this << "): " x \
00541 << "\n\n"; \
00542 ::itk::OutputWindowDisplayWarningText(itkmsg.str().c_str());} \
00543 }
00544 #endif
00545
00546
00547 namespace itk
00548 {
00549
00555 #if !defined(ITK_NO_ANSI_STRING_STREAM)
00556 class OStringStream: public std::ostringstream
00557 {
00558 public:
00559 OStringStream() {}
00560 private:
00561 OStringStream(const OStringStream&);
00562 void operator=(const OStringStream&);
00563 };
00564 #else
00565 namespace OStringStreamDetail
00566 {
00567 class Cleanup
00568 {
00569 public:
00570 Cleanup(std::ostrstream& ostr): m_OStrStream(ostr) {}
00571 ~Cleanup() { m_OStrStream.rdbuf()->freeze(0); }
00572 static void IgnoreUnusedVariable(const Cleanup&) {}
00573 protected:
00574 std::ostrstream& m_OStrStream;
00575 };
00576 }
00578
00579 class OStringStream: public std::ostrstream
00580 {
00581 public:
00582 typedef std::ostrstream Superclass;
00583 OStringStream() {}
00584 std::string str()
00585 {
00586 OStringStreamDetail::Cleanup cleanup(*this);
00587 OStringStreamDetail::Cleanup::IgnoreUnusedVariable(cleanup);
00588 int pcount = this->pcount();
00589 const char* ptr = this->Superclass::str();
00590 return std::string(ptr?ptr:"", pcount);
00591 }
00592 private:
00593 OStringStream(const OStringStream&);
00594 void operator=(const OStringStream&);
00595 };
00596 #endif
00597
00598 }
00599
00600 #if defined(ITK_CPP_FUNCTION)
00601 #if defined(__BORLANDC__)
00602 #define ITK_LOCATION __FUNC__
00603 #elif defined(_WIN32) && !defined(__MINGW32__) && !defined(__CYGWIN__) && !defined(CABLE_CONFIGURATION) && !defined(CSWIG)
00604 #define ITK_LOCATION __FUNCSIG__
00605 #elif defined(__GNUC__)
00606 #define ITK_LOCATION __PRETTY_FUNCTION__
00607 #else
00608 #define ITK_LOCATION __FUNCTION__
00609 #endif
00610 #else
00611 #define ITK_LOCATION "unknown"
00612 #endif
00613
00614 #include "itkExceptionObject.h"
00615
00619 #define itkExceptionMacro(x) \
00620 { \
00621 ::itk::OStringStream message; \
00622 message << "itk::ERROR: " << this->GetNameOfClass() \
00623 << "(" << this << "): " x; \
00624 ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); \
00625 throw e_; \
00626 }
00627
00628
00629 #define itkGenericExceptionMacro(x) \
00630 { \
00631 ::itk::OStringStream message; \
00632 message << "itk::ERROR: " x; \
00633 ::itk::ExceptionObject e_(__FILE__, __LINE__, message.str().c_str(),ITK_LOCATION); \
00634 throw e_; \
00635 }
00636
00637 #ifdef ITK_LEAN_AND_MEAN
00638 #define itkGenericOutputMacro(x)
00639 #else
00640 #define itkGenericOutputMacro(x) \
00641 { if (::itk::Object::GetGlobalWarningDisplay()) \
00642 { ::itk::OStringStream itkmsg; \
00643 itkmsg << "WARNING: In " __FILE__ ", line " << __LINE__ << "\n" \
00644 x << "\n\n"; \
00645 ::itk::OutputWindowDisplayGenericOutputText(itkmsg.str().c_str());} \
00646 }
00647 #endif
00648
00649
00650
00651
00652 #define itkLogMacro( x, y) \
00653 { \
00654 if (this->GetLogger() ) \
00655 { \
00656 this->GetLogger()->Write(::itk::LoggerBase::x, y); \
00657 } \
00658 }
00659
00660
00661 #define itkLogMacroStatic( obj, x, y) \
00662 { \
00663 if (obj->GetLogger() ) \
00664 { \
00665 obj->GetLogger()->Write(::itk::LoggerBase::x, y); \
00666 } \
00667 }
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693 #if defined(ITK_LEGACY_REMOVE)
00694
00695
00696
00697
00698 # define itkLegacyMacro(method) class itkLegacyMethodRemoved
00699 #elif defined(ITK_LEGACY_SILENT) || defined(ITK_LEGACY_TEST) || defined(CSWIG)
00700
00701 # define itkLegacyMacro(method) method
00702 #else
00703
00704
00705 # if defined(__GNUC__) && !defined(__INTEL_COMPILER) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
00706 # define itkLegacyMacro(method) method __attribute__((deprecated))
00707 # elif defined(_MSC_VER) && _MSC_VER >= 1300
00708 # define itkLegacyMacro(method) __declspec(deprecated) method
00709 # else
00710 # define itkLegacyMacro(method) method
00711 # endif
00712 #endif
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726
00727 #if defined(ITK_LEGACY_REMOVE) || defined(ITK_LEGACY_SILENT)
00728 # define itkLegacyBodyMacro(method, version)
00729 # define itkLegacyReplaceBodyMacro(method, version, replace)
00730 # define itkGenericLegacyBodyMacro(method, version)
00731 # define itkGenericLegacyReplaceBodyMacro(method, version, replace)
00732 #else
00733 # define itkLegacyBodyMacro(method, version) \
00734 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
00735 # define itkLegacyReplaceBodyMacro(method, version, replace) \
00736 itkWarningMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")
00737 # define itkGenericLegacyBodyMacro(method, version) \
00738 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version.")
00739 # define itkGenericLegacyReplaceBodyMacro(method, version, replace) \
00740 itkGenericOutputMacro(#method " was deprecated for ITK " #version " and will be removed in a future version. Use " #replace " instead.")
00741 #endif
00742
00743 #if defined(__INTEL_COMPILER)
00744 # pragma warning (disable: 193)
00745 #endif
00746
00747
00748
00749
00750
00751
00752
00753
00754
00755
00756
00757
00758
00759
00760
00761
00762
00763
00764
00765
00766
00767
00768
00769
00770
00771
00772
00773
00774
00775
00776 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_NULL_STRING)
00777 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T)
00778 #else
00779 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_EMPTY_BRACKETS)
00780 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) <>
00781 #else
00782 #if defined(ITK_SUPPORTS_TEMPLATED_FRIEND_FUNCTION_WITH_TEMPLATE_ARGUMENTS)
00783 #define ITK_FRIEND_TEMPLATE_FUNCTION_ARGUMENT(T) <T>
00784 #endif
00785 #endif
00786 #endif
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 #if defined(__sgi) && defined(_COMPILER_VERSION)
00800 # define ITK_TEMPLATE_DO_NOT_INSTANTIATE 1
00801 #elif defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 700
00802 # define ITK_TEMPLATE_EXTERN 1
00803 #elif defined(__GNUC__) && __GNUC__ >= 3
00804 # define ITK_TEMPLATE_EXTERN 1
00805 #elif defined(_MSC_VER) && _MSC_VER >= 1300
00806 # define ITK_TEMPLATE_EXTERN 1
00807 #endif
00808 #if !defined(ITK_TEMPLATE_DO_NOT_INSTANTIATE)
00809 # define ITK_TEMPLATE_DO_NOT_INSTANTIATE 0
00810 #endif
00811 #if !defined(ITK_TEMPLATE_EXTERN)
00812 # define ITK_TEMPLATE_EXTERN 0
00813 #endif
00814
00815
00816
00817
00818
00819
00820
00821
00822 #define ITK_TEMPLATE_EXPORT(x) ITK_TEMPLATE_EXPORT_DELAY(x)
00823 #define ITK_TEMPLATE_EXPORT_DELAY(x) template ITK_TEMPLATE_##x;
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833 #if ITK_TEMPLATE_EXTERN
00834 # define ITK_TEMPLATE_IMPORT_DELAY(x) extern template ITK_TEMPLATE_##x;
00835 # if defined(_MSC_VER)
00836 # pragma warning (disable: 4231)
00837 # endif
00838 #elif ITK_TEMPLATE_DO_NOT_INSTANTIATE
00839 # define ITK_TEMPLATE_IMPORT_DELAY(x) \
00840 ITK_TEMPLATE_IMPORT_IMPL(do_not_instantiate ITK_TEMPLATE_##x)
00841 # define ITK_TEMPLATE_IMPORT_IMPL(x) _Pragma(#x)
00842 #endif
00843 #if defined(ITK_TEMPLATE_IMPORT_DELAY)
00844 # define ITK_TEMPLATE_IMPORT(x) ITK_TEMPLATE_IMPORT_DELAY(x)
00845 # define ITK_TEMPLATE_IMPORT_WORKS 1
00846 #else
00847 # define ITK_TEMPLATE_IMPORT(x)
00848 # define ITK_TEMPLATE_IMPORT_WORKS 0
00849 #endif
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871
00872
00873
00874
00875
00876
00877
00878
00879
00880
00881
00882
00883
00884
00885
00886
00887
00888
00889
00890
00891
00892
00893
00894
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907 #define ITK_EXPORT_TEMPLATE(EXPORT, c, x, y) \
00908 ITK_TEMPLATE_##c(ITK_TEMPLATE_EXPORT, EXPORT ITK_EMPTY, x, y)
00909 #define ITK_IMPORT_TEMPLATE(EXPORT, c, x, y) \
00910 ITK_TEMPLATE_##c(ITK_TEMPLATE_IMPORT, EXPORT ITK_EMPTY, x, y)
00911 #define ITK_EMPTY
00912
00913
00914
00915
00916
00917 #define ITK_TEMPLATE_1(x1) x1
00918 #define ITK_TEMPLATE_2(x1,x2) x1,x2
00919 #define ITK_TEMPLATE_3(x1,x2,x3) x1,x2,x3
00920 #define ITK_TEMPLATE_4(x1,x2,x3,x4) x1,x2,x3,x4
00921 #define ITK_TEMPLATE_5(x1,x2,x3,x4,x5) x1,x2,x3,x4,x5
00922 #define ITK_TEMPLATE_6(x1,x2,x3,x4,x5,x6) x1,x2,x3,x4,x5,x6
00923 #define ITK_TEMPLATE_7(x1,x2,x3,x4,x5,x6,x7) x1,x2,x3,x4,x5,x6,x7
00924 #define ITK_TEMPLATE_8(x1,x2,x3,x4,x5,x6,x7,x8) x1,x2,x3,x4,x5,x6,x7,x8
00925 #define ITK_TEMPLATE_9(x1,x2,x3,x4,x5,x6,x7,x8,x9) x1,x2,x3,x4,x5,x6,x7,x8,x9
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935 #if defined(ITK_MANUAL_INSTANTIATION)
00936 # define ITK_TEMPLATE_TXX 0
00937 #else
00938 # define ITK_TEMPLATE_TXX !(ITK_TEMPLATE_CXX || ITK_TEMPLATE_TYPE)
00939 #endif
00940
00941
00942
00943
00944
00945
00946 #if ITK_TEMPLATE_CXX
00947 # undef ITK_MANUAL_INSTANTIATION
00948 # define ITK_MANUAL_INSTANTIATION
00949 # if defined(_MSC_VER)
00950 # pragma warning (disable: 4275)
00951 # pragma warning (disable: 4661)
00952 # endif
00953 #endif
00954
00955
00956
00957
00958 #define ITK_EXPORT_ITKCommon(c, x, n) \
00959 ITK_EXPORT_TEMPLATE(ITKCommon_EXPORT, c, x, n)
00960 #define ITK_IMPORT_ITKCommon(c, x, n) \
00961 ITK_IMPORT_TEMPLATE(ITKCommon_EXPORT, c, x, n)
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973
00974
00975
00976 #if ITK_TEMPLATE_IMPORT_WORKS && defined(ITK_EXPLICIT_INSTANTIATION)
00977 # define ITK_TEMPLATE_EXPLICIT !ITK_TEMPLATE_CXX
00978 #else
00979 # define ITK_TEMPLATE_EXPLICIT 0
00980 #endif
00981
00982
00983
00984
00985
00986
00987
00988
00989 #if defined(__GNUC__)
00990 # if (((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5)) || (__GNUC__ >= 3))
00991 # define ITK_NO_RETURN \
00992 __attribute__ ((noreturn))
00993 # endif
00994 #else
00995 # define ITK_NO_RETURN
00996 #endif
00997
00998
00999 namespace itk
01000 {
01001 namespace Math
01002 {
01003 inline int RoundHalfIntegerUp(float x) { return vnl_math_rnd_halfintup(x); }
01004 inline int RoundHalfIntegerUp(double x) { return vnl_math_rnd_halfintup(x); }
01005 inline int RoundHalfIntegerToEven(float x) { return vnl_math_rnd_halfinttoeven(x); }
01006 inline int RoundHalfIntegerToEven(double x) { return vnl_math_rnd_halfinttoeven(x); }
01007 inline int Round(float x) { return RoundHalfIntegerUp(x); }
01008 inline int Round(double x) { return RoundHalfIntegerUp(x); }
01009 inline int Floor(float x) { return vnl_math_floor(x); }
01010 inline int Floor(double x) { return vnl_math_floor(x); }
01011 inline int Ceil(float x) { return vnl_math_ceil(x); }
01012 inline int Ceil(double x) { return vnl_math_ceil(x); }
01013 }
01014 }
01015
01016
01017 #ifdef ITK_USE_TEMPLATE_META_PROGRAMMING_LOOP_UNROLLING
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029 #define itkForLoopAssignmentMacro(DestinationType,SourceType,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
01030 for(unsigned int i=0;i < NumberOfIterations; ++i) \
01031 { \
01032 DestinationArray[i] = static_cast< DestinationElementType >( SourceArray[i] ); \
01033 }
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043 #define itkForLoopRoundingAndAssignmentMacro(DestinationType,Sourcrnd_halfintup,DestinationElementType,DestinationArray,SourceArray,NumberOfIterations) \
01044 for(unsigned int i=0;i < NumberOfIterations; ++i) \
01045 { \
01046 DestinationArray[i] = static_cast< DestinationElementType >( itk::Math::Round( SourceArray[i] ) ); \
01047 }
01048
01049 #endif
01050
01051
01052
01053 #ifndef NDEBUG
01054
01055 #ifdef _POSIX_SOURCE
01056 #define itkAssertInDebugOrThrowInReleaseMacro(msg) __assert_fail (msg, __FILE__, __LINE__, __ASSERT_FUNCTION);
01057 #else
01058 #define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro( << msg );
01059 #endif
01060
01061 #else
01062 #define itkAssertInDebugOrThrowInReleaseMacro(msg) itkGenericExceptionMacro( << msg);
01063 #endif
01064
01065 #define itkAssertOrThrowMacro(test, message) \
01066 if( !(test) ) \
01067 { \
01068 ::itk::OStringStream msgstr; \
01069 msgstr << message; \
01070 itkAssertInDebugOrThrowInReleaseMacro( msgstr.str().c_str() ); \
01071 }
01072
01073 #endif //end of itkMacro.h
01074