]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement temporary MED files handling.
authorapo <apo@opencascade.com>
Wed, 27 Jun 2007 13:43:36 +0000 (13:43 +0000)
committerapo <apo@opencascade.com>
Wed, 27 Jun 2007 13:43:36 +0000 (13:43 +0000)
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index 012c00b611844ecd55bc68f78ecd5455080ffdf1..cc8f5bb3a5a636785e98c6fd5faaf500c9cdd47d 100644 (file)
 #include <boost/thread/thread.hpp>
 #include <boost/bind.hpp>
 
+#include <qfileinfo.h>
+#include <qfile.h>
+#include <qdir.h>
+
 #include <strstream>
 
 
@@ -460,20 +464,34 @@ VISU::MultiResult_i
 //---------------------------------------------------------------
 VISU::MultiResult_i
 ::~MultiResult_i()
-{}
+{
+  //cout<<"MultiResult_i::~MultiResult_i - '"<<myRepresentation2Input.size()<<"' - "<<endl;
+  TRepresentation2Input::iterator anIter = myRepresentation2Input.begin();
+  for ( ; anIter != myRepresentation2Input.end() ; anIter++) {
+    const PInput& anInput = anIter->second;
+    std::string aFileName = anInput->GetName();
+    //cout<<"'"<<aFileName<<"'; "<<endl;
+    QFileInfo aFileInfo(aFileName.c_str());
+    QFile(aFileInfo.absFilePath()).remove();
+    QDir().rmdir(aFileInfo.dirPath(TRUE));
+  }
+}
 
 
 //---------------------------------------------------------------
 void
 VISU::MultiResult_i
-::SetResolution(const std::string& theName, 
+::SetResolution(const std::string& thePartName, 
                TResolutionID theNewResolution)
 {
-  TPartName2FileName::iterator anIter = myPartName2FileName.find(theName);
+  if(!IsFullResolution(thePartName))
+    return;
+
+  TPartName2FileName::iterator anIter = myPartName2FileName.find(thePartName);
   if(anIter == myPartName2FileName.end())
     return;
 
-  TResolutionID& aNewResolution = myPartName2ResolutionID[theName];
+  TResolutionID& aNewResolution = myPartName2ResolutionID[thePartName];
   if(aNewResolution == theNewResolution)
     return;
 
@@ -543,13 +561,15 @@ namespace VISU
     MultiResult_i::TPartName2ResolutionID::const_iterator anIter = thePartName2ResolutionID.begin();
     for ( ; anIter != thePartName2ResolutionID.end() ; anIter++) {
       const MultiResult_i::TPartName& aPartName = anIter->first;
-      const MultiResult_i::TResolutionID& aResolutionID = anIter->second;
-      if(aResolutionID == 'F') 
-       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName);
-      if(aResolutionID == 'M') 
-       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_MED");
-      else if(aResolutionID == 'L') 
-       UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_LOW");
+      if(IsFullResolution(aPartName)){
+       const MultiResult_i::TResolutionID& aResolutionID = anIter->second;
+       if(aResolutionID == 'F') 
+         UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName);
+       if(aResolutionID == 'M') 
+         UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_MED");
+       else if(aResolutionID == 'L') 
+         UpdateRepresentationKey(thePartName2FileName, aRepresentationKey, aPartName + "_LOW");
+      }
     }
     return aRepresentationKey;
   }
@@ -609,14 +629,22 @@ VISU::MultiResult_i
   TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey);
   if(anIter == myRepresentation2Input.end()){
     std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "tmp.med";
-    //cout<<"MultiResult_i::GetInput - '"<<aFileName<<"'"<<endl;
+    //cout<<"MultiResult_i::GetInput - '"<<aFileName<<"' - "<<endl;
+    {
+      TFileNames::const_iterator anIter = aFileNames.begin();
+      for ( ; anIter != aFileNames.end() ; anIter++) {
+       const MultiResult_i::TFileName& aFileName = *anIter;
+       //cout<<"'"<<aFileName<<"'; "<<endl;
+      }
+    }
     int aRes = multipr::merge(aFileNames, theMeshName.c_str(), theFieldName.c_str(), aFileName.c_str());
+    //cout<<"aRes = "<<aRes<<endl;
     if (aRes == 0) {
       QFile(aFileName.c_str()).remove();
       throw std::runtime_error("empty mesh"); 
     }
     PInput anInput(CreateConvertor(aFileName));
-    anInput->Build();
+    anInput->BuildFields();
     myRepresentation2Input[aRepresentationKey] = anInput;
     return anInput;
   }
index 1b3bf77cdef26808e63bb339b0af47ebc8083aa5..c199ec628d074981c1d4efd81bae5b2b0793428a 100644 (file)
@@ -909,6 +909,14 @@ VISU::Result_i
 }
 
 
+const VISU::Result_i::ESourceId&
+VISU::Result_i
+::GetSourceId() const
+{
+  return mySourceId;
+}
+
+
 //---------------------------------------------------------------
 std::string
 VISU::Result_i
index bd8ec41ddb3a3272b1fa725e0a12c6112b0efa91..191dafd38b432a4ca53a911f08f46e7eb9d09edc 100644 (file)
@@ -174,6 +174,9 @@ namespace VISU
     Storable* 
     BuildAll(SALOMEDS::SObject_ptr theSObject) ;
 
+    const ESourceId& 
+    GetSourceId() const;
+       
     _PTR(Study) myStudy;
     CORBA::Boolean myIsBuildImmediately;