]> Creatis software - creaImageIO.git/commitdiff
Now it compiles in Linux...
authorjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 26 May 2011 12:34:21 +0000 (12:34 +0000)
committerjean-pierre roux <jean-pierre.roux@creatis.insa-lyon.fr>
Thu, 26 May 2011 12:34:21 +0000 (12:34 +0000)
src/creaImageIOWxAnySimpleDlg.cpp
src/creaImageIOWxAnySimpleDlg.h

index 593d389f3a574416f1c409c1d08f8e37780757fe..e66d2ba3cecacd8964afb4d5971028c8a0059f9c 100644 (file)
@@ -39,7 +39,7 @@ namespace creaImageIO
        }
        // Button to select file(s)
        wxButton *fileBut = new wxButton(this, -1,_T("Select a file to display"), wxPoint(10,7) );
-         Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile ); 
+       Connect( fileBut->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &WxAnySimpleDlg::OnReadFile ); 
 
        // Button to select directory
        wxButton *directoryBut = new wxButton(this, -1,_T("Select a directory to display"), wxPoint(10,40) );
@@ -53,6 +53,7 @@ namespace creaImageIO
         m_dicom = true;
         Layout(); 
     }
+
 //////////////////////////////////////////////////////////////////////
 //                                                                  //
 //////////////////////////////////////////////////////////////////////
@@ -84,13 +85,11 @@ namespace creaImageIO
 //         Close();
           EndModal( resultShowModal );
       }
-
-
         
-void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
-{
-    m_exts = i_exts;
-}
+     void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
+     {
+         m_exts = i_exts;
+     }
  /////////////////////////////////////////////////////////////////////
 //                                                                  //
 //////////////////////////////////////////////////////////////////////
@@ -124,10 +123,10 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                                break;
                            }
                        }
-                    if (!boost::filesystem::is_directory(itr->status()) && bvalid)
-                    {
-                        readImg(itr->string().c_str());
-                    }
+                       if (!boost::filesystem::is_directory(itr->status()) && bvalid)
+                       {
+                           readImg(itr->string().c_str());
+                       }
                 }
          }
          SetReturnCode( resultShowModal );
