]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Implementation of Save functionality for MultiResult
authorapo <apo@opencascade.com>
Mon, 9 Jul 2007 11:42:54 +0000 (11:42 +0000)
committerapo <apo@opencascade.com>
Mon, 9 Jul 2007 11:42:54 +0000 (11:42 +0000)
src/VISU_I/Makefile.am
src/VISU_I/VISU_Gen_i.cc
src/VISU_I/VISU_MultiResult_i.cc
src/VISU_I/VISU_MultiResult_i.hh
src/VISU_I/VISU_Prs3d_i.hh
src/VISU_I/VISU_Result_i.cc
src/VISU_I/VISU_Result_i.hh

index 2887c6d61815678e2f52e007b76606971283e15c..9bc96abd24364fa76ccf749fc1713c7b94b2109d 100644 (file)
@@ -58,6 +58,7 @@ libVISUEngineImpl_la_SOURCES = \
        VISU_Result_i.cc \
        VISU_ResultUtils.cc \
        VISU_MultiResult_i.cc \
+       VISU_Gen_i.cc \
        VISU_CorbaMedConvertor.cxx \
        VISU_PrsObject_i.cc \
        VISU_Prs3d_i.cc \
@@ -80,7 +81,6 @@ libVISUEngineImpl_la_SOURCES = \
        VISU_TimeAnimation.cxx \
        VISU_View_i.cc \
        VISU_Table_i.cc \
-       VISU_Gen_i.cc \
        VISU_DumpPython.cc \
        SALOME_GenericObjPointer.cc
 
@@ -116,7 +116,10 @@ libVISUEngineImpl_la_LDFLAGS= \
        $(MED_LDFLAGS) \
        ../../idl/libSalomeIDLVISU.la
 
-libVISUEngineImpl_la_LIBADD= -lboost_signals@BOOST_LIBSUFFIX@ -lboost_thread@BOOST_LIBSUFFIX@ \
+libVISUEngineImpl_la_LIBADD= \
+       -lboost_signals@BOOST_LIBSUFFIX@ \
+       -lboost_thread@BOOST_LIBSUFFIX@ \
+       -lboost_filesystem@BOOST_LIBSUFFIX@ \
        -lSalomeHDFPersist \
        -lSalomeGenericObj \
        -lSalomeContainer \
@@ -145,7 +148,9 @@ endif
 bin_PROGRAMS = VISU_I
 dist_VISU_I_SOURCES=VISU_I.cxx
 VISU_I_CPPFLAGS=$(libVISUEngineImpl_la_CPPFLAGS)
-VISU_I_LDADD=$(libVISUEngineImpl_la_LIBADD) $(libVISUEngineImpl_la_LDFLAGS) \
+VISU_I_LDADD=\
+       $(libVISUEngineImpl_la_LIBADD) \
+       $(libVISUEngineImpl_la_LDFLAGS) \
        $(KERNEL_LDFLAGS) \
        -lSALOMEBasics \
        -lSalomeCatalog \
index c364188fcafb13eb14209d6403edb7796b038600..426b4052ba21e4decbda421caae835f76e342aa1 100644 (file)
@@ -82,12 +82,13 @@ UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
 // STL Includes
 #include <strstream>
 
-using namespace std;
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace filesystem = boost::filesystem;
 
-static QFileInfo aFileInfo;
 
 #ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
 #else
 static int MYDEBUG = 0;
 #endif
@@ -362,14 +363,14 @@ namespace VISU
   SALOMEDS::TMPFile* 
   VISU_Gen_i
   ::Save(SALOMEDS::SComponent_ptr theComponent,
-        const char* theTmpDir,
+        const char* theURL,
         bool theIsMultiFile)
   {
-    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theTmpDir = '"<<theTmpDir<<"'");
+    if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theURL = '"<<theURL<<"'");
     
-    typedef std::vector<std::string> TFileNames;
-    TFileNames aFileNames;
-    TFileNames aFilePathes;
+    Result_i::TFileNames aFileNames;
+    Result_i::TFileNames aFullFileNames;
+    Result_i::TFileNames aTemporaryDirs;
 
     SALOMEDS::Study_var aStudy = theComponent->GetStudy();
     SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
@@ -377,11 +378,12 @@ namespace VISU
       SALOMEDS::SObject_var aSObject = anIter->Value();
       CORBA::Object_var anObj = SObjectToObject(aSObject);
       if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
-       std::string aFileName, aFilePath;
-       if(aResult->Save(theComponent, theTmpDir, theIsMultiFile, aFileName, aFilePath)){
-         aFileNames.push_back(aFileName);
-         aFilePathes.push_back(aFilePath);
-       }
+       aResult->Save(theComponent, 
+                     theURL, 
+                     theIsMultiFile, 
+                     aFileNames, 
+                     aFullFileNames,
+                     aTemporaryDirs);
       }
     }
 
