From: caballero Date: Wed, 8 Apr 2009 15:46:46 +0000 (+0000) Subject: Added GetImages to obtain images from a given file list. X-Git-Tag: EED.02Oct2009~111 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=bfe6b2a61bb41b040fb6d49718f1d3558baec84d;p=creaImageIO.git Added GetImages to obtain images from a given file list. --- diff --git a/appli/gimmick/main.cxx b/appli/gimmick/main.cxx index 274efe7..cecd0f7 100644 --- a/appli/gimmick/main.cxx +++ b/appli/gimmick/main.cxx @@ -76,12 +76,11 @@ int main(int ac, char* av[]) } if (vm.count("file")) { std::vector files=vm["file"].as< vector >(); - cout << "Include paths are: " << vm["file"].as< vector >().front() << "\n"; g.AddFiles(handler,files); } if (vm.count("dir")) { std::vector dirs=vm["dir"].as< vector >(); - g.AddDir(handler,dirs.front(), vm.count("recurse")); + g.AddDir(handler,dirs.front(), vm.count("recurse")); } g.Finalize(); } diff --git a/src2/creaImageIOGimmickView.cpp b/src2/creaImageIOGimmickView.cpp index c24a7c3..8c0884c 100644 --- a/src2/creaImageIOGimmickView.cpp +++ b/src2/creaImageIOGimmickView.cpp @@ -256,7 +256,7 @@ namespace creaImageIO //====================================================================== ///Reads Images (Non Threaded) - void GimmickView::ReadImagesNotThreaded(std::vector& s,std::vector im, int dimension) + void GimmickView::ReadImagesNotThreaded(std::vector& s,std::vector im, int dimension) { // Create the output data @@ -265,16 +265,16 @@ namespace creaImageIO // Only one image : give it vtkImageData* out = vtkImageData::New(); - GimmickMessage(1, "State Check: Full Filename: " - <GetAttribute("FullFileName") + GimmickDebugMessage(3, "State Check: Full Filename: " + <ShallowCopy(mReader.GetImage(im.front()->GetAttribute("FullFileName"))); + out->ShallowCopy(mReader.GetImage(im.front())); s.push_back( out ); } else if (im.size()>1) { - vtkImageData* first = mReader.GetImage( im.front()->GetAttribute("FullFileName")); + vtkImageData* first = mReader.GetImage( im.front()); if (dimension==2) { // n2D to 3D @@ -300,11 +300,11 @@ namespace creaImageIO *dim[1]; int slice = 0; - std::vector::iterator it; - for (it=im.begin(); it!=im.end(); ++it) + std::vector::iterator it; + for (it=im.begin(); it!=im.end(); ++it) { //std::cout << "copying slice "<GetAttribute("FullFileName")); + vtkImageData* cur = mReader.GetImage( (*it)); void* src = cur->GetScalarPointer(0,0,0); void* dst = out->GetScalarPointer(0,0,slice); @@ -320,11 +320,11 @@ namespace creaImageIO else { // n3D - std::vector::iterator it; + std::vector::iterator it; for (it=im.begin(); it!=im.end(); ++it) { vtkImageData* out = vtkImageData::New(); - out->ShallowCopy(mReader.GetImage((*it)->GetAttribute("FullFileName"))); + out->ShallowCopy(mReader.GetImage(*it)); s.push_back(out); } } diff --git a/src2/creaImageIOGimmickView.h b/src2/creaImageIOGimmickView.h index 751e5ba..d028b5d 100644 --- a/src2/creaImageIOGimmickView.h +++ b/src2/creaImageIOGimmickView.h @@ -69,8 +69,13 @@ namespace creaImageIO virtual void GetSelectedFiles(std::vector& s) { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); } + + virtual void GetImages(int dim, std::vector files, std::vector& s) + { GimmickError("INTERNAL ERROR : GetImages not implemented"); } + virtual void OnSelectionChange(std::vector& s, bool isSelection, int selection, bool mProcess) { GimmickError("INTERNAL ERROR : OnSelectionChange not implemented"); } + virtual void ClearSelection() { GimmickError("INTERNAL ERROR : ClearSelection not implemented"); } @@ -78,8 +83,8 @@ namespace creaImageIO ///Validates the dimension compliance of the images with the maximum and minimum given, and between their sizes bool ValidateSelected (tree::Node* sel, int min_dim, int max_dim); - ///Reads the vector of nodes, builds images in the dimension required and returns them in the supplied vector. - void ReadImagesNotThreaded(std::vector& s,std::vector im, int dim); + ///Reads the vector of images, builds it in the dimension required and returns them in the supplied vector. + void ReadImagesNotThreaded(std::vector& s,std::vector files, int dim); ///Requests the reading of an image with priority and index in the /// current selection (-1 if not in selection) void RequestReading(tree::Node* n, int prio, int selection_index , ImagePointerHolder *p); diff --git a/src2/creaImageIOWxGimmickView.cpp b/src2/creaImageIOWxGimmickView.cpp index f70f943..63ff888 100644 --- a/src2/creaImageIOWxGimmickView.cpp +++ b/src2/creaImageIOWxGimmickView.cpp @@ -221,19 +221,22 @@ namespace creaImageIO } //====================================================================== - /// Returns the selected Images so that they comply with the given parameter(4D) void WxGimmickView::GetSelectedImages(std::vector& s, int dim) { - int level=GetTreeViewMap()["Local database"]->GetNumberOfLevels(); - std::vector im=GetTreeViewMap()["Local database"]->GetSelected(level+1); - ReadImagesNotThreaded(s,im,dim); + std::vector files; + GetTreeViewMap()["Local database"]->GetSelectedAsString(files); + ReadImagesNotThreaded(s,files,dim); } //====================================================================== - /// Returns the selected Images so that they comply with the given parameter(4D) void WxGimmickView::GetSelectedFiles(std::vector& s) { GetTreeViewMap()["Local database"]->GetSelectedAsString(s); } + //====================================================================== + void WxGimmickView::GetImages(int dim, std::vector files, std::vector& s) + { + ReadImagesNotThreaded(s,files,dim); + } //================================================= void WxGimmickView::CreateIconList() { diff --git a/src2/creaImageIOWxGimmickView.h b/src2/creaImageIOWxGimmickView.h index 314d172..9fd54a9 100644 --- a/src2/creaImageIOWxGimmickView.h +++ b/src2/creaImageIOWxGimmickView.h @@ -45,6 +45,9 @@ namespace creaImageIO /// Returns the selected Images so that they comply with the given parameter(4D) //(overloaded from GimmickView) void GetSelectedImages(std::vector& s, int dim); + /// Returns the images indicated by the filenames in the vector so that they comply with the given parameter(dim) + //(overloaded from GimmickView) + void GetImages(int dim, std::vector files, std::vector& s); /// Callback called when a selection from a TreeView has changed //(overloaded from GimmickView) void OnSelectionChange(std::vector& s, bool isSelection, int selection, bool mProcess);