]> Creatis software - creaImageIO.git/commitdiff
Added GetImages to obtain images from a given file list.
authorcaballero <caballero>
Wed, 8 Apr 2009 15:46:46 +0000 (15:46 +0000)
committercaballero <caballero>
Wed, 8 Apr 2009 15:46:46 +0000 (15:46 +0000)
appli/gimmick/main.cxx
src2/creaImageIOGimmickView.cpp
src2/creaImageIOGimmickView.h
src2/creaImageIOWxGimmickView.cpp
src2/creaImageIOWxGimmickView.h

index 274efe70ee6f7d48cbf1fd82c677fa545513c0f1..cecd0f76ba6ac8503f6e7d24fb8cfac8fae10caf 100644 (file)
@@ -76,12 +76,11 @@ int main(int ac, char* av[])
        }
        if (vm.count("file")) {
                std::vector<std::string> files=vm["file"].as< vector<string> >();
-               cout << "Include paths are: " << vm["file"].as< vector<string> >().front() << "\n";
         g.AddFiles(handler,files);
        }
        if (vm.count("dir")) {
                std::vector<std::string> dirs=vm["dir"].as< vector<string> >();
-         g.AddDir(handler,dirs.front(), vm.count("recurse"));
+               g.AddDir(handler,dirs.front(), vm.count("recurse"));
        }
         g.Finalize();
     }
index c24a7c3c3534638640762fc75d1eaaf1e61b3e0f..8c0884c3e4926406e2d2387ba39612e42ad942fd 100644 (file)
@@ -256,7 +256,7 @@ namespace creaImageIO
 
    //======================================================================
   ///Reads Images (Non Threaded)
-  void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<tree::Node*> im, int dimension)
+  void GimmickView::ReadImagesNotThreaded(std::vector<vtkImageData*>& s,std::vector<std::string> 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: "
-                                               <<im.front()->GetAttribute("FullFileName")
+               GimmickDebugMessage(3, "State Check: Full Filename: "
+                                               <<im.front()
                                                <<std::endl);
-               out->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<tree::Node*>::iterator it;
-           for (it=im.begin(); it!=im.end(); ++it) 
+               std::vector<std::string>::iterator it;
+          for (it=im.begin(); it!=im.end(); ++it) 
              {
                //std::cout << "copying slice "<<slice <<std::endl;
-                         vtkImageData* cur = mReader.GetImage( (*it)->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<tree::Node*>::iterator it;
+                 std::vector<std::string>::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);
              }
          }
index 751e5babab42e1e75c6094397151badcbfbac0c0..d028b5d3ea952d9da29f92a529860193fd39f47b 100644 (file)
@@ -69,8 +69,13 @@ namespace creaImageIO
 
       virtual void GetSelectedFiles(std::vector<std::string>& s)
       { GimmickError("INTERNAL ERROR : GetSelectedFiles not implemented"); }
+
+         virtual void GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s) 
+         { GimmickError("INTERNAL ERROR : GetImages not implemented"); }
+
       virtual void OnSelectionChange(std::vector<tree::Node*>& 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<vtkImageData*>& s,std::vector<tree::Node*> 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<vtkImageData*>& s,std::vector<std::string> 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);
index f70f9430ee0259557deeebcc38cdfc4660b5f826..63ff888694a3fd09b8dfe5081687aa8c5e1967dc 100644 (file)
@@ -221,19 +221,22 @@ namespace creaImageIO
   }
 
   //======================================================================
-  /// Returns the selected Images so that they comply with the given parameter(4D)
   void WxGimmickView::GetSelectedImages(std::vector<vtkImageData*>& s, int dim)
   {
-       int level=GetTreeViewMap()["Local database"]->GetNumberOfLevels();
-       std::vector<tree::Node*> im=GetTreeViewMap()["Local database"]->GetSelected(level+1);
-       ReadImagesNotThreaded(s,im,dim);
+       std::vector<std::string> 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<std::string>& s)
   {
        GetTreeViewMap()["Local database"]->GetSelectedAsString(s);
   }
+  //======================================================================
+  void WxGimmickView::GetImages(int dim, std::vector<std::string> files, std::vector<vtkImageData*>& s)
+  {
+       ReadImagesNotThreaded(s,files,dim);
+  }
   //=================================================
   void WxGimmickView::CreateIconList()
   {
index 314d1720b414b32bc66725f19e8d8e7ab9d54ed2..9fd54a963a87d3c56864e781d21576be0943e0c2 100644 (file)
@@ -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<vtkImageData*>& 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<std::string> files, std::vector<vtkImageData*>& s);
       /// Callback called when a selection from a TreeView has changed 
       //(overloaded from GimmickView)
       void OnSelectionChange(std::vector<tree::Node*>& s, bool isSelection, int selection, bool mProcess);