@@ -394,19 +396,27 @@ namespace VISU
        aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
     }
 
-    SALOMEDS::ListOfFileNames_var aListOfFilePathes = new SALOMEDS::ListOfFileNames;
-    aListOfFilePathes->length(aFilePathes.size());
-    if(!aFilePathes.empty()){
-      for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
-       aListOfFilePathes[aCounter-1] = aFilePathes[aCounter-1].c_str();
+    SALOMEDS::ListOfFileNames_var aListOfFullFileNames = new SALOMEDS::ListOfFileNames;
+    if(!aFullFileNames.empty()){
+      aListOfFullFileNames->length(aFullFileNames.size());
+      for(int aCounter = aFullFileNames.size(); aCounter > 0; aCounter--)
+       aListOfFullFileNames[aCounter-1] = aFullFileNames[aCounter-1].c_str();
     }
 
     SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
     if(theIsMultiFile)
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(theTmpDir, aListOfFilePathes.in(), theIsMultiFile);
-    else
-      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFilePathes.in(), aListOfFileNames.in());
-
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFullFileNames.in(), theIsMultiFile);
+    else{
+      aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFullFileNames.in(), aListOfFileNames.in());
+      Result_i::TFileNames::const_iterator anIter = aTemporaryDirs.begin();
+      for(; anIter != aTemporaryDirs.end(); anIter++){
+       filesystem::path aDirName(*anIter);
+       if(filesystem::exists(aDirName)){
+         filesystem::remove_all(aDirName);
+         if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aDirName  ='"<<aDirName.string()<<"'\n");
+       }
+      }
+    }
     return aStreamFile._retn();
   }
 
@@ -608,7 +618,11 @@ namespace VISU
 
     Result_i* aResult = Result_i::New(myStudyDocument,
                                      Result_i::eFile,
-                                     Result_i::eImportFile);
+                                     Result_i::eImportFile,
+                                     true,
+                                     true,
+                                     true,
+                                     true);
 
     if(aResult->Create(theFileName) != NULL)
       return aResult->_this();
@@ -630,7 +644,10 @@ namespace VISU
     Result_i* aResult = Result_i::New(myStudyDocument,
                                      Result_i::eFile,
                                      Result_i::eImportFile,
-                                     false);
+                                     false,
+                                     true,
+                                     true,
+                                     true);
 
     if(aResult->Create(theFileName) != NULL)
       return aResult->_this();
@@ -651,7 +668,11 @@ namespace VISU
 
     Result_i* aResult = Result_i::New(myStudyDocument,
                                      Result_i::eRestoredFile,
-                                     Result_i::eCopyAndImportFile);
+                                     Result_i::eCopyAndImportFile,
+                                     true,
+                                     true,
+                                     true,
+                                     true);
     if(aResult->Create(theFileName) != NULL)
       return aResult->_this();
     else
@@ -671,7 +692,11 @@ namespace VISU
 
     Result_i* aResult = Result_i::New(myStudyDocument,
                                      Result_i::eComponent,
-                                     Result_i::eImportMed);
+                                     Result_i::eImportMed,
+                                     true,
+                                     true,
+                                     true,
+                                     true);
     if (aResult->Create(theMedSObject) != NULL)
       return aResult->_this();
     else
@@ -691,7 +716,11 @@ namespace VISU
 
     Result_i* aResult = Result_i::New(myStudyDocument,
                                      Result_i::eComponent,
-                                     Result_i::eImportMedField);
+                                     Result_i::eImportMedField,
+                                     true,
+                                     true,
+                                     true,
+                                     true);
 
     if (aResult->Create(theField) != NULL)
       return aResult->_this();
index cd7ea864d28428bbb3c2af16fbf32d52581ccfbd..faee5c18db6406c3e87aa5e07519cdea1b46f5fb 100644 (file)
 
 #include <strstream>
 
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace filesystem = boost::filesystem;
+
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
 static int MYTIMEDEBUG = 0;
