]> Creatis software - creaImageIO.git/commitdiff
#3123creaImageIO Bug New Normal - branch changestoITK3and4 changestoITK3and4
authorEduardo DAVILA <davila@localhost.localdomain>
Tue, 5 Sep 2017 11:57:18 +0000 (13:57 +0200)
committerEduardo DAVILA <davila@localhost.localdomain>
Tue, 5 Sep 2017 11:57:18 +0000 (13:57 +0200)
bbtk/src/bbcreaImageIOItkImagesChooserDialogBox.cxx
src/creaImageIOWxAnySimpleDlg.cpp

index 434b71972c177a65d4b494bac8ad207febb88de3..e0c2a1ed29402d0924a5aa4bde2a34aaa86c874b 100644 (file)
@@ -119,14 +119,10 @@ template <typename  ty, size_t di>
 void ItkImagesChooserDialogBox::Export()
 {
        typedef itk::Image<ty,di> TImage;
-
-printf("EED ItkImagesChooserDialogBox::Export Start \n");
        if (dlg->getImagesSelected().size() == 1)
        { 
-printf("EED ItkImagesChooserDialogBox::Export 1\n");
                bbSetOutputOut( dlg->getTemplatedImagesSelected<TImage>().front().GetPointer() ); 
        } else if (dlg->getImagesSelected().size() > 1){ 
-printf("EED ItkImagesChooserDialogBox::Export 2\n");
                OutputImagesITKType outVect;
                typename  std::vector<typename TImage::Pointer> tempImgs= dlg->getTemplatedImagesSelected<TImage>();
                typename std::vector<typename TImage::Pointer>::iterator it = tempImgs.begin();
@@ -136,25 +132,14 @@ printf("EED ItkImagesChooserDialogBox::Export 2\n");
                } // for
                bbSetOutputOutIImages( outVect); 
 
-//EED creater one 3D image from 2D list
-//             const unsigned int Dimension = 3;
-//             typedef itk::RGBPixel< unsigned char > RGBPixelType;
-//             typedef itk::Image< RGBPixelType, Dimension > RGBImageType;
-//             typedef itk::ImportImageFilter< RGBPixelType, Dimension > ImportFilterType;
-
-//             typedef itk::RGBPixel< ty > RGBPixelType;
                typedef  ty RGBPixelType;
                typedef itk::ImportImageFilter< ty , di > ImportFilterType;
-     typename ImportFilterType::Pointer importFilter = ImportFilterType::New();
-
+               typename ImportFilterType::Pointer importFilter = ImportFilterType::New();
 
                typename TImage::SizeType imsize;
-//             imsize[0] = img.width();
-//             imsize[1] = img.height();
                imsize[0] = tempImgs[0].GetPointer()->GetLargestPossibleRegion().GetSize()[0];
                imsize[1] = tempImgs[0].GetPointer()->GetLargestPossibleRegion().GetSize()[1];
                imsize[2] = tempImgs.size();
-printf("EED ItkImagesChooserDialogBox::Export 2.10\n");
 
                typename ImportFilterType::IndexType start;
                start.Fill( 0 );
@@ -163,65 +148,42 @@ printf("EED ItkImagesChooserDialogBox::Export 2.10\n");
                region.SetSize( imsize );
                importFilter->SetRegion( region );
 
-//             const itk::SpacePrecisionType origin[ di ] = { 0.0, 0.0, 0.0 };
                const itk::SpacePrecisionType origin[ 3 ] = { 0.0, 0.0, 0.0 };
                importFilter->SetOrigin( origin );
 
-//             const itk::SpacePrecisionType spacing[ di ] = { 1.0, 1.0, 1.0 };
                const itk::SpacePrecisionType spacing[ 3 ] = { 1.0, 1.0, 1.0 };
                importFilter->SetSpacing( spacing );
-               const unsigned long int numberOfPixels2D = imsize[0]*imsize[1];
-               const unsigned long int numberOfPixels3D = imsize[0]*imsize[1]*imsize[2];
+               const unsigned long int numberOfPixels2D                = imsize[0]*imsize[1];
+               const unsigned long int numberOfPixels2DInBytes = imsize[0]*imsize[1]*sizeof(ty);
+               const unsigned long int numberOfPixels3D                = imsize[0]*imsize[1]*imsize[2]*sizeof(ty);
 
-               RGBPixelType * localBuffer      = new RGBPixelType[ numberOfPixels3D ];
+               RGBPixelType * localBuffer              = new RGBPixelType[ numberOfPixels3D ];
                RGBPixelType * tmpLocalBuffer   = localBuffer;
-printf("EED ItkImagesChooserDialogBox::Export 2.20\n");
 
                it = tempImgs.begin();
                for(;it != tempImgs.end(); ++it)
                {               
-printf("EED ItkImagesChooserDialogBox::Export 2.30\n");
-                       memcpy(tmpLocalBuffer, (*it).GetPointer()->GetBufferPointer(), numberOfPixels2D);
+                       memcpy(tmpLocalBuffer, (*it).GetPointer()->GetBufferPointer(), numberOfPixels2DInBytes);
                        tmpLocalBuffer = tmpLocalBuffer + numberOfPixels2D;
                } // for
 
                const bool importImageFilterWillOwnTheBuffer = true;
                importFilter->SetImportPointer( localBuffer , numberOfPixels3D , importImageFilterWillOwnTheBuffer );
-importFilter->Update();
-importFilter->Register();
-printf("EED ItkImagesChooserDialogBox::Export 2.40\n");
-
-//         bbSetOutputOut( (*tempImgs.begin()).GetPointer() ); 
-//         bbSetOutputOut( importFilter->GetOutput().unsafe_get<TImage*>() ); 
+               importFilter->Update();
+               importFilter->Register();
            bbSetOutputOut( importFilter->GetOutput() ); 
-printf("EED ItkImagesChooserDialogBox::Export 2.50\n");
 
    } else {
-printf("EED ItkImagesChooserDialogBox::Export 3\n");
       // warning: passing NULL to non-pointer 
       //bbSetOutputOut( NULL);
       bbSetOutputOut(0); // JPR
    }