@@ -142,7 +141,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
       void WxAnySimpleDlg::OnReadGimmick(wxCommandEvent &event)
       {
           // Run Gimmick
-           WxGimmickReaderDialog dlg(0,-1, 
+         WxGimmickReaderDialog dlg(0,-1, 
                    namedescp,
                    namedb, 
                    _T("Select image(s)        - Gimmick! (c) CREATIS-LRMN 2008"),
@@ -179,7 +178,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
 
 
      
-     wxString WxAnySimpleDlg::getInfoImage()
+    wxString WxAnySimpleDlg::getInfoImage()
     {
         return infoimage;
     }
@@ -187,7 +186,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
 
       // FCY : just to check but not needed, we hardly suppose that we load only same type and dim of images
     const std::type_info & WxAnySimpleDlg::getType(const std::string &i_name)
-     {
+    {
             typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
             itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
             imageIO->SetFileName(i_name.c_str());
@@ -195,7 +194,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
             return imageIO->GetComponentTypeInfo();//AsString( imageIO->GetComponentType());
      }
 
-      const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
+     const size_t WxAnySimpleDlg::getNumberOfDimensions(const std::string &i_name)
      {
             typedef itk::ImageIOBase::IOComponentType ScalarPixelType;
             itk::ImageIOBase::Pointer imageIO =  itk::ImageIOFactory::CreateImageIO(i_name.c_str(), itk::ImageIOFactory::ReadMode);
@@ -204,8 +203,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
             return imageIO->GetNumberOfDimensions();
      }
 
-      void WxAnySimpleDlg::readImg(const std::string &i_name)
-      {
+     void WxAnySimpleDlg::readImg(const std::string &i_name)
+     {
           size_t dims = getNumberOfDimensions(i_name);
           const std::type_info  *type= &getType(i_name);
           switch(dims)
@@ -221,8 +220,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                }
-              else if (getType(i_name) ==  typeid(signed char)) 
-              {
+               else if (getType(i_name) ==  typeid(signed char)) 
+               {
                     typedef itk::Image<signed char, 3> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -230,7 +229,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->Update(); 
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
-              }
+               }
                else if (getType(i_name) ==  typeid(short))
                {
                     typedef itk::Image<short, 3> TImage;
@@ -241,8 +240,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                }
-              else if (getType(i_name) ==  typeid(unsigned short)) 
-              {
+               else if (getType(i_name) ==  typeid(unsigned short)) 
+               {
                     typedef itk::Image<unsigned short, 3> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -329,8 +328,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
                 }
-               else if (getType(i_name) ==  typeid(signed char)) 
-               {
+                else if (getType(i_name) ==  typeid(signed char)) 
+                {
                     typedef itk::Image<signed char, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -339,8 +338,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-               }
-               else    if (getType(i_name) ==  typeid(unsigned short))
+                }
+                else    if (getType(i_name) ==  typeid(unsigned short))
                 {
                     typedef itk::Image<unsigned short, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
@@ -351,8 +350,8 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
                 }
-               else if(getType(i_name) == typeid(short))
-               {
+                else if(getType(i_name) == typeid(short))
+                {
                     typedef itk::Image<short, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -375,9 +374,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-               }
-               else if (getType(i_name) ==  typeid(unsigned short)) 
-               {
+                }
+                else if (getType(i_name) ==  typeid(unsigned short)) 
+                {
                     typedef itk::Image<unsigned short, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -386,9 +385,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(unsigned int)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(unsigned int)) 
+               {
                     typedef itk::Image<unsigned int, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -397,9 +396,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(signed int)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(signed int)) 
+               {
                     typedef itk::Image<signed int, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -408,9 +407,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(unsigned long)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(unsigned long)) 
+               {
                     typedef itk::Image<unsigned long, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -419,9 +418,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(signed long)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(signed long)) 
+               {
                     typedef itk::Image<signed long, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -430,9 +429,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(float)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(float)) 
+               {
                     typedef itk::Image<float, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -441,9 +440,9 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else if (getType(i_name) ==  typeid(double)) 
-              {
+               }
+               else if (getType(i_name) ==  typeid(double)) 
+               {
                     typedef itk::Image<double, 4> TImage;
                     typedef itk::ImageFileReader<TImage> ReaderType; 
                     ReaderType::Pointer reader = ReaderType::New(); 
@@ -452,16 +451,16 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                     reader->GetOutput()->Register();
                     m_AnyImages.push_back(reader->GetOutput());
                     split4Din3Dvtk<TImage>(reader->GetOutput());
-              }
-              else
-              {
+               }
+               else
+               {
                   //????FCY, so what the type????
-              }
-              break;
+               }
+               break;
            }
            
            // Test to know if we have to add new type
-          bool btest = false;
+           bool btest = false;
            if( m_AnyDims.size() != 0)
            {
                btest = true;
@@ -469,23 +468,20 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
            else
            {
                m_AnyDims.push_back(dims);
-               m_AnyType.push_back(&getType(i_name));
+               m_AnyType.push_back((std::type_info*)&getType(i_name));  //JPR cast
            }
            if (btest)
            {
                if(m_AnyDims.front() != dims || m_AnyType.front()->before(getType(i_name)))
                {
                    m_AnyDims.push_back(dims);
-                   m_AnyType.push_back(&getType(i_name));
+                   m_AnyType.push_back((std::type_info*)&getType(i_name)); //JPR cast
                }
                else{}
            }
            else  {}
       }
 
-
-
-
       void WxAnySimpleDlg::readDicomImg(const std::vector<std::string> &i_names)
       {
           typedef itk::Image<short,3> TImage;
@@ -519,9 +515,6 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
     
       }
 
-
-
-
       template <typename TImage> 
       void WxAnySimpleDlg::split3Din3Dvtk(TImage* i_Img)
       {
@@ -540,55 +533,55 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
       template <typename TImage> 
       void WxAnySimpleDlg::split4Din3Dvtk(TImage* i_Img)
       {
-                 if(i_Img->GetImageDimension() == 4)
-                 {
-                     // size of fourth dimension 
-                     int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
-                     // Output Type
-                     typedef itk::Image<unsigned char,3> ImageOutputType;  
-                     typedef itk::ImageSeriesWriter<TImage, ImageOutputType >  SeriesWriterType;
-                     typedef itk::MetaImageIO MetaImageType;
-                     MetaImageType::Pointer metaIO;
-                     typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
+          if(i_Img->GetImageDimension() == 4)
+          {
+              // size of fourth dimension 
+              int dsize = i_Img->GetLargestPossibleRegion().GetSize(3);
+              // Output Type
+              typedef itk::Image<unsigned char,3> ImageOutputType;  
+              typedef itk::ImageSeriesWriter<TImage, ImageOutputType >  SeriesWriterType;
+              typedef itk::MetaImageIO MetaImageType;
+              MetaImageType::Pointer metaIO;
+              typename SeriesWriterType::Pointer seriesWriter = SeriesWriterType::New();
             
-                     // from JPR file to generate output files
-                     typedef itk::NumericSeriesFileNames NamesGeneratorType;
-                     NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
-                     namesGenerator->SetStartIndex(0);
-                     namesGenerator->SetEndIndex(dsize-1); 
-                     namesGenerator->SetIncrementIndex(1);
-                     std::string format = m_dir;
-                     format += "/image%03d.mhd";
-                     namesGenerator->SetSeriesFormat( format.c_str() );
-                    
-                     const std::vector<std::string> names = namesGenerator->GetFileNames();
-                     seriesWriter->SetFileNames( names );
-                     seriesWriter->SetInput(i_Img);
-                       seriesWriter->SetImageIO(metaIO);
-                     try
-                     {
-                        seriesWriter->Update();
-                        vtkMetaImageReader *vReader = vtkMetaImageReader::New();
-                        std::vector<std::string>::const_iterator it = names.begin();
-                        for( ;it !=  names.end(); ++it)
-                        {
-                            vReader->SetFileName((*it).c_str());
-                            vReader->Update();
-                            m_Vresults.push_back(vReader->GetOutput());
-                            
-                        }
-                     }
-                     catch( itk::ExceptionObject & excp )
-                     {
-                        std::cerr << "Exception thrown while writing the series " << std::endl;
-                        std::cerr << excp << std::endl;
-                        //return EXIT_FAILURE;
-                     }
+              // from JPR file to generate output files
+              typedef itk::NumericSeriesFileNames NamesGeneratorType;
+              NamesGeneratorType::Pointer namesGenerator = NamesGeneratorType::New();
+              namesGenerator->SetStartIndex(0);
+              namesGenerator->SetEndIndex(dsize-1); 
+              namesGenerator->SetIncrementIndex(1);
+              std::string format = m_dir;
+              format += "/image%03d.mhd";
+              namesGenerator->SetSeriesFormat( format.c_str() );
+             
+              const std::vector<std::string> names = namesGenerator->GetFileNames();
+              seriesWriter->SetFileNames( names );
+              seriesWriter->SetInput(i_Img);
+              seriesWriter->SetImageIO(metaIO);
+              try
+              {
+                 seriesWriter->Update();
+                 vtkMetaImageReader *vReader = vtkMetaImageReader::New();
+                 std::vector<std::string>::const_iterator it = names.begin();
+                 for( ;it !=  names.end(); ++it)
+                 {
+                     vReader->SetFileName((*it).c_str());
+                     vReader->Update();
+                     m_Vresults.push_back(vReader->GetOutput());
+                     
                  }
+              }
+              catch( itk::ExceptionObject & excp )
+              {
+                 std::cerr << "Exception thrown while writing the series " << std::endl;
+                 std::cerr << excp << std::endl;
+                 //return EXIT_FAILURE;
+              }
+          }
       }
 
-       bool WxAnySimpleDlg::AllSameType()
-       {
+      bool WxAnySimpleDlg::AllSameType()
+      {
            if(m_AnyType.size() == 1)
            {
                return true;
@@ -598,7 +591,7 @@ void WxAnySimpleDlg::setExts(std::vector<std::string> i_exts)
                return false;
            }
 
-       }
+      }
 
- }// namespace end
+ } // namespace end
 
index 9bbde5a0d38c4943edbdd285c023e0a73db0fefc..34120242304f7ac5c03ae765b79e7330acf44600 100644 (file)
@@ -7,8 +7,8 @@
 namespace creaImageIO
 {
  /**
  * \ingroup View
  */
+ * \ingroup View
+ */
 
     /// Simple Wxwidgets interface to select file(s) or directory or from creaImageIO database to display
 //EED    class  __declspec(dllexport) WxAnySimpleDlg : public wxDialog
@@ -19,8 +19,8 @@ namespace creaImageIO
            WxAnySimpleDlg( wxWindow *parent,  
                wxString i_title =_T(""),
                const std::string i_namedescp = "localdatabase_Descriptor.dscp",   
-               const std::string i_namedb   = "Local Database"     
-            );
+               const std::string i_namedb    = "Local Database"
+           );
 
            ~WxAnySimpleDlg(){};
 
@@ -43,13 +43,14 @@ namespace creaImageIO
            std::vector <boost::any>& getImagesSelected(){ return m_AnyImages;}
         
            // return the size of readed images
-           //strange compile error // JPR
-           std::vector<const size_t> getDims(){ return m_AnyDims;}
+           std::vector</*const*/ size_t> getDims(){ return m_AnyDims;} // comment out const // JPR
 
            // return the type of readed images
-           std::vector<const std::type_info *> getTypes(){ return m_AnyType;}
+           std::vector</*const */std::type_info *> getTypes(){ return m_AnyType;} // comment out const // JPR
 
            // get an Image on wanted type
+          /*
+          // strange compile error, commented out on Fred's advice // JPR
            template <typename TImage> 
            typename TImage::Pointer getImage(boost::any i_AnyImage)
            {
@@ -58,6 +59,7 @@ namespace creaImageIO
               img = boost::any_cast< ImageOut::Pointer>(i_AnyImage);
               return img;
            }
+           */
 
          // get the images on itk type defined by user
           template <typename TImage> 
@@ -75,9 +77,9 @@ namespace creaImageIO
     private:
 
         // strange compile error with gcc 4.5.1-4 //JPR        
-        std::vector<const size_t> m_AnyDims;
-        std::vector<const std::type_info *> m_AnyType;
-        std::vector<boost::any> m_AnyImages;
+        std::vector</*const*/ size_t>           m_AnyDims;   //comment out const JPR
+        std::vector</*const*/ std::type_info *> m_AnyType;   //comment out const JPR
+        std::vector<boost::any>                 m_AnyImages; //comment out const JPR
         std::vector<std::string> m_exts;
         std::string namedescp; 
         std::string namedb;