@@ -113,21 +117,21 @@ namespace VISU
   //---------------------------------------------------------------
   inline
   MultiResult_i::TResolutions
-  GetResolutions(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts,
+  GetResolutions(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames,
                 const std::string& thePartName)
   {
     MultiResult_i::TResolutions aResolutions;
     aResolutions.insert(VISU::Result::FULL);
 
     MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName);
-    MultiResult_i::TMainPart2SubParts::const_iterator anIter = theMainPart2SubParts.find(aMainPart);
-    if(anIter != theMainPart2SubParts.end()){
-      const MultiResult_i::TSubParts& aSubParts = anIter->second;
+    MultiResult_i::TMainPart2SubPartNames::const_iterator anIter = theMainPart2SubPartNames.find(aMainPart);
+    if(anIter != theMainPart2SubPartNames.end()){
+      const MultiResult_i::TSubPartNames& aSubPartNames = anIter->second;
 
-      if(aSubParts.find(aMainPart + "_LOW") != aSubParts.end())
+      if(aSubPartNames.find(aMainPart + "_LOW") != aSubPartNames.end())
        aResolutions.insert(VISU::Result::LOW);
 
-      if(aSubParts.find(aMainPart + "_MED") != aSubParts.end())
+      if(aSubPartNames.find(aMainPart + "_MED") != aSubPartNames.end())
        aResolutions.insert(VISU::Result::MEDIUM);
     }
     return aResolutions;
@@ -155,10 +159,10 @@ namespace VISU
   //---------------------------------------------------------------
   inline
   VISU::Result::Resolution
-  GetResolution(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts,
+  GetResolution(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames,
                  const std::string& thePartName)
   {
-    MultiResult_i::TResolutions aResolutions = GetResolutions(theMainPart2SubParts, thePartName);
+    MultiResult_i::TResolutions aResolutions = GetResolutions(theMainPart2SubPartNames, thePartName);
 
     if(aResolutions.find(VISU::Result::LOW) != aResolutions.end())
       return VISU::Result::LOW;
@@ -173,10 +177,10 @@ namespace VISU
   //---------------------------------------------------------------
   inline
   std::string
-  GetIconName(const MultiResult_i::TMainPart2SubParts& theMainPart2SubParts,
+  GetIconName(const MultiResult_i::TMainPart2SubPartNames& theMainPart2SubPartNames,
              const std::string& thePartName)
   {
-    VISU::Result::Resolution aResolution = GetResolution(theMainPart2SubParts,
+    VISU::Result::Resolution aResolution = GetResolution(theMainPart2SubPartNames,
                                                         thePartName);
     if(aResolution == VISU::Result::LOW)
       return "ICON_MULTIPR_VIEW_LOW";
@@ -196,7 +200,7 @@ namespace VISU
             MultiResult_i::TPartInfos* thePartInfos,
             MultiResult_i::TPartName2FileName* thePartName2FileName,
             MultiResult_i::TPartName2Resolution* thePartName2Resolution,
-            MultiResult_i::TMainPart2SubParts* theMainPart2SubParts,
+            MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames,
             CORBA::Boolean* theIsDone,
             CORBA::Boolean theIsBuild,
             _PTR(Study) theStudy)
@@ -214,10 +218,10 @@ namespace VISU
        VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
        const VISU::PMesh& aMesh = aMeshMapIter->second;
        
-       MultiResult_i::TParts aParts = aMultiprObj.getParts();
+       MultiResult_i::TPartNames aPartNames = aMultiprObj.getParts();
        
        QString aComment = "Sub-parts: #";
-       aComment += QString::number(aParts.size());
+       aComment += QString::number(aPartNames.size());
        
        CreateAttributes(theStudy,
                         aMesh->myPartsEntry,
@@ -232,17 +236,17 @@ namespace VISU
        MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName;
        MultiResult_i::TPartName2Resolution& aPartName2Resolution = *thePartName2Resolution;
        
-       MultiResult_i::TMainPart2SubParts& aMainPart2SubParts = *theMainPart2SubParts;
+       MultiResult_i::TMainPart2SubPartNames& aMainPart2SubPartNames = *theMainPart2SubPartNames;
        
-       for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
-         const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+       for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+         const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
          MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName);
-         aMainPart2SubParts[aMainPart].insert(aPartName);
+         aMainPart2SubPartNames[aMainPart].insert(aPartName);
        }
        
        std::string aLastEntry;
-       for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
-         const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+       for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+         const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
          std::string aStringInfo = aMultiprObj.getPartInfo(aPartName.c_str());
          
          MultiResult_i::TPartInfo aPartInfo;
@@ -259,11 +263,11 @@ namespace VISU
          aPartName2FileName[aPartInfo.myName] = aPartInfo.myFileName;
          
          QString aComment = "";
-         MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubParts, aPartInfo.myName);
+         MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubPartNames, aPartInfo.myName);
          std::string aResoltutionsString = Resolutions2String(aResoltutions);
          if ( IsFullResolution(aPartInfo.myName) ) {
-           std::string anIconName = GetIconName(aMainPart2SubParts, aPartInfo.myName);
-           VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubParts, aPartInfo.myName);
+           std::string anIconName = GetIconName(aMainPart2SubPartNames, aPartInfo.myName);
+           VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubPartNames, aPartInfo.myName);
            aComment.sprintf("myComment=PART;myMeshName=%s;myFile=%s;myResolutions=%s;myState=%c", 
                             aPartInfo.myMeshName.c_str(), aPartInfo.myFileName.c_str(), aResoltutionsString.c_str(), aResolution); 
            aLastEntry = CreateAttributes(theStudy,
@@ -309,7 +313,7 @@ namespace VISU
     MultiResult_i::TPartInfos* myPartInfos;
     MultiResult_i::TPartName2FileName* myPartName2FileName;
     MultiResult_i::TPartName2Resolution* myPartName2Resolution;
-    MultiResult_i::TMainPart2SubParts* myMainPart2SubParts;
+    MultiResult_i::TMainPart2SubPartNames* myMainPart2SubPartNames;
     CORBA::Boolean* myIsDone;
     CORBA::Boolean myIsBuild;
     _PTR(Study) myStudy;
@@ -320,7 +324,7 @@ namespace VISU
                    MultiResult_i::TPartInfos* thePartInfos,
                    MultiResult_i::TPartName2FileName* thePartName2FileName,
                    MultiResult_i::TPartName2Resolution* thePartName2Resolution,
-                   MultiResult_i::TMainPart2SubParts* theMainPart2SubParts,
+                   MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames,
                    CORBA::Boolean* theIsDone,
                    CORBA::Boolean theIsBuild,
                    _PTR(Study) theStudy):
@@ -330,7 +334,7 @@ namespace VISU
       myPartInfos(thePartInfos),
       myPartName2FileName(thePartName2FileName),
       myPartName2Resolution(thePartName2Resolution),
-      myMainPart2SubParts(theMainPart2SubParts),
+      myMainPart2SubPartNames(theMainPart2SubPartNames),
       myIsDone(theIsDone),
       myIsBuild(theIsBuild),
       myStudy(theStudy)
@@ -348,7 +352,7 @@ namespace VISU
               theArgs.myPartInfos,
               theArgs.myPartName2FileName,
               theArgs.myPartName2Resolution,
-              theArgs.myMainPart2SubParts,
+              theArgs.myMainPart2SubPartNames,
               theArgs.myIsDone,
               theArgs.myIsBuild,
               theArgs.myStudy);
@@ -361,13 +365,13 @@ namespace VISU
 
 //---------------------------------------------------------------
 VISU::MultiResult_i
-::MultiResult_i (SALOMEDS::Study_ptr theStudy,
-                const ESourceId& theSourceId,
-                const ECreationId& theCreationId,
-                CORBA::Boolean theIsBuildImmediately,
-                CORBA::Boolean theIsBuildFields,
-                CORBA::Boolean theIsBuildMinMax,
-                CORBA::Boolean theIsBuildGroups):
+::MultiResult_i(SALOMEDS::Study_ptr theStudy,
+               const ESourceId& theSourceId,
+               const ECreationId& theCreationId,
+               CORBA::Boolean theIsBuildImmediately,
+               CORBA::Boolean theIsBuildFields,
+               CORBA::Boolean theIsBuildMinMax,
+               CORBA::Boolean theIsBuildGroups):
   Result_i(theStudy,
           theSourceId,
           theCreationId,
@@ -378,6 +382,12 @@ VISU::MultiResult_i
 {}
 
 
+//---------------------------------------------------------------
+VISU::MultiResult_i
+::MultiResult_i()
+{}
+
+
 //---------------------------------------------------------------
 size_t
 VISU::MultiResult_i
@@ -406,7 +416,7 @@ VISU::MultiResult_i
               &myPartInfos,
               &myPartName2FileName,
               &myPartName2Resolution,
-              &myMainPart2SubParts,
+              &myMainPart2SubPartNames,
               &myIsPartsDone,
               myIsBuildParts,
               myStudy);
@@ -437,7 +447,7 @@ VISU::MultiResult_i
                           &myPartInfos,
                           &myPartName2FileName,
                           &myPartName2Resolution,
-                          &myMainPart2SubParts,
+                          &myMainPart2SubPartNames,
                           &myIsPartsDone,
                           myIsBuildParts,
                           myStudy);
