From 571ba36f99e308623afc6f6cd0e7e3ae0a4bc09e Mon Sep 17 00:00:00 2001 From: Frederic Cervenansky Date: Fri, 21 Oct 2011 09:48:59 +0000 Subject: [PATCH] to resolve Lisa-Eduardo issue --- .../bbcreaImageIOImagesChooserDialogBox.xml | 65 ++++++++++++++++--- 1 file changed, 57 insertions(+), 8 deletions(-) diff --git a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml index 8310f1c..bbc6b95 100644 --- a/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml +++ b/bbtk/src/bbcreaImageIOImagesChooserDialogBox.xml @@ -31,14 +31,63 @@
-      creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database");
-      dlg.ShowModal();
-	  if (dlg.getImagesSelected().size()!=0){
-	      bbSetOutputOut( dlg.getImagesSelected()[0] ); 
-	  } else {
-	      bbSetOutputOut( NULL ); 
-	  }
-      bbSetOutputOutImages( dlg.getImagesSelected()); 
+        creaImageIO::WxSimpleDlg dlg(0,crea::std2wx(bbGetInputTitle()),"localdatabase_Descriptor.dscp","Local Database"); 
+		dlg.ShowModal(); 
+		if (dlg.getImagesSelected().size()!=0){ 
+		  if(dlg.getImagesSelected().size() ==1)
+		  {
+			bbSetOutputOut( dlg.getImagesSelected()[0] );  
+		  }
+		  else
+		  {
+			  // 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);
+		      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 = 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);
+		  }
+		} else { 
+	      bbSetOutputOut( NULL );  
+		} 
+        bbSetOutputOutImages( dlg.getImagesSelected());  
     
-- 2.47.1