From: Eduardo DAVILA Date: Thu, 25 Jul 2013 14:23:17 +0000 (+0200) Subject: 2084 creaImageIO Bug New Normal ChooseerDialogBox First button is not working for... X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=74fee11f6fc2f68df04cd41b448bf10cbff2ca24;p=creaImageIO.git 2084 creaImageIO Bug New Normal ChooseerDialogBox First button is not working for reading miltiple images 3D --- diff --git a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml index 5c75390..9c07473 100644 --- a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml +++ b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml @@ -64,73 +64,77 @@ 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 ; sliceGetScalarPointer(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 ; sliceGetScalarPointer(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::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::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");