@@ -486,6 +496,63 @@ VISU::MultiResult_i
 }
 
 
+//---------------------------------------------------------------
+bool
+VISU::MultiResult_i
+::Save(SALOMEDS::SComponent_ptr theComponent,
+       const std::string& theURL,
+       bool theIsMultiFile,
+       TFileNames& theFileNames,
+       TFileNames& theFullFileNames,
+       TFileNames& theTemporaryDirs)
+{
+  bool anIsDone = Result_i::Save(theComponent, 
+                                theURL, 
+                                theIsMultiFile, 
+                                theFileNames, 
+                                theFullFileNames,
+                                theTemporaryDirs);
+  if(!anIsDone)
+    return false;
+
+  if(!myMultiprObj.isValidDistributedMEDFile())
+    return true;
+    
+  // Obtain a temporary directory
+  filesystem::path aTmpDir = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+  aTmpDir /= GetName();
+  cout<<"aTmpDir = '"<<aTmpDir.string()<<endl;
+
+  filesystem::create_directory(aTmpDir);
+  if(!theIsMultiFile)
+    theTemporaryDirs.push_back(aTmpDir.string());
+
+  myMultiprObj.savePersistent(aTmpDir.string().c_str());
+
+  cout<<"myMultiprObj.getMEDFilename() = '"<<myMultiprObj.getMEDFilename()<<endl;
+  MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts();
+  for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+    const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
+    std::string aStringInfo = myMultiprObj.getPartInfo(aPartName.c_str());
+         
+    MultiResult_i::TPartInfo aPartInfo;
+    std::istrstream anOutputStream(aStringInfo.c_str());
+    anOutputStream>>(aPartInfo.myMeshName);
+    anOutputStream>>(aPartInfo.myPartID);
+    anOutputStream>>(aPartInfo.myName);
+    anOutputStream>>(aPartInfo.myPath);
+    anOutputStream>>(aPartInfo.myFileName);
+
+    cout<<"aPartInfo.myFileName = '"<<(aPartInfo.myFileName)<<endl;
+    filesystem::path aFile(aPartInfo.myFileName);
+    theFileNames.push_back(aFile.leaf());
+    theFullFileNames.push_back(aFile.branch_path().string());
+  }
+
+  return true;
+}
+
+
 //---------------------------------------------------------------
 void 
 VISU::MultiResult_i
