Salome HOME
*** empty log message ***
[modules/multipr.git] / src / MULTIPR / MULTIPR_Obj.cxx
index 82cecfb6eaa893b320f66c201f3310ab3c42d061..30fd595ad34fdfa6adc532b73b4e0c14ee404355 100644 (file)
@@ -424,16 +424,29 @@ vector<string> Obj::getListParts() const
 }
 
 
-void Obj::save()
+void Obj::save(const char* pPath)
 {
-       // only save file if it is a distributed MED file currently in memory
-       if (mState == MULTIPR_OBJ_STATE_DIS_MEM)
+       static string prevPath = "";
+       
+       // only save file if it is a distributed MED file currently in memory or path has changed
+       if ((mState == MULTIPR_OBJ_STATE_DIS_MEM) || (strcmp(pPath, prevPath.c_str()) != 0))
        {
+               prevPath = pPath;
+               
                //-------------------------------------------------------------
                // Write new distributed mesh
                //-------------------------------------------------------------
-               string strPrefix = multipr::removeExtension(mMEDfilename.c_str(), ".med");
-               mMeshDis->writeDistributedMED(strPrefix.c_str());               
+               string filename;
+               if (strlen(pPath) == 0)
+               {
+                       filename = multipr::removeExtension(mMEDfilename.c_str(), ".med");
+               }
+               else
+               {
+                       filename = string(pPath) + string("/") + multipr::getFilenameWithoutPath(mMEDfilename.c_str());
+               }
+               string strPrefix = multipr::removeExtension(filename.c_str(), ".med");
+               mMeshDis->writeDistributedMED(strPrefix.c_str());
                mMEDfilename = mMeshDis->getFilename();
                
                cout << "Write MED master file: " << mMEDfilename << ": OK" << endl;