From dd7b3bb19f17388ddef4f7e0374fc76f625a2639 Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Tue, 21 Dec 2021 17:14:03 +0100 Subject: [PATCH] 3480 Bug typeid in Macos --- kernel/src/bbtkAny.h | 38 +++++--- packages/itk/src/bbitkImage.h | 89 +++---------------- packages/itk/src/bbitkImageProperties.cxx | 21 +---- packages/itk/src/bbitkResampleImageFilter.h | 11 --- .../src/bbitkvtkitkImage2vtkImageData.cxx | 24 ++++- ...tkvtkitkImageVector2vtkImageDataVector.cxx | 27 +++++- .../src/bbitkvtkvtkImageData2itkImage.cxx | 8 -- 7 files changed, 85 insertions(+), 133 deletions(-) diff --git a/kernel/src/bbtkAny.h b/kernel/src/bbtkAny.h index 71edc87..9f161c9 100644 --- a/kernel/src/bbtkAny.h +++ b/kernel/src/bbtkAny.h @@ -311,7 +311,13 @@ namespace bbtk template inline bool contains() { - return ( type() == typeid(Type) ); +//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared in different libraries +// ex: itk <-> vtk templates convertion +#if defined(MACOSX) + if ( strcmp( type().name() , typeid(Type).name() ) ==0 ) return true; else return false; +#else + return ( type() == typeid(Type) ); +#endif } /// Returns true iff the contained type is a pointer @@ -323,7 +329,14 @@ namespace bbtk /// Returns true iff the contained type is t inline bool contains(TypeInfo t) { - return ( (bool)((type() == t)!=0) ); +//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared in different libraries +// ex: itk <-> vtk templates convertion +#if defined(MACOSX) + bool compTmp = (strcmp( type().name() , t.name() ) == 0); + return ( compTmp!=0 ); +#else + return ( (bool)((type() == t)!=0) ); +#endif } /// Returns true iff any of type ValueType can be held @@ -344,14 +357,13 @@ namespace bbtk <<"> with content : " <().c_str() ); - printf("EED bbtkAny get() ValueType=%s \n" , bbtk::HumanTypeName().c_str() ); - printf("EED bbtkAny get() Type=%s \n" , bbtk::HumanTypeName<>(type()).c_str() ); - printf("EED bbtkAny get() type name=(-%s-) \n" , type().name() ); - printf("EED bbtkAny get() ValueType name=(-%s-) \n" , typeid(ValueType).name() ); -// 2021-12-15 - if ( strcmp( type().name() , typeid(ValueType).name() ) ==0 ) -// if ( type() == typeid(ValueType) ) +//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared in different libraries +// ex: itk <-> vtk templates convertion +#if defined(MACOSX) + if ( strcmp( type().name() , typeid(ValueType).name() ) ==0 ) +#else + if ( type() == typeid(ValueType) ) +#endif { return static_cast< anyholder *>(content)->held; } @@ -366,7 +378,13 @@ namespace bbtk template inline const ValueType* getP() const { +//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared in different libraries +// ex: itk <-> vtk templates convertion +#if defined(MACOSX) + if ( strcmp( type().name() , typeid(ValueType).name() ) ==0 ) +#else if ( type() == typeid(ValueType) ) +#endif return &static_cast< anyholder *>(content)->held; bbtkError(HumanTypeName() diff --git a/packages/itk/src/bbitkImage.h b/packages/itk/src/bbitkImage.h index 8cc1a94..cc754d5 100644 --- a/packages/itk/src/bbitkImage.h +++ b/packages/itk/src/bbitkImage.h @@ -72,14 +72,8 @@ namespace bbitk //BBTK_TYPEDEF_ITK_IMAGES_DIM(5) -// printf("EEDitk TYPE_INFO=%s %s\n", TYPE_INFO.name(), typeid(bbitk::Image_int8_t_3_##CONST##ptr).name() ); \ #define BBTK_BEGIN_TEMPLATE_SWITCH(TYPE_INFO) \ -if ( TYPE_INFO == typeid(bbitk::Image_uint16_t_3_ptr) ) { printf ("Yes\n"); }else{ printf ("No\n"); } \ -if ( strcmp(TYPE_INFO.name() , typeid(bbitk::Image_uint16_t_3_ptr).name() ) ==0 ) { printf ("Yes\n"); }else{ printf ("No\n"); } \ - printf("EEDitk TYPE_INFO=<%s> <%s> <%s>\n", TYPE_INFO.name(), bbtk::demangle_type_name(typeid(bbitk::Image_uint8_t_3_ptr).name()).c_str() , typeid(bbitk::Image_uint8_t_3_ptr).name() ); \ - printf("EEDitk TYPE_INFO=<%s> <%s> <%s>\n", TYPE_INFO.name(), bbtk::demangle_type_name(typeid(bbitk::Image_uint16_t_3_ptr).name()).c_str() , typeid(bbitk::Image_uint16_t_3_ptr).name() ); \ - printf("EEDitk TYPE_INFO=<%s> <%s> <%s>\n", TYPE_INFO.name(), bbtk::demangle_type_name(typeid(bbitk::Image_uint32_t_3_ptr).name()).c_str() , typeid(bbitk::Image_uint32_t_3_ptr).name() ); \ if (false) {} #define BBTK_END_TEMPLATE_SWITCH(TYPE_INFO) else { bbtkError("bbtk was not built for itk images of type <"<< bbtk::demangle_type_name(TYPE_INFO.name())<<">"); } @@ -91,12 +85,17 @@ if (false) {} /// This macro must be used (maybe several times) between a pair of BEGIN_TEMPLATE_SWITCH and END_TEMPLATE_SWITCH macros -// 2021-12-15 -// else if (TYPE_INFO == typeid(bbitk::TEST_TYPE)) \ - -#define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE) \ - else if ( strcmp(TYPE_INFO.name() , typeid(bbitk::TEST_TYPE).name() ) ==0 ) \ - { TEMPLATE_FUNCTION(); } +//EED 2021-12-15 typeid comparation is not working in MacOs for objects declared in different libraries +// ex: itk <-> vtk templates convertion +#if defined(MACOSX) + #define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE) \ + else if ( strcmp(TYPE_INFO.name() , typeid(bbitk::TEST_TYPE).name() ) ==0 ) \ + { TEMPLATE_FUNCTION(); } +#else + #define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE) \ + else if (TYPE_INFO == typeid(bbitk::TEST_TYPE)) \ + { TEMPLATE_FUNCTION(); } +#endif // DIMENSION 2 @@ -221,72 +220,6 @@ if (false) {} # define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) #endif - -/* EED -// DIMENSION 3 -#ifdef BBTK_ITK_IMAGE_DIM_3 -# ifdef BBTK_ITK_IMAGE_TYPE_int8_t -# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_3_ptr,FUN,Image_int8_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_int16_t -# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_int16_t_3_ptr,FUN,Image_int16_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_int32_t -# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_int32_t_3_ptr,FUN,Image_int32_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_uint8_t -# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_uint8_t_3_ptr,FUN,Image_uint8_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_uint16_t -# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_3_,FUN,Image_uint16_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_uint32_t -# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_uint32_t_3_ptr,FUN,Image_uint32_t_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_float -# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_float_3_ptr,FUN,Image_float_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST) -# endif -# ifdef BBTK_ITK_IMAGE_TYPE_double -# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) \ - TEMPLATE_SWITCH(TYPE_INFO,Image_double_3_ptr,FUN,Image_double_3) -# else -# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) -# endif -#else -# define BBTK_SWITCH_ITK_IMAGE_int8_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_int16_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_int32_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_uint16_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_uint32_t_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_float_3(TYPE_INFO,FUN,CONST) -# define BBTK_SWITCH_ITK_IMAGE_double_3(TYPE_INFO,FUN,CONST) -#endif -*/ - - - // DIMENSION 4 #ifdef BBTK_ITK_IMAGE_DIM_4 # ifdef BBTK_ITK_IMAGE_TYPE_int8_t diff --git a/packages/itk/src/bbitkImageProperties.cxx b/packages/itk/src/bbitkImageProperties.cxx index 17b07cf..d2f8890 100644 --- a/packages/itk/src/bbitkImageProperties.cxx +++ b/packages/itk/src/bbitkImageProperties.cxx @@ -68,9 +68,7 @@ namespace bbitk void ImageProperties::DoIt() { - printf("EED ImageProperties::DoIt Start \n"); BBTK_TEMPLATE_ITK_IMAGE_SWITCH(bbGetInputIn().type(),DoIt); - printf("EED ImageProperties::DoIt End \n"); } /** @@ -79,25 +77,17 @@ namespace bbitk template void ImageProperties::DoIt() { - printf("EED