-        // FCY To test the Output
-         //typedef itk::Image <short, 3> ImageType;
-        //typedef itk::ImageFileReader< ImageType > itkReaderType;
-     //  typename itkReaderType::Pointer reader = itkReaderType::New();
-     //
-     //  reader->SetFileName("d:\test.hdr");
-     //   reader->Update(); 
-        //reader->GetOutput()->Register();
-     //  this->bbSetOutputOut(reader->GetOutput());
-
-printf("EED ItkImagesChooserDialogBox::Export End \n");
-
 }
 
 
 template <class TImage>
 void ItkImagesChooserDialogBox::ExportVTK()
 {
-printf("EED ItkImagesChooserDialogBox::ExportVTK Start \n");
-
        // BBTK can support only a vector with same dimensions image.
         if (dlg->getDims().front() < 4)
         { 
@@ -239,7 +201,6 @@ printf("EED ItkImagesChooserDialogBox::ExportVTK Start \n");
          } else {
                  // NOT IMPLEMENTED YET FOR DIMENSIONS > 4     
         } // if dlg
-printf("EED ItkImagesChooserDialogBox::ExportVTK End \n");
 }
 
 //===== 
index 11d5fa92d60a79d6b4e5436c66ada2cd8deaeaa6..a8db5f73ed26584d538de30ea503e6ed0f2b050f 100644 (file)
@@ -132,7 +132,6 @@ namespace creaImageIO
 //////////////////////////////////////////////////////////////////////
       void WxAnySimpleDlg::OnReadDirectory(wxCommandEvent &event)
       {
-printf("EED WxAnySimpleDlg::OnReadDirectory Start\n");
          int resultShowModal;
          bool bvalid = false;
          long style = wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST;
@@ -142,7 +141,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory Start\n");
          if ( resultShowModal==wxID_OK )
          {  
             std::string path = crea::wx2std(dirDlg->GetPath());
-printf("EED WxAnySimpleDlg::OnReadDirectory path %s\n", path.c_str() );
 
 /*
             typedef boost::filesystem::directory_iterator dir_it;
@@ -182,8 +180,7 @@ printf("EED WxAnySimpleDlg::OnReadDirectory  Each file %s \n", itr->path().strin
                                for (vec::const_iterator it (v.begin()); it != v.end(); ++it)
                                {
                            readImg( it->string().c_str() );
-                                 cout << "   " << *it << '\n';
-                               }
+                               } // for
 
 
 
@@ -192,7 +189,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory  Each file %s \n", itr->path().strin
          SetReturnCode( resultShowModal );
 //         Close();
          EndModal( resultShowModal );
-printf("EED WxAnySimpleDlg::OnReadDirectory End\n");
 
       }
 
@@ -270,8 +266,6 @@ printf("EED WxAnySimpleDlg::OnReadDirectory End\n");
      {
           size_t dims = getNumberOfDimensions(i_name);
 
-printf("EED WxAnySimpleDlg::readImg dims=%d \n",dims);
-
           //const std::type_info  *type= &getType(i_name);
           switch(dims)
           {