]> Creatis software - creaImageIO.git/commitdiff
2084 creaImageIO Bug New Normal ChooseerDialogBox First button is not working for...
authorEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 25 Jul 2013 14:23:17 +0000 (16:23 +0200)
committerEduardo DAVILA <eduardo.davila@creatis.insa-lyon.fr>
Thu, 25 Jul 2013 14:23:17 +0000 (16:23 +0200)
bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml

index 5c753905a3a44195ae37c4f18a2fe032d3afcc4e..9c074739974905f80c56bc69b31866d7d930d969 100644 (file)
                  if(dlg.getImagesSelected().size() ==1)
                  {
                        bbSetOutputOut( dlg.getImagesSelected()[0] );  
-                 }
-                 else
-                 {
+                 } else {
+printf("EED  creaImageIOWxSimpleDlg 1 \n");
                          // FCY: it will be a big problem if we have several kind of data in the same folder.
-                         vtkImageData *out;
                          // creation of a huge vtkImageData!!!!
                          vtkImageData* first = dlg.getImagesSelected()[0];
-                         out  = vtkImageData::New();
-                         out->SetScalarType(first->GetScalarType());
-                         out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
-                         int ext[6];
-                         first->GetWholeExtent(ext); 
-                         if(ext[5] == 0)
-                         {
-                           ext[5] = dlg.getImagesSelected().size()-1;
-                         }
-                         else
-                         {
-                               ext[5] = ext[5] * dlg.getImagesSelected().size()-1; // to deal with multiframes 
-                         }
-                         out->SetExtent(ext);
                          int dim[3];
-                         double spac[3];
                          first->GetDimensions(dim);
-                         first->GetSpacing(spac);
-                         if (spac[0]==spac[1])
-                          {
-                               spac[2]=spac[0];  
-                         }
-                         out->SetSpacing(spac);
-                         out->SetDimensions(dim[0], dim[1], dlg.getImagesSelected().size() );
-                         out->AllocateScalars();
-                         out->Update();
-                         unsigned long imsize = dim[0] * dim[1];
-                         imsize = imsize * dim[2];  // deal with multiframes here
-                         // differents formats char , short, etc...
-                         // differents components 1..3  ex. jpg ->RGB 3
-                         imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
-
-                       int slice,sizeImageVector=dlg.getImagesSelected().size();
-                        for (slice=0 ; slice<sizeImageVector ; slice++)
-                        {
-                               vtkImageData *img = dlg.getImagesSelected()[slice];
-                               memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
+                         if (dim[2]==1){
+                                vtkImageData *out;
+                               out  = vtkImageData::New();
+                               out->SetScalarType(first->GetScalarType());
+                               out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
+                               int ext[6];
+                               first->GetWholeExtent(ext); 
+                               if(ext[5] == 0)
+                               {
+                                  ext[5] = dlg.getImagesSelected().size()-1;
+                                } else {
+                                       ext[5] = ext[5] * dlg.getImagesSelected().size()-1; // to deal with multiframes 
+                               } // ext
+                               out->SetExtent(ext);
+                               double spac[3];
+                               first->GetDimensions(dim);
+                               first->GetSpacing(spac);
+                               if (spac[0]==spac[1])
+                               {
+                                               spac[2]=spac[0];  
+                               }
+                               out->SetSpacing(spac);
+                               out->SetDimensions(dim[0], dim[1], dlg.getImagesSelected().size() );
+                               out->AllocateScalars();
+                               out->Update();
+                               unsigned long imsize = dim[0] * dim[1];
+                               imsize = imsize * dim[2];  // deal with multiframes here
+                               // differents formats char , short, etc...
+                               // differents components 1..3  ex. jpg ->RGB 3
+                               imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+printf("EED  creaImageIOWxSimpleDlg 2 \n");
+                               int slice,sizeImageVector=dlg.getImagesSelected().size();
+                               for (slice=0 ; slice<sizeImageVector ; slice++)
+                               {
+printf("EED  creaImageIOWxSimpleDlg 3 slice %d     sizeImageVector %d\n",slice,sizeImageVector);
+                                       vtkImageData *img = dlg.getImagesSelected()[slice];
+                                       memcpy(out->GetScalarPointer(0,0,slice), img->GetScalarPointer(0,0,0), imsize);
                                //img->Delete();
-                        }      
+                                } // for slice 
 
-//EED Notworking the iteration over the pointer vtkImageData
-//                   int slice=0;
-//                   std::vector<vtkImageData*>::iterator it;
-//                   for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it) 
-//                       {
+//EED This is NOT working. The iteration over the pointer vtkImageData
+//                     int slice=0;
+//                     std::vector<vtkImageData*>::iterator it;
+//                     for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it) 
+//                     {
 //                               memcpy(out->GetScalarPointer(0,0,slice), (*it)->GetScalarPointer(0,0,0), imsize);
 //                               slice++;
-//                       }     
+//                     }       
 //                    //for (it=dlg.getImagesSelected().begin(); it!=dlg.getImagesSelected().end(); ++it) 
 //                     //  {
 //                     //      (*it)->Delete();
 //                     //  }
 
-
-                        bbSetOutputOut(out);
+printf("EED  creaImageIOWxSimpleDlg 4 \n");
+                               bbSetOutputOut(out);
+                       } else {
+                        bbSetOutputOut(first);
+                       } // dim
                  }
                } else { 
-             bbSetOutputOut( NULL );  
-               } 
+               bbSetOutputOut( NULL );  
+       } // dlg.getImagesSelected().size()!=0
         bbSetOutputOutImages( dlg.getImagesSelected());  
+printf("EED  creaImageIOWxSimpleDlg 5 \n");
     </PRE>
   </process>