#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
-#include <qfileinfo.h>
-#include <qfile.h>
-#include <qdir.h>
-
#include <strstream>
#include <boost/filesystem/path.hpp>
namespace VISU
{
+ //---------------------------------------------------------------
+ class TSubString: public std::string
+ {
+ public:
+ typedef std::string::size_type size_type;
+
+ TSubString(std::string& theSource,
+ const std::string& theTarget):
+ mySource(theSource),
+ myPosition(theSource.find(theTarget)),
+ mySize(theTarget.length())
+ {}
+
+ TSubString&
+ operator = (const std::string& theTarget)
+ {
+ if(myPosition != std::string::npos)
+ mySource.replace(myPosition, mySize, theTarget);
+ return *this;
+ }
+
+ private:
+ std::string& mySource;
+ size_type myPosition;
+ size_type mySize;
+ };
+
+
+ //---------------------------------------------------------------
+ inline
+ std::ostream&
+ operator<<(std::ostream& theStream,
+ const MultiResult_i::TPartInfo& thePartInfo)
+ {
+ theStream<<(thePartInfo.myMeshName)<<" ";
+ theStream<<(thePartInfo.myPartID)<<" ";
+ theStream<<(thePartInfo.myName)<<" ";
+ theStream<<(thePartInfo.myPath)<<" ";
+ theStream<<(thePartInfo.myFileName);
+ return theStream;
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ std::istream&
+ operator>>(std::istream& theStream,
+ MultiResult_i::TPartInfo& thePartInfo)
+ {
+ theStream>>(thePartInfo.myMeshName);
+ theStream>>(thePartInfo.myPartID);
+ theStream>>(thePartInfo.myName);
+ theStream>>(thePartInfo.myPath);
+ theStream>>(thePartInfo.myFileName);
+ return theStream;
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ MultiResult_i::TPartInfo
+ GetPartInfo(const std::string theInfoString)
+ {
+ MultiResult_i::TPartInfo aPartInfo;
+ std::istrstream anOutputStream(theInfoString.c_str());
+ anOutputStream>>aPartInfo;
+ return aPartInfo;
+ }
+
+
+ //---------------------------------------------------------------
+ inline
+ MultiResult_i::TPartInfo
+ GetPartInfo(multipr::Obj& theMultiprObj,
+ const MultiResult_i::TPartName& thePartName)
+ {
+ return GetPartInfo(theMultiprObj.getPartInfo(thePartName.c_str()));
+ }
+
+
//---------------------------------------------------------------
inline
std::string
MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames,
CORBA::Boolean* theIsDone,
CORBA::Boolean theIsBuild,
- _PTR(Study) theStudy)
+ _PTR(Study) theStudy,
+ bool thePublishInStudy)
{
if(!theIsBuild || *theIsDone)
return;
TTransactionManager aTransactionManager(theStudy);
try {
- multipr::Obj& aMultiprObj = *theMultiprObj;
- const VISU::TMeshMap& aMeshMap = theInput->GetMeshMap();
- VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
- const VISU::PMesh& aMesh = aMeshMapIter->second;
-
- MultiResult_i::TPartNames aPartNames = aMultiprObj.getParts();
-
+ multipr::Obj& aMultiprObj = *theMultiprObj;
+ const VISU::TMeshMap& aMeshMap = theInput->GetMeshMap();
+ VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
+ const VISU::PMesh& aMesh = aMeshMapIter->second;
+
+ MultiResult_i::TPartNames aPartNames = aMultiprObj.getParts();
+
+ if(thePublishInStudy){
QString aComment = "Sub-parts: #";
aComment += QString::number(aPartNames.size());
NO_PERFSITENT_REF,
aComment.latin1(),
false);
+ }
+
+ MultiResult_i::TPartInfos& aPartInfos = *thePartInfos;
+ MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName;
+ MultiResult_i::TPartName2Resolution& aPartName2Resolution = *thePartName2Resolution;
+
+ MultiResult_i::TMainPart2SubPartNames& aMainPart2SubPartNames = *theMainPart2SubPartNames;
+
+ for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+ const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
+ MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName);
+ aMainPart2SubPartNames[aMainPart].insert(aPartName);
+ }
+
+ std::string aLastEntry;
+ for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+ const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(aMultiprObj, aPartName);
+
+ QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
+ aPartInfos[aFileInfo.fileName()] = aPartInfo;
- MultiResult_i::TPartInfos& aPartInfos = *thePartInfos;
- MultiResult_i::TPartName2FileName& aPartName2FileName = *thePartName2FileName;
- MultiResult_i::TPartName2Resolution& aPartName2Resolution = *thePartName2Resolution;
-
- MultiResult_i::TMainPart2SubPartNames& aMainPart2SubPartNames = *theMainPart2SubPartNames;
+ aPartName2FileName[aPartInfo.myName] = aPartInfo.myFileName;
- for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
- const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
- MultiResult_i::TPartName aMainPart = ExtractMainPart(aPartName);
- aMainPart2SubPartNames[aMainPart].insert(aPartName);
- }
+ if(!thePublishInStudy)
+ continue;
- std::string aLastEntry;
- 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;
- std::istrstream anOutputStream(aStringInfo.c_str());
- anOutputStream>>(aPartInfo.myMeshName);
- anOutputStream>>(aPartInfo.myPartID);
- anOutputStream>>(aPartInfo.myName);
- anOutputStream>>(aPartInfo.myPath);
- anOutputStream>>(aPartInfo.myFileName);
-
- QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
- aPartInfos[aFileInfo.fileName()] = aPartInfo;
-
- aPartName2FileName[aPartInfo.myName] = aPartInfo.myFileName;
-
- QString aComment = "";
- MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubPartNames, aPartInfo.myName);
- std::string aResoltutionsString = Resolutions2String(aResoltutions);
- if ( IsFullResolution(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,
- aMesh->myPartsEntry,
- anIconName,
- NO_IOR,
- aPartInfo.myName,
- NO_PERFSITENT_REF,
- aComment.latin1(),
- true);
- aPartName2Resolution[aPartInfo.myName] = aResolution;
- } else {
- aComment.sprintf("myComment=PART;myMeshName=%s;myFile=%s;myResolutions=%s",
- aPartInfo.myMeshName.c_str(), aPartInfo.myFileName.c_str(), aResoltutionsString.c_str());
- CreateAttributes(theStudy,
- aLastEntry,
- NO_ICON,
- NO_IOR,
- aPartInfo.myName,
- NO_PERFSITENT_REF,
- aComment.latin1(),
- true);
- }
+ QString aComment = "";
+ MultiResult_i::TResolutions aResoltutions = GetResolutions(aMainPart2SubPartNames, aPartInfo.myName);
+ std::string aResoltutionsString = Resolutions2String(aResoltutions);
+ if ( IsFullResolution(aPartInfo.myName) ) {
+ std::string anIconName = GetIconName(aMainPart2SubPartNames, aPartInfo.myName);
+ VISU::Result::Resolution aResolution = GetResolution(aMainPart2SubPartNames, aPartInfo.myName);
+ aComment.sprintf("myComment=PART;myMeshName=%s;myName=%s;myResolutions=%s;myState=%d",
+ aPartInfo.myMeshName.c_str(), aPartInfo.myName.c_str(), aResoltutionsString.c_str(), aResolution);
+ aLastEntry = CreateAttributes(theStudy,
+ aMesh->myPartsEntry,
+ anIconName,
+ NO_IOR,
+ aPartInfo.myName,
+ NO_PERFSITENT_REF,
+ aComment.latin1(),
+ true);
+ aPartName2Resolution[aPartInfo.myName] = aResolution;
+ } else {
+ aComment.sprintf("myComment=PART;myMeshName=%s;myName=%s;myResolutions=%s",
+ aPartInfo.myMeshName.c_str(), aPartInfo.myName.c_str(), aResoltutionsString.c_str());
+ CreateAttributes(theStudy,
+ aLastEntry,
+ NO_ICON,
+ NO_IOR,
+ aPartInfo.myName,
+ NO_PERFSITENT_REF,
+ aComment.latin1(),
+ true);
}
-
- *theIsDone = true;
+ }
+
+ *theIsDone = true;
}catch(std::exception& exc){
- INFOS("Follow exception was occured :\n"<<exc.what());
+ INFOS("Follow exception was occured :\n"<<exc.what());
}catch(...){
- INFOS("Unknown exception was occured!");
+ INFOS("Unknown exception was occured!");
}
ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(), theIsDone));
CORBA::Boolean* myIsDone;
CORBA::Boolean myIsBuild;
_PTR(Study) myStudy;
+ bool myPublishInStudy;
TBuildPartsArgs(Result_i* theResult,
Result_i::PInput theInput,
MultiResult_i::TMainPart2SubPartNames* theMainPart2SubPartNames,
CORBA::Boolean* theIsDone,
CORBA::Boolean theIsBuild,
- _PTR(Study) theStudy):
+ _PTR(Study) theStudy,
+ bool thePublishInStudy):
myResult(theResult),
myInput(theInput),
myMultiprObj(theMultiprObj),
myMainPart2SubPartNames(theMainPart2SubPartNames),
myIsDone(theIsDone),
myIsBuild(theIsBuild),
- myStudy(theStudy)
+ myStudy(theStudy),
+ myPublishInStudy(thePublishInStudy)
{}
};
theArgs.myMainPart2SubPartNames,
theArgs.myIsDone,
theArgs.myIsBuild,
- theArgs.myStudy);
+ theArgs.myStudy,
+ theArgs.myPublishInStudy);
}
&myMainPart2SubPartNames,
&myIsPartsDone,
myIsBuildParts,
- myStudy);
+ myStudy,
+ true);
}
return this;
&myMainPart2SubPartNames,
&myIsPartsDone,
myIsBuildParts,
- myStudy);
+ myStudy,
+ true);
boost::thread aThread(boost::bind(&BuildParts, anArgs));
}
const std::string& theURL,
bool theIsMultiFile,
TFileNames& theFileNames,
- TFileNames& theFullFileNames,
- TFileNames& theTemporaryDirs)
+ TFileNames& theFullFileNames)
{
+ INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<<this<<"\n");
+
bool anIsDone = Result_i::Save(theComponent,
theURL,
theIsMultiFile,
theFileNames,
- theFullFileNames,
- theTemporaryDirs);
+ theFullFileNames);
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());
+ // To generate an unique prefix for the set of multi sub files
+ std::string aPrefix;
+ if (theIsMultiFile) {
+ CORBA::String_var anURL = GetStudyDocument()->URL();
+ aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+ }
+
+ std::string aBase, aSuffix;
+ SplitName(GetName(), aBase, aSuffix);
+ BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
- myMultiprObj.savePersistent(aTmpDir.string().c_str());
+ aPrefix = aPrefix + "_" + aBase;
+ VISU::TSubString(aPrefix, ".med") = "";
+
+ BEGMSG(MYDEBUG, "aPrefix = '"<<aPrefix<<"'\n");
+
+ // To get a common prefix used in the multi file
+ QFileInfo aFileInfo(myMultiprObj.getSequentialMEDFilename());
+ std::string aFilePrefix = aFileInfo.baseName(TRUE).latin1();
- 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);
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
- cout<<"aPartInfo.myFileName = '"<<(aPartInfo.myFileName)<<endl;
- filesystem::path aFile(aPartInfo.myFileName);
- theFileNames.push_back(aFile.leaf());
- theFullFileNames.push_back(aFile.branch_path().string());
- }
+ QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
+ theFullFileNames.push_back(aFileInfo.absFilePath());
+ std::string aFileName = aFileInfo.fileName().latin1();
+ VISU::TSubString(aFileName, aFilePrefix) = aPrefix;
+ VISU::TSubString(aFileName, aSuffix) = "";
+ aFileName = aFileName + aSuffix;
+ INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
+ theFileNames.push_back(aFileName);
+ }
+
return true;
}
VISU::MultiResult_i
::ToStream(std::ostringstream& theStr)
{
+ INITMSG(MYDEBUG, "MultiResult_i::ToStream - this = "<<this<<"\n");
+
TSuperClass::ToStream(theStr);
- std::ostringstream aPartNames, aResolutions;
- TPartName2Resolution::const_iterator anIter = myPartName2Resolution.begin();
- for ( ; anIter != myPartName2Resolution.end() ; anIter++) {
- const TPartName& aPartName = anIter->first;
- aPartNames<<aPartName<<"|";
- const VISU::Result::Resolution& aResolution = anIter->second;
- aResolutions<<aResolution<<"|";
+ Storable::DataToStream(theStr,"myIsBuildParts", myIsPartsDone);
+ if(!myIsPartsDone)
+ return;
+
+ {
+ std::ostringstream aPartNames, aResolutions;
+ TPartName2Resolution::const_iterator anIter = myPartName2Resolution.begin();
+ for ( ; anIter != myPartName2Resolution.end() ; anIter++) {
+ const TPartName& aPartName = anIter->first;
+ aPartNames<<aPartName<<"|";
+ const VISU::Result::Resolution& aResolution = anIter->second;
+ aResolutions<<aResolution<<"|";
+ }
+
+ Storable::DataToStream(theStr, "myPartNames", aPartNames.str().c_str());
+ Storable::DataToStream(theStr, "myResolutions", aResolutions.str().c_str());
}
- Storable::DataToStream( theStr, "myPartNames", aPartNames.str().c_str());
- if(MYDEBUG) MESSAGE("MultiResult_i::ToStream - aPartNames = "<<aPartNames.str());
+ {
+ std::string aBase, aSuffix;
+ SplitName(GetName(), aBase, aSuffix);
+ BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
+
+ QFileInfo aFileInfo(myMultiprObj.getSequentialMEDFilename());
+ std::string aFilePrefix = aFileInfo.baseName(TRUE).latin1();
+ BEGMSG(MYDEBUG, "aFilePrefix = '"<<aFilePrefix<<"'\n");
+
+ std::ostringstream aPartInfos;
+ MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts();
+ for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+ const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
+
+ QFileInfo aFileInfo(aPartInfo.myFileName.c_str());
+ std::string aFileName = aFileInfo.fileName().latin1();
+ VISU::TSubString(aFileName, aFilePrefix + "_") = "";
+ aPartInfo.myFileName = aFileName + aSuffix;
+ aPartInfos<<aPartInfo<<"|";
+
+ INITMSG(MYDEBUG, "aFileName = '"<<aPartInfo.myFileName<<"'\n");
+ }
- Storable::DataToStream( theStr, "myResolutions", aResolutions.str().c_str());
- if(MYDEBUG) MESSAGE("MultiResult_i::ToStream - aResolutions = "<<aResolutions.str());
+ Storable::DataToStream(theStr, "myPartInfos", aPartInfos.str().c_str());
+ }
}
const std::string& thePrefix,
CORBA::Boolean theIsMultiFile)
{
+ INITMSG(MYDEBUG, "MultiResult_i::Restore - this = "<<this<<"\n");
+
if(!TSuperClass::Restore(theSObject, theMap, thePrefix, theIsMultiFile))
return NULL;
+ myIsBuildParts = Storable::FindValue(theMap, "myIsBuildParts", "0").toInt();
+ if(!myIsBuildParts)
+ return this;
+
QStringList aResolutions = QStringList::split("|", VISU::Storable::FindValue(theMap, "myResolutions"));
QStringList aPartNames = QStringList::split("|",VISU::Storable::FindValue(theMap, "myPartNames") );
for(size_t anId = 0, anEnd = aPartNames.size(); anId < anEnd; anId++){
const QString& aPartName = aPartNames[anId];
- const QString& aResolution = aResolutions[anId];
- if(MYDEBUG) MESSAGE("MultiResult_i::Restore - aPartName = '"<<aPartName<<"' = "<<aResolution);
- if(aResolution[0] == 'F')
- myPartName2Resolution[aPartName.latin1()] = VISU::Result::FULL;
- if(aResolution[0] == 'M')
- myPartName2Resolution[aPartName.latin1()] = VISU::Result::MEDIUM;
- if(aResolution[0] == 'L')
- myPartName2Resolution[aPartName.latin1()] = VISU::Result::LOW;
+ VISU::Result::Resolution aResolution = VISU::Result::Resolution(aResolutions[anId].toInt());
+ myPartName2Resolution[aPartName.latin1()] = aResolution;
+ INITMSG(MYDEBUG, "aPartName = '"<<aPartName<<"' = "<<aResolution<<"\n");
}
+ std::string aBase, aSuffix;
+ SplitName(GetName(), aBase, aSuffix);
+ BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
+
+ std::string aSourceFileName = GetFileInfo().absFilePath().latin1();
+ BEGMSG(MYDEBUG, "aSourceFileName = '"<<aSourceFileName<<"'\n");
+
+ std::string aPrefix = aSourceFileName;
+ VISU::TSubString(aPrefix, ".med") = "";
+ VISU::TSubString(aPrefix, aSuffix) = "";
+ BEGMSG(MYDEBUG, "aPrefix = '"<<aPrefix<<"'\n");
+
+ std::string aMultiFileName(aPrefix + "_grains_maitre.med" + aSuffix);
+ BEGMSG(MYDEBUG, "aMultiFileName = '"<<aMultiFileName<<"'\n");
+
+ {
+ std::ofstream aMultiFileStream(aMultiFileName.c_str());
+ aMultiFileStream<<"# MED file v2.3 - Master file created by VISU\n";
+ aMultiFileStream<<"#\n";
+ aMultiFileStream<<"# [SOURCE]="<<aSourceFileName<<"\n";
+ aMultiFileStream<<"#\n";
+
+ QStringList aPartInfos = QStringList::split("|", VISU::Storable::FindValue(theMap, "myPartInfos"));
+ aMultiFileStream<<aPartInfos.size()<<"\n";
+
+ for(size_t anId = 0, anEnd = aPartInfos.size(); anId < anEnd; anId++){
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(aPartInfos[anId].latin1());
+ aPartInfo.myFileName = aPrefix + "_" + aPartInfo.myFileName;
+ INITMSG(MYDEBUG, "aPartInfo.myFileName = '"<<aPartInfo.myFileName<<"'\n");
+ aMultiFileStream<<aPartInfo<<"\n";
+ }
+ }
+
+ {
+ myMultiprObj.create(aMultiFileName.c_str());
+ BuildParts(this,
+ GetInput(),
+ &myMultiprObj,
+ &myPartInfos,
+ &myPartName2FileName,
+ &myPartName2Resolution,
+ &myMainPart2SubPartNames,
+ &myIsPartsDone,
+ myIsBuildParts,
+ myStudy,
+ false);
+ }
+
return this;
}
if(!IsFullResolution(aPartName))
continue;
- std::string aStringInfo = myMultiprObj.getPartInfo(aPartName.c_str());
- std::istrstream anOutputStream(aStringInfo.c_str());
-
- TMeshName aMeshName;
- anOutputStream>>aMeshName;
- if(aMeshName == theMeshName)
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
+ if(aPartInfo.myMeshName == theMeshName)
aMeshParts.push_back(aPartName);
}
if(aMainPart != thePartName)
continue;
- std::string aStringInfo = myMultiprObj.getPartInfo(aPartName.c_str());
- std::istrstream anOutputStream(aStringInfo.c_str());
-
- TMeshName aMeshName;
- anOutputStream>>aMeshName;
- if(aMeshName != theMeshName)
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
+ if(aPartInfo.myMeshName != theMeshName)
continue;
MultiResult_i::TResolutions aResolutions = VISU::GetResolutions(myMainPart2SubPartNames, thePartName);
if(aResolution == theResolution)
return;
- TPartName2FileName::iterator aFileNameIter = myPartName2FileName.find(thePartName);
- if(aFileNameIter == myPartName2FileName.end())
- return;
- const TFileName& aFileName = aFileNameIter->second;
-
VISU::Storable::TRestoringMap aRestoringMap;
aRestoringMap["myComment"] = "PART";
aRestoringMap["myMeshName"] = theMeshName;
- aRestoringMap["myFile"] = aFileName;
+ aRestoringMap["myName"] = thePartName;
const VISU::TMeshMap& aMeshMap = Result_i::GetInput()->GetMeshMap();
VISU::TMeshMap::const_iterator aMeshIter = aMeshMap.find(theMeshName);
if(aMeshIter == aMeshMap.end())
return;
- const VISU::PMesh& aMesh = aMeshIter->second;
- std::string aFatherEntry = Storable::FindEntry(GetStudyDocument(),
- aMesh->myPartsEntry,
- aRestoringMap);
-
+ std::string aFatherEntry;
+ const VISU::PMesh& aMesh = aMeshIter->second;
+ if(aMesh->myPartsEntry != "")
+ aFatherEntry = Storable::FindEntry(GetStudyDocument(),
+ aMesh->myPartsEntry,
+ aRestoringMap);
+ else
+ aFatherEntry = Result_i::GetEntry(aRestoringMap);
+
std::string anIconName = "ICON_MULTIPR_VIEW_HIDE";
if(theResolution == VISU::Result::FULL)
anIconName = "ICON_MULTIPR_VIEW_FULL";
std::ostrstream anOutputStream;
anOutputStream<<"myComment=PART;";
- anOutputStream<<"myFile="<<aFileName<<";";
+ anOutputStream<<"myName="<<thePartName<<";";
anOutputStream<<"myMeshName="<<theMeshName<<";";
anOutputStream<<"myResolutions="<<aRestoringMap["myResolutions"]<<";";
anOutputStream<<"myState="<<theResolution;
+ anOutputStream<<ends;
CreateAttributes(aStudy,
aFatherEntry,
VISU::MultiResult_i
::~MultiResult_i()
{
- if(MYDEBUG) MESSAGE("MultiResult_i::~MultiResult_i - this = "<<this<<": "<<myRepresentation2Input.size());
- TRepresentation2Input::iterator anIter = myRepresentation2Input.begin();
- for ( ; anIter != myRepresentation2Input.end() ; anIter++) {
- const PInput& anInput = anIter->second;
- std::string aFileName = anInput->GetName();
- if(MYDEBUG) MESSAGE("'"<<aFileName<<"'; ");
- QFileInfo aFileInfo(aFileName.c_str());
- QFile(aFileInfo.absFilePath()).remove();
- QDir().rmdir(aFileInfo.dirPath(TRUE));
+ INITMSG(MYDEBUG, "MultiResult_i::~MultiResult_i - this = "<<this<<"\n");
+ if(myIsBuildParts){
+ TRepresentation2Input::iterator anIter = myRepresentation2Input.begin();
+ for ( ; anIter != myRepresentation2Input.end() ; anIter++) {
+ const PInput& anInput = anIter->second;
+ std::string aFileName = anInput->GetName();
+ INITMSG(MYDEBUG, "RemoveFile - aFileName = '"<<aFileName<<"'\n");
+ VISU::RemoveFile(aFileName);
+ }
+ if (GetSourceId() == eRestoredFile) {
+ INITMSG(MYDEBUG, "RemoveFile - myMultiprObj.getMEDFilename = '"<<myMultiprObj.getMEDFilename()<<"'\n");
+ VISU::RemoveFile(myMultiprObj.getMEDFilename());
+ MultiResult_i::TPartNames aPartNames = myMultiprObj.getParts();
+ for (size_t aPartID = 0 ; aPartID < aPartNames.size() ; aPartID++) {
+ const MultiResult_i::TPartName& aPartName = aPartNames[aPartID];
+ MultiResult_i::TPartInfo aPartInfo = GetPartInfo(myMultiprObj, aPartName);
+ INITMSG(MYDEBUG, "RemoveFile - aPartInfo.myFileName = '"<<aPartInfo.myFileName<<"'\n");
+ VISU::RemoveFile(aPartInfo.myFileName);
+ }
+ }
}
}
TRepresentation2Input::iterator anIter = myRepresentation2Input.find(aRepresentationKey);
if(anIter == myRepresentation2Input.end()){
+ INITMSG(MYDEBUG, "MultiResult_i::GetInput - this = "<<this<<"\n");
std::string aFileName = SALOMEDS_Tool::GetTmpDir() + "tmp.med";
if(MYDEBUG){
- MESSAGE("MultiResult_i::GetInput - '"<<aFileName<<"': ");
+ INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"':\n");
TFileNames::const_iterator anIter = aFileNames.begin();
for ( ; anIter != aFileNames.end() ; anIter++) {
const MultiResult_i::TFileName& aFileName = *anIter;
- MESSAGE("'"<<aFileName<<"'; ");
+ INITMSG(MYDEBUG, "'"<<aFileName<<"'\n");
}
}
int aRes = multipr::merge(aFileNames, theMeshName.c_str(), theFieldName.c_str(), aFileName.c_str());
- if(MYDEBUG) MESSAGE("aRes = "<<aRes);
+ BEGMSG(MYDEBUG, "aRes = "<<aRes<<"\n");
if (aRes == 0) {
QFile(aFileName.c_str()).remove();
throw std::runtime_error("empty mesh");
//---------------------------------------------------------------
VISU::Result_i
-::Result_i()
+::Result_i():
+ myIsEntitiesDone(false),
+ myIsFieldsDone(false),
+ myIsGroupsDone(false),
+ myIsMinMaxDone(false),
+ myIsAllDone(false),
+ myIsBuildParts(false),
+ myIsPartsDone(false)
{}
const std::string& theURL,
bool theIsMultiFile,
TFileNames& theFileNames,
- TFileNames& theFullFileNames,
- TFileNames& theTemporaryDirs)
+ TFileNames& theFullFileNames)
{
switch(GetCreationId()){
case Result_i::eImportFile:
case Result_i::eCopyAndImportFile: {
- filesystem::path aFileName = std::string("_") + GetName();
- filesystem::path aFilePath = GetFileInfo().filePath().latin1();
+ std::string aPrefix;
+ if (theIsMultiFile) {
+ CORBA::String_var anURL = GetStudyDocument()->URL();
+ aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+ }
+
+ std::string aFileName = aPrefix + "_" + GetName();
+ std::string aFilePath = GetFileInfo().filePath().latin1();
+
if(theIsMultiFile){
CORBA::String_var anURL = GetStudyDocument()->URL();
- aFilePath = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + aFilePath.string();
+ aFilePath = SALOMEDS_Tool::GetNameFromPath(anURL.in()) + aFilePath;
+
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());
+
+ if(MYDEBUG){
+ MESSAGE("Result_i::Save - aFileName ='"<<aFileName<<"'");
+ MESSAGE("Result_i::Save - aFilePath ='"<<aFileName<<"'");
+ }
+
+ theFileNames.push_back(aFileName);
+ theFullFileNames.push_back(aFilePath);
+
return true;
}}
mySObject = SALOMEDS::SObject::_duplicate(theSObject);
mySComponent = mySObject->GetFatherComponent();
myStudyDocument = theSObject->GetStudy();
+ myStudy = VISU::GetStudy(myStudyDocument);
myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
mySourceId = eRestoredFile;
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 {
myName = VISU::Storable::FindValue(theMap, "myName").latin1();
+ VISU::GenerateName(myName); // To register the name in global naming map
SetFileName(VISU::Storable::FindValue(theMap, "myInitFileName").latin1());
SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
- if (mySObject->FindSubObject(1, aRefSObj) &&
- aRefSObj->ReferencedObject(aTargetRefSObj))
- {
+ if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
} else {
myFileInfo.setFile(thePrefix.c_str());
- string aStudyPrefix ("");
- if (theIsMultiFile)
- aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL());
+ std::string aStudyPrefix ("");
+ if (theIsMultiFile) {
+ CORBA::String_var anURL(GetStudyDocument()->URL());
+ aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
+ }
if (!myFileInfo.isFile()) {
string aFileName = thePrefix + aStudyPrefix + "_" + myName;
myFileInfo.setFile(aFileName.c_str());
Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
- Storable::DataToStream(theStr,"myIsBuildParts", myIsBuildParts);
}
::~Result_i()
{
MESSAGE("Result_i::~Result_i() - this = "<<this);
- if (mySourceId == eRestoredFile) {
- static QString aCommand;
-#ifndef WNT
- aCommand.sprintf("rm %s",myFileInfo.filePath().latin1());
-#else
- aCommand.sprintf("del /F %s",myFileInfo.filePath().latin1());
-#endif
- int res = system(aCommand);
- MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<res);
-
-#ifndef WNT
- aCommand.sprintf("rmdir --ignore-fail-on-non-empty %s",myFileInfo.dirPath().latin1());
-#else
- aCommand.sprintf("del /F %s",myFileInfo.dirPath().latin1());
-#endif
-
- res = system(aCommand);
- MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<res);
+ if (GetSourceId() == eRestoredFile) {
+ VISU::RemoveFile(myFileInfo.filePath().latin1());
}
}