// Create the output data
if (im.size()==1)
{
- // 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 );
+ // O0.
}
- else if (im.size()>1) // Test inutile ? JPR
+ 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());
vtkImageData* out = vtkImageData::New();
out->CopyStructure(first);
out->SetScalarType(first->GetScalarType());
+ out->SetNumberOfScalarComponents(first->GetNumberOfScalarComponents());
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;
// LG : TODO : Z Spacing ? // Voir + loin // JPR
- out->AllocateScalars();
-
int dim[3];
first->GetDimensions(dim);
+
+ out->SetDimensions(dim[0], dim[1], im.size() );
+ out->AllocateScalars();
+ out->Update();
+
unsigned long imsize = dim[0] * dim[1];
imsize = imsize * dim[2] ; // deal with multiframes // JPR
+
+
//EED 03-11-2009
- imsize = imsize * first->GetScalarSize();
+ // differents formats char , short, etc...
+ // differents components 1..3 ex. jpg ->RGB 3
+ imsize = imsize * first->GetScalarSize() * first->GetNumberOfScalarComponents();
+
+ first->PrintSelf( std::cout , (vtkIndent)2);
+ // Order the file name vector
+
+ double spc[3];
+ out->GetSpacing(spc);
+ spc[2]=OrderTheFileNameVector(im);
+ out->SetSpacing(spc);
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);
+ printf("EED GimmickView::ReadImagesNotThreaded %s \n", (*it).c_str() );
+ vtkImageData* cur = mReader.GetImage( (*it) );
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
+
+ } // dimension == 3
+
+ } // size >1
+
+}
+ //======================================================================
+
+
+double GimmickView::OrderTheFileNameVector(std::vector<std::string> &im)
+{
+ double spacing=1;
+ 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> lstAux;
+ std::vector<std::string>::iterator it;
+ for (it=im.begin(); it!=im.end(); ++it)
+ {
+ ///\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())
{
- 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;
- }
+ fileVector.push_back(f);
+ } else {
+ lstAux.push_back(*it);
+ }
+ } // for
- /*
- 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
+
+ if ((fileVector.size()>1) && (sh->IsCoherent( &fileVector )))
+ {
+ sh->OrderFileList(&fileVector);
+ spacing= sh->GetZSpacing();
+ im.clear();
+ int i;
+ for (i=0; i<fileVector.size(); i++)
{
- sh->OrderFileList(&fileVector);
+ im.push_back( (fileVector[i])->GetFileName() );
}
- /*
- for (int i=0; i<fileVector.size();i++)
+ for (i=0; i<lstAux.size(); i++)
{
- std::cout << "apres tri ---------" << fileVector[i]->GetFileName() << std::endl;
+ im.push_back( lstAux[i] );
}
- */
- vtkGdcmReader *reader = vtkGdcmReader::New();
- reader->SetCoherentFileList(&fileVector);
- reader->Update();
- s.push_back(reader->GetOutput());
- reader->GetOutput()->Print(std::cout);
- }
- /**/
+ }else {
+ std::sort( im.begin(), im.end() );
}
+
+ return spacing;
}
- //======================================================================
+
+
+//======================================================================
+
void GimmickView::ReadImagesNotThreadedInVector(std::vector<vtkImageData*>& s, std::vector<std::string> im, int dimension)
{