}
-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;