]> Creatis software - bbtk.git/commitdiff
#3480 Bug typeid in Macos
authorEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 16 Dec 2021 16:51:33 +0000 (17:51 +0100)
committerEduardo DAVILA <davila@creatis.insa-lyon.fr>
Thu, 16 Dec 2021 16:51:33 +0000 (17:51 +0100)
kernel/src/bbtkAny.h
packages/itk/src/bbitkImage.h
packages/itk/src/bbitkImageProperties.cxx
packages/itk/src/bbitkResampleImageFilter.h
packages/itkvtk/src/bbitkvtkvtkImageData2itkImage.cxx

index 74efb3ecbf3028bb088290f1837ab9f91b600914..71edc872f423209239dde51d298720b0329c72b0 100644 (file)
@@ -344,9 +344,18 @@ namespace bbtk
                         <<"> with content : "
                         <<HumanTypeName(type())<<std::endl);
 
-      if ( type() == typeid(ValueType) )
-       return static_cast< anyholder<ValueType> *>(content)->held;
-
+        printf("EED bbtkAny get()   self=%s \n" , HumanTypeName<self >().c_str() );
+        printf("EED bbtkAny get()   ValueType=%s \n" , bbtk::HumanTypeName<ValueType>().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) )
+        {
+            return static_cast< anyholder<ValueType> *>(content)->held;
+        }
+        
       bbtkError(HumanTypeName<self >()
                <<" get with type <"
                <<bbtk::HumanTypeName<ValueType>()
index 9f74cec6f3aa7bdc203351eb5837c1f17c8086de..8cc1a9482e1723eac5d0b809a447610af7ced4b0 100644 (file)
@@ -65,15 +65,22 @@ namespace bbitk
     BBTK_TYPEDEF_ITK_IMAGE(uint32_t,DIM);      \
     BBTK_TYPEDEF_ITK_IMAGE(float,DIM);         \
     BBTK_TYPEDEF_ITK_IMAGE(double,DIM)
-  
   BBTK_TYPEDEF_ITK_IMAGES_DIM(2);
   BBTK_TYPEDEF_ITK_IMAGES_DIM(3);
   BBTK_TYPEDEF_ITK_IMAGES_DIM(4);
   //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 (false) {}
+#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())<<">"); }
 
@@ -82,14 +89,19 @@ namespace bbitk
   /// Generic macro which calls a TEMPLATE_FUNCTION instanciated 
   /// on TEMPLATE_TYPE iff TYPE_INFO == typeid(TEST_TYPE).
   /// This macro must be used (maybe several times) between a pair of BEGIN_TEMPLATE_SWITCH and END_TEMPLATE_SWITCH macros
-#define TEMPLATE_SWITCH(TYPE_INFO,TEST_TYPE,TEMPLATE_FUNCTION,TEMPLATE_TYPE)    \
-  else if (TYPE_INFO == typeid(bbitk::TEST_TYPE))                               \
+
+
+// 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<bbitk::TEMPLATE_TYPE>(); }
 
 
 // DIMENSION 2
 #ifdef BBTK_ITK_IMAGE_DIM_2
-#  ifdef BBTK_ITK_IMAGE_TYPE_int8_t 
+#  ifdef BBTK_ITK_IMAGE_TYPE_int8_t
 #    define BBTK_SWITCH_ITK_IMAGE_int8_t_2(TYPE_INFO,FUN,CONST)                        \
   TEMPLATE_SWITCH(TYPE_INFO,Image_int8_t_2_##CONST##ptr,FUN,Image_int8_t_2)
 #  else
@@ -113,7 +125,7 @@ namespace bbitk
 #  else
 #    define BBTK_SWITCH_ITK_IMAGE_uint8_t_2(TYPE_INFO,FUN,CONST)
 #  endif
-#  ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+#  ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
 #    define BBTK_SWITCH_ITK_IMAGE_uint16_t_2(TYPE_INFO,FUN,CONST)               \
   TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_2_##CONST##ptr,FUN,Image_uint16_t_2)
 #  else
@@ -148,7 +160,6 @@ namespace bbitk
 #  define BBTK_SWITCH_ITK_IMAGE_double_2(TYPE_INFO,FUN,CONST)
 #endif
 
-
 // DIMENSION 3
 #ifdef BBTK_ITK_IMAGE_DIM_3
 #  ifdef BBTK_ITK_IMAGE_TYPE_int8_t 
@@ -175,7 +186,7 @@ namespace bbitk
 #  else
 #    define BBTK_SWITCH_ITK_IMAGE_uint8_t_3(TYPE_INFO,FUN,CONST)
 #  endif
-#  ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+#  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_##CONST##ptr,FUN,Image_uint16_t_3)
 #  else
@@ -211,6 +222,71 @@ namespace bbitk
 #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 
@@ -237,7 +313,7 @@ namespace bbitk
 #  else
 #    define BBTK_SWITCH_ITK_IMAGE_uint8_t_4(TYPE_INFO,FUN,CONST)
 #  endif
-#  ifdef BBTK_ITK_IMAGE_TYPE_int16_t
+#  ifdef BBTK_ITK_IMAGE_TYPE_uint16_t
 #    define BBTK_SWITCH_ITK_IMAGE_uint16_t_4(TYPE_INFO,FUN,CONST)              \
   TEMPLATE_SWITCH(TYPE_INFO,Image_uint16_t_4_##CONST##ptr,FUN,Image_uint16_t_4)
 #  else
index 7e5f47dbd62272fd195bd9c26da125fb560b9abe..17b07cfc4ae520647d3d8b5dee96644c9fe2ee06 100644 (file)
@@ -68,7 +68,9 @@ 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");
   }
 
   /** 
@@ -77,18 +79,25 @@ namespace bbitk
   template<class itkImageType>
   void ImageProperties::DoIt()
   {
+      printf("EED <template>ImageProperties::DoIt Start \n");
     bbtkDebugMessageInc("Core",9,"bbitk::ImageProperties::DoIt<"
                        <<bbtk::TypeName<itkImageType>()
                        <<">()"<<std::endl);
 
     itkImageType* im = bbGetInputIn().get<itkImageType*>();
+      
+      printf("EED <template>ImageProperties::DoIt 1 \n");
+
     unsigned int dim = im->GetImageDimension();
 
+      
     bbSetOutputTypeName(bbtk::TypeName<typename itkImageType::PixelType>());
     bbSetOutputDimension(dim);
     const typename itkImageType::RegionType& r =im->GetLargestPossibleRegion();
     bbSetOutputLargestPossibleRegion(r);
 
+      printf("EED <template>ImageProperties::DoIt 2 \n");
+
     const typename itkImageType::IndexType& ind = r.GetIndex();
     std::vector<int> vind;
     for (unsigned int i=0;i<dim;++i) 
@@ -99,7 +108,9 @@ namespace bbitk
     std::vector<int> vsz;
     for (unsigned int i=0;i<dim;++i) 
        vsz.push_back(sz[i]);
-    
+
+      printf("EED <template>ImageProperties::DoIt 3 \n");
+
   // brute hack to avoid failure of most black boxes that expects 3D images. // JPR
    if (dim==2)
         vsz.push_back(1);
@@ -115,6 +126,7 @@ namespace bbitk
        vog.push_back(1.0);
   
     bbSetOutputOrigin(vog);
+      printf("EED <template>ImageProperties::DoIt 4 \n");
 
     typename itkImageType::SpacingType sp = im->GetSpacing();
     std::vector<double> vsp;
@@ -137,10 +149,15 @@ namespace bbitk
          vminmax.push_back( (float) (minMaxCalculator->GetMinimum()) );
          vminmax.push_back( (float) (minMaxCalculator->GetMaximum()) );          
          bbSetOutputMinMax(vminmax);
-         
+      
+      printf("EED <template>ImageProperties::DoIt 5 \n");
+
+      
     bbtkDebugDecTab("Core",9);
+      printf("EED <template>ImageProperties::DoIt End \n");
   }
-}
-// eo namespace bbtk
+
+
+} // eo namespace bbtk
 
 #endif
index da653e691025635a64438390c83ad3f1a4404e86..c00bdda678f1f2aae9d22b959189f7e8cde0640b 100644 (file)
@@ -90,8 +90,10 @@ namespace bbitk
  //===================================================
    void ResampleImageFilter::ProcessSwitch()
   {
+       printf("EED ResampleImageFilter::ProcessSwitch Start \n");
     bbtk::TypeInfo t = bbGetInputIn().type();
     BBTK_TEMPLATE_ITK_IMAGE_SWITCH(t, this->Process);
+       printf("EED ResampleImageFilter::ProcessSwitch End \n");
   }
  //===================================================
  
@@ -99,18 +101,24 @@ namespace bbitk
    template <class T> 
   void ResampleImageFilter::Process()
   {
+      printf("EED ResampleImageFilter::Process Start \n");
     bbtkDebugMessageInc("Core",9,
                        "bbitk::ResampleImageFilter::Process<"
                        <<bbtk::TypeName<T>()<<">()"<<std::endl);
  
     typedef T ImageType;
+      printf("EED ResampleImageFilter::Process 1 \n");
     typedef itk::ResampleImageFilter<ImageType,ImageType> FilterType;
+      printf("EED ResampleImageFilter::Process 2 \n");
     typename FilterType::Pointer filter = FilterType::New();
     const unsigned int Dimension = ImageType::ImageDimension;
 
     // Input
+      printf("EED ResampleImageFilter::Process 3 \n");
     T* in = this->bbGetInputIn().get<T*>();
+      printf("EED ResampleImageFilter::Process 4 \n");
     filter->SetInput( in );
+      printf("EED ResampleImageFilter::Process 5 \n");
 
     // Size, Spacing, Origin and DefaultPixelVal
     typename ImageType::SizeType size;
@@ -181,6 +189,9 @@ namespace bbitk
     mOutput = filter->GetOutput();
 
     bbtkDebugDecTab("Core",9);
+      
+      printf("EED ResampleImageFilter::Process End \n");
+
   }
    //===================================================
  
index 565e0274a2f04b56d08ebb8d36f2ab2b3ee9e3ce..f12b52566de25d03712a9f53dcc800412f22b9c4 100644 (file)
@@ -84,6 +84,8 @@ namespace bbitkvtk
    template<class T, unsigned int D>
    void vtkImageData2itkImage::Convert()
    {
+       printf("vtkImageData2itkImage::Convert A \n");
+
     bbtkDebugMessage("process",5,"==> ["<<bbGetFullName()<<"] : Convert<"
                        <<bbtk::TypeName<T>()<<","<<D
                        <<">()"<<std::endl);
@@ -93,9 +95,12 @@ namespace bbitkvtk
     typedef itk::VTKImageToImageFilter< itkImageType > VtkToItkConnection;
     typename VtkToItkConnection::Pointer conv;
 
+       printf("vtkImageData2itkImage::Convert B \n");
+
     // No converter yet : create it and set its input
     if (!mConverter) 
       {
+          printf("vtkImageData2itkImage::Convert C \n");
        bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : No converter yet : creating it"<<std::endl);
        conv = VtkToItkConnection::New();
        mConverter = conv;
@@ -110,7 +115,8 @@ namespace bbitkvtk
                           ((itk::ProcessObject*)mConverter);
        if (!conv) 
          {
-           bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : Converter of wrong input type : reacreating it "<<std::endl);
+          printf("vtkImageData2itkImage::Convert 1 \n");
+          bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : Converter of wrong input type : reacreating it "<<std::endl);
 
            mConverter->UnRegister();
            conv = VtkToItkConnection::New();
@@ -121,13 +127,15 @@ namespace bbitkvtk
        // set new input
        else if ( this->bbGetInputIn() != conv->GetExporter()->GetInput())
          {
+          printf("vtkImageData2itkImage::Convert 2 \n");
            bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : Converter input changed : resetting it"<<std::endl);
 
            conv->SetInput( this->bbGetInputIn() );
          }
        else 
          {
-           bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : Nothing changed"<<std::endl);     
+          printf("vtkImageData2itkImage::Convert 3 \n");
+           bbtkDebugMessage("process",5,"    ["<<bbGetFullName()<<"] : Nothing changed"<<std::endl);
          }
       }
     try