@@ -558,10 +625,10 @@ VISU::MultiResult_i
   if(!myIsBuildParts)
     return aResult._retn();
     
-  MultiResult_i::TParts aMeshParts;
-  MultiResult_i::TParts aParts = myMultiprObj.getParts();
-  for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
-    const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+  MultiResult_i::TPartNames aMeshParts;
+  MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts();
+  for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+    const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
     if(!IsFullResolution(aPartName))
       continue;
 
@@ -595,9 +662,9 @@ VISU::MultiResult_i
   if(!myIsBuildParts)
     return aResult._retn();
 
-  MultiResult_i::TParts aParts = myMultiprObj.getParts();
-  for (size_t aPartID = 0 ; aPartID < aParts.size() ; aPartID++) {
-    const MultiResult_i::TPartName& aPartName = aParts[aPartID];
+  MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts();
+  for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+    const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
     MultiResult_i::TPartName aMainPart = ExtractMainPart(thePartName);
     if(aMainPart != thePartName)
       continue;
@@ -610,7 +677,7 @@ VISU::MultiResult_i
     if(aMeshName != theMeshName)
       continue;
 
-    MultiResult_i::TResolutions aResolutions = VISU::GetResolutions(myMainPart2SubParts, thePartName);
+    MultiResult_i::TResolutions aResolutions = VISU::GetResolutions(myMainPart2SubPartNames, thePartName);
     if(aResolutions.empty())
       return aResult._retn();
 
index b98c962c55450f2074561e24451f9bf47d325b1f..54c9a7769ad14ff2cffa936080f58961893250c8 100644 (file)
@@ -55,6 +55,8 @@ namespace VISU
                  CORBA::Boolean theIsBuildMinMax,
                  CORBA::Boolean theIsBuildGroups);
 
