+ {
+ // Only one image : give it
+ vtkImageData* out = vtkImageData::New();
+ GimmickDebugMessage(3, "State Check: Full Filename: "
+ <<im.front()
+ <<std::endl);
+ out->ShallowCopy(mReader.GetImage(im.front()));
+ s.push_back( out );
+ }
+ else if (im.size()>1) // Test inutile ? JPR
+ {
+ // Read the FIRST image to get info ... about all the other ones. ?!? // JPR
+ vtkImageData* first = mReader.GetImage( im.front());
+
+ if (dimension == 2)
+ {
+ // n3D
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ vtkImageData* out = vtkImageData::New();
+ out->ShallowCopy(mReader.GetImage(*it));
+ s.push_back(out);
+ }
+ }
+ else if (dimension == 3)
+ {
+ // n*2D to 3D :: --> NON ! Ca va tres bien pour du 2D+T (le ZSpacing, on s'en tape)
+ // // ne convient pas pour du n*2D a lire comme un 3D
+ // // Il faut un gdcmSerieHelper !
+ vtkImageData* out = vtkImageData::New();
+ out->CopyStructure(first);
+ out->SetScalarType(first->GetScalarType());
+ int ext[6];
+ //first->GetExtent(ext); // JPR
+ first->GetWholeExtent(ext); // renvoie egalement 0,0 en Z // JPR
+ // Normal :
+
+std::cout <<"in GimmickView::ReadImagesNotThreaded GetWholeExtent ext =";
+for (int jjj=0;jjj<6;jjj++)
+ std:cout << " [" << jjj << "]=" << ext[jjj];
+std::cout << std::endl;
+
+ if(ext[5] == 0)
+ {
+ ext[5] = im.size()-1;
+ }
+ else
+ {
+ ext[5] = ext[5] * im.size()-1; // to deal with multiframes - JPR
+ }
+ out->SetExtent(ext);
+
+ // LG : TODO : Z Spacing ? // Voir + loin // JPR
+
+ out->AllocateScalars();
+
+ int dim[3];
+ first->GetDimensions(dim);
+ unsigned long imsize = dim[0] * dim[1];
+ imsize = imsize * dim[2] ; // deal with multiframes // JPR
+//EED 03-11-2009
+ imsize = imsize * first->GetScalarSize();
+
+ int slice = 0;
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ vtkImageData* cur = mReader.GetImage( (*it));
+ // void* src = cur->GetScalarPointer(0,0,0);
+ // void* dst = out->GetScalarPointer(0,0,slice);
+ memcpy(out->GetScalarPointer(0,0,slice), cur->GetScalarPointer(0,0,0), imsize);
+
+ slice++;
+ }
+ s.push_back(out);
+ }
+/**/
+ else // ici, on traite le cas *vraiment* n*2D as 3D // JPR
+ {
+ typedef std::vector<GDCM_NAME_SPACE::File* > FileList;
+ FileList fileVector;
+ //GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+ GDCM_NAME_SPACE::SerieHelper *sh = GDCM_NAME_SPACE::SerieHelper::New();
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ //std::cout << "avant Load ---------" << *it << std::endl;
+
+ ///\TODO liberer les GDCM_NAME_SPACE::File a la fin! // JPR
+ GDCM_NAME_SPACE::File *f = GDCM_NAME_SPACE::File::New();
+
+ f->SetFileName(*it);
+ f->Load();
+ if (f->IsReadable())
+ fileVector.push_back(f);
+ else
+ std::cout << "File [" << *it << "] not GDCM Readable; Skipped!" << std::endl;
+ }
+
+ /*
+ for (int i=0; i<fileVector.size();i++)
+ {
+ std::cout << "avant tri ---------" << fileVector[i]->GetFileName() << std::endl;
+ }
+ */
+ if (!sh->IsCoherent(&fileVector))
+ {
+ std::cout << "---------fileset is NOT coherent ?!?" << *it << std::endl;
+ //return;
+ }
+ else
+ {
+ sh->OrderFileList(&fileVector);
+ }
+ /*
+ for (int i=0; i<fileVector.size();i++)
+ {
+ std::cout << "apres tri ---------" << fileVector[i]->GetFileName() << std::endl;
+ }
+ */
+ vtkGdcmReader *reader = vtkGdcmReader::New();
+ reader->SetCoherentFileList(&fileVector);
+ reader->Update();
+ s.push_back(reader->GetOutput());
+ reader->GetOutput()->Print(std::cout);
+ }
+ /**/
+ }
+}
+ //======================================================================
+
+void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
+{
+ // Create the output data
+ if (im.size()==1)
+ {