+    MultiResult_i();
+
     virtual
     ~MultiResult_i();
 
@@ -84,11 +86,10 @@ namespace VISU
 
 
     typedef std::string TPartName;
-    typedef std::vector<TPartName> TParts;
+    typedef std::vector<TPartName> TPartNames;
 
     typedef size_t TPartID;
     typedef std::string TPath;
-    typedef std::string TFileName;
     typedef std::string TMeshName;
 
     struct TPartInfo
@@ -110,14 +111,14 @@ namespace VISU
     typedef std::set<std::string> TRepresentationKey;
     typedef std::map<TRepresentationKey, PInput> TRepresentation2Input;
 
-    typedef std::set<TPartName> TSubParts;
-    typedef std::map<TPartName, TSubParts> TMainPart2SubParts;
+    typedef std::set<TPartName> TSubPartNames;
+    typedef std::map<TPartName, TSubPartNames> TMainPart2SubPartNames;
 
   private:
     multipr::Obj myMultiprObj;
     TPartName2FileName myPartName2FileName;
     TPartName2Resolution myPartName2Resolution;
-    TMainPart2SubParts myMainPart2SubParts;
+    TMainPart2SubPartNames myMainPart2SubPartNames;
 
     TRepresentation2Input myRepresentation2Input;
 
@@ -147,6 +148,16 @@ namespace VISU
            const std::string& thePrefix,
            CORBA::Boolean theIsMultiFile);
 
+    //---------------------------------------------------------------
+    virtual 
+    bool
+    Save(SALOMEDS::SComponent_ptr theComponent,
+        const std::string& theURL,
+        bool theIsMultiFile,
+        TFileNames& theFileNames,
+        TFileNames& theFullFileNames,
+        TFileNames& theTemporaryDirs);
+
     virtual
     void
     ToStream(std::ostringstream& theStr);
index 6419d111df1bd8f63e031e60a39a7d24e2fc58b2..969772a74f77d7e5064e10c6b7631774ed97a940 100644 (file)
@@ -50,8 +50,19 @@ class vtkDataSet;
 
 namespace VISU
 {
+  //----------------------------------------------------------------------------
   class Result_i;
 
+
+  //----------------------------------------------------------------------------
+  struct TResultObserver: public virtual boost::signalslib::trackable
+  {
+    virtual
+    void
+    UpdateFromResult(Result_i* theResult) = 0;
+  };
+
+
   //----------------------------------------------------------------------------
   //! Base class for all VTK 3D presentations.
   /*!
@@ -63,11 +74,10 @@ namespace VISU
     - implement basic actor management (CreateActor, UpdateActor, UpdateActors, RemoveActor and RemoveActors);
     - implement common 3D functionality like "clipping planes" and offset.
   */
-  class VISU_I_EXPORT Prs3d_i :
-    public virtual POA_VISU::Prs3d,
-    public virtual SALOME::GenericObj_i,
-    public virtual TActorFactory,
-    public virtual PrsObject_i
+  class VISU_I_EXPORT Prs3d_i : public virtual POA_VISU::Prs3d,
+                               public virtual SALOME::GenericObj_i,
+                               public virtual TActorFactory,
+                               public virtual PrsObject_i
 
   {
     Prs3d_i(const Prs3d_i&);
index 61236dda27408b63658f9d1abac91aa682347765..ff1b63f8e6e9e23a2faa40c00e8335f7269c3cbc 100644 (file)
@@ -26,6 +26,7 @@
 
 #include "VISU_MultiResult_i.hh"
 #include "VISU_ResultUtils.hh"
+#include "VISU_Prs3d_i.hh"
 
 #include "VISU_Convertor_impl.hxx"
 #include "VISU_CorbaMedConvertor.hxx"
 // OCCT Includes
 #include <Bnd_Box.hxx>
 
+#include <boost/filesystem/path.hpp>
+#include <boost/filesystem/operations.hpp>
+namespace filesystem = boost::filesystem;
+
 
 #ifdef _DEBUG_
 static int MYDEBUG = 1;
@@ -139,13 +144,13 @@ const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
 
 //---------------------------------------------------------------
 VISU::Result_i
-::Result_i (SALOMEDS::Study_ptr theStudy,
-           const ESourceId& theSourceId,
-           const ECreationId& theCreationId,
-           CORBA::Boolean theIsBuildImmediately,
-           CORBA::Boolean theIsBuildFields,
-           CORBA::Boolean theIsBuildMinMax,
-           CORBA::Boolean theIsBuildGroups):
+::Result_i(SALOMEDS::Study_ptr theStudy,
+          const ESourceId& theSourceId,
+          const ECreationId& theCreationId,
+          CORBA::Boolean theIsBuildImmediately,
+          CORBA::Boolean theIsBuildFields,
+          CORBA::Boolean theIsBuildMinMax,
+          CORBA::Boolean theIsBuildGroups):
   myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
   myCreationId(theCreationId),
   mySourceId(theSourceId),
@@ -165,6 +170,12 @@ VISU::Result_i
 }
 
 
+//---------------------------------------------------------------
+VISU::Result_i
+::Result_i()
+{}
+
+
 //---------------------------------------------------------------
 void
 VISU::Result_i
@@ -481,8 +492,8 @@ VISU::Result_i
 
 //---------------------------------------------------------------
 VISU::Storable*
-VISU::Result_i::
-Create(const char* theFileName)
+VISU::Result_i
+::Create(const char* theFileName)
 {      
   try {
     myFileInfo.setFile(theFileName);
@@ -585,25 +596,29 @@ VISU::Result_i
 bool
 VISU::Result_i
 ::Save(SALOMEDS::SComponent_ptr theComponent,
-       const char* theTmpDir,
+       const std::string& theURL,
        bool theIsMultiFile,
-       std::string& theFileName,
-       std::string& theFilePath)
+       TFileNames& theFileNames,
+       TFileNames& theFullFileNames,
+       TFileNames& theTemporaryDirs)
 {
   switch(GetCreationId()){
   case Result_i::eImportFile:
   case Result_i::eCopyAndImportFile: {
-    theFileName = std::string("_") + GetName();
-    theFilePath = GetFileInfo().filePath().latin1();
+    filesystem::path aFileName = std::string("_") + GetName();
+    filesystem::path aFilePath = GetFileInfo().filePath().latin1();
     if(theIsMultiFile){
       CORBA::String_var anURL = GetStudyDocument()->URL();
-      theFileName = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + theFileName;
-
-      std::ostringstream aCommand;
-      aCommand<<COPY_COMMAND<<theFilePath<<" "<<theTmpDir<<theFileName;
-      if(system(aCommand.str().c_str()) != 0)
+      aFilePath = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + aFilePath.string();
+      filesystem::path aPathToCopy = filesystem::path(theURL) / aFileName;
+      filesystem::copy_file(aFilePath, aPathToCopy);
+      if(!filesystem::exists(aPathToCopy))
        return false;
     }
+    if(MYDEBUG) MESSAGE("Result_i::Save - aFileName  ='"<<aFileName.string()
+                       <<"'; aFilePath = '"<<aFilePath.string()<<"'\n");
+    theFileNames.push_back(aFileName.string());
+    theFullFileNames.push_back(aFilePath.string());
     return true;
   }}
 
@@ -712,10 +727,23 @@ VISU::Result_i
          CORBA::Boolean theIsMultiFile)
 {
   if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
+  mySObject = SALOMEDS::SObject::_duplicate(theSObject);
+  mySComponent = mySObject->GetFatherComponent();
+  myStudyDocument = theSObject->GetStudy();
+
+  myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
+  mySourceId = eRestoredFile;
+  if(myCreationId == eImportMed || myCreationId == eImportMedField)
+    mySourceId = eRestoredComponent;
+
+  myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt();
+  myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt();
+  myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt();
+  myIsBuildParts = Storable::FindValue(theMap, "myIsBuildParts", "0").toInt();
+
+  myIsBuildImmediately = true;
+
   try {
-    mySObject = SALOMEDS::SObject::_duplicate(theSObject);
-    myStudyDocument = mySObject->GetStudy();
-    mySComponent = mySObject->GetFatherComponent();
     myName = VISU::Storable::FindValue(theMap, "myName").latin1();
     SetFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1());
     
@@ -1279,27 +1307,7 @@ VISU::Result_i
                 const std::string& thePrefix,
                 CORBA::Boolean theIsMultiFile)
 {
-  SALOMEDS::Study_var aStudy = theSObject->GetStudy();
-
-  ECreationId aCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
-  ESourceId aSourceId = eRestoredFile;
-  if(aCreationId == eImportMed || aCreationId == eImportMedField)
-    aSourceId = eRestoredComponent;
-
-  CORBA::Boolean anIsBuildFields = Storable::FindValue(theMap,"myIsBuildFields","1").toInt();
-  CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","1").toInt();
-  CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","1").toInt();
-
-  VISU::Result_i* aResult = new RESULT_CLASS_NAME(aStudy,
-                                                 aSourceId,
-                                                 aCreationId,
-                                                 true,
-                                                 anIsBuildFields,
-                                                 anIsBuildMinMax,
-                                                 anIsBuildGroups);
-  if (aResult == NULL)
-    return NULL;
-
+  VISU::Result_i* aResult = new RESULT_CLASS_NAME();
   return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
 }
 
@@ -1310,12 +1318,13 @@ VISU::Result_i
 ::ToStream(std::ostringstream& theStr)
 {
   if(MYDEBUG) MESSAGE(GetComment());
-  Storable::DataToStream(theStr,"myName",myName.c_str());
-  Storable::DataToStream(theStr,"myInitFileName",GetFileName().c_str());
-  Storable::DataToStream(theStr,"myCreationId",myCreationId);
-  Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone);
-  Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone);
-  Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone);
+  Storable::DataToStream(theStr,"myName", myName.c_str());
+  Storable::DataToStream(theStr,"myInitFileName", GetFileName().c_str());
+  Storable::DataToStream(theStr,"myCreationId", myCreationId);
+  Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
+  Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
+  Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
+  Storable::DataToStream(theStr,"myIsBuildParts", myIsBuildParts);
 }
 
 
index 7f2e8962d5117d70970a4d8f2fa8b6bdcedc972b..9b278f271ce56c4c328a02dd5230c4b046f0e9ac 100644 (file)
@@ -44,16 +44,7 @@ class VISU_Convertor;
 namespace VISU
 {
   //----------------------------------------------------------------------------
-  class Result_i;
-
-
-  //----------------------------------------------------------------------------
-  struct TResultObserver: public virtual boost::signalslib::trackable
-  {
-    virtual
-    void
-    UpdateFromResult(Result_i* theResult) = 0;
-  };
+  class TResultObserver;
 
 
   //----------------------------------------------------------------------------
@@ -72,10 +63,10 @@ namespace VISU
     New(SALOMEDS::Study_ptr theStudy,
        const ESourceId& theSourceId,
        const ECreationId& theCreationId,
-       CORBA::Boolean theIsBuildImmediately = true,
-       CORBA::Boolean theIsBuildFields = true,
-       CORBA::Boolean theIsBuildMinMax = true,
-       CORBA::Boolean theIsBuildGroups = true);
+       CORBA::Boolean theIsBuildImmediately,
+       CORBA::Boolean theIsBuildFields,
+       CORBA::Boolean theIsBuildMinMax,
+       CORBA::Boolean theIsBuildGroups);
     
     virtual
     void
@@ -211,10 +202,12 @@ namespace VISU
     Result_i(SALOMEDS::Study_ptr theStudy,
             const ESourceId& theSourceId,
             const ECreationId& theCreationId,
-            CORBA::Boolean theIsBuildImmediately = true,
-            CORBA::Boolean theIsBuildFields = true,
-            CORBA::Boolean theIsBuildMinMax = true,
-            CORBA::Boolean theIsBuildGroups = true);
+            CORBA::Boolean theIsBuildImmediately,
+            CORBA::Boolean theIsBuildFields,
+            CORBA::Boolean theIsBuildMinMax,
+            CORBA::Boolean theIsBuildGroups);
+
+    Result_i();
 
     virtual
     ~Result_i();
@@ -291,13 +284,17 @@ namespace VISU
     ToStream(std::ostringstream& theStr);
 
     //---------------------------------------------------------------
+    typedef std::string TFileName;
+    typedef std::vector<TFileName> TFileNames;
+
     virtual 
     bool
     Save(SALOMEDS::SComponent_ptr theComponent,
-        const char* theURL,
+        const std::string& theURL,
         bool theIsMultiFile,
-        std::string& theFileName,
-        std::string& theFilePath);
+        TFileNames& theFileNames,
+        TFileNames& theFullFileNames,
+        TFileNames& theTemporaryDirs);
 
     virtual 
     bool