}
+ //----------------------------------------------------------------------------
+ SALOMEDS::ListOfFileNames*
+ GetListOfFileNames(const Result_i::TFileNames& theFileNames)
+ {
+ SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
+ if(!theFileNames.empty()){
+ aListOfFileNames->length(theFileNames.size());
+ for(int aCounter = theFileNames.size(); aCounter > 0; aCounter--)
+ aListOfFileNames[aCounter-1] = theFileNames[aCounter-1].c_str();
+ }
+ return aListOfFileNames._retn();
+ }
+
+
//----------------------------------------------------------------------------
VISU_Gen_i
::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
aResult->Save(theComponent,
theURL,
- theIsMultiFile,
+ theIsMultiFile,
+ false,
aFileNames,
aFiles);
}
}
-
if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<<aFileNames.size());
- SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
- if(!aFileNames.empty()){
- aListOfFileNames->length(aFileNames.size());
- for(int aCounter = aFileNames.size(); aCounter > 0; aCounter--)
- aListOfFileNames[aCounter-1] = aFileNames[aCounter-1].c_str();
- }
-
- SALOMEDS::ListOfFileNames_var aListOfFiles = new SALOMEDS::ListOfFileNames;
- if(!aFiles.empty()){
- aListOfFiles->length(aFiles.size());
- for(int aCounter = aFiles.size(); aCounter > 0; aCounter--)
- aListOfFiles[aCounter-1] = aFiles[aCounter-1].c_str();
- }
-
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
+ if(aFileNames.empty())
+ return aStreamFile._retn();
+
+ SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
+ SALOMEDS::ListOfFileNames_var aListOfFiles = GetListOfFileNames(aFiles);
+
if(theIsMultiFile)
aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFiles.in(), theIsMultiFile);
else
SALOMEDS::TMPFile*
VISU_Gen_i
::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
- const char* theTmpDir,
+ const char* theURL,
bool theIsMultiFile)
{
- std::string aTmpDir = theIsMultiFile ? theTmpDir : SALOMEDS_Tool::GetTmpDir();
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - "<<aTmpDir);
- int aCounter = 0;
- TColStd_SequenceOfAsciiString aFileNames;
+ std::string anURL = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - "<<anURL);
+
+ Result_i::TFileNames aFileNames;
+ Result_i::TFileNames aFiles;
+
SALOMEDS::Study_var aStudy = theComponent->GetStudy();
SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
for (; anIter->More(); anIter->Next()) {
- SALOMEDS::SObject_var gotBranch = anIter->Value();
- CORBA::Object_var anObj = SObjectToObject(gotBranch);
- if(CORBA::is_nil(anObj))
- continue;
+ 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;
- if(aResult->SaveASCII(theComponent, aTmpDir, theIsMultiFile, aFileName)){
- TCollection_AsciiString aString(const_cast<char*>(aFileName.c_str()));
- aFileNames.Append(aString);
- }
+ aResult->Save(theComponent,
+ anURL,
+ theIsMultiFile,
+ true,
+ aFileNames,
+ aFiles);
}
}
+ if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - aFileNames.size() - "<<aFileNames.size());
+
SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
- if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.Length() - "<<aFileNames.Length());
- if(aFileNames.Length() > 0){
- SALOMEDS::ListOfFileNames_var aSeq = new SALOMEDS::ListOfFileNames;
- aSeq->length(aFileNames.Length());
- for(aCounter = aFileNames.Length(); aCounter > 0; aCounter--)
- aSeq[aCounter-1] = CORBA::string_dup(aFileNames.Value(aCounter).ToCString());
- aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aSeq.in(), theIsMultiFile);
- if(!theIsMultiFile)
- SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aSeq.in(), true);
- }
+ if(aFileNames.empty())
+ return aStreamFile._retn();
+
+ SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
+ aStreamFile = SALOMEDS_Tool::PutFilesToStream(anURL, aListOfFileNames.in(), theIsMultiFile);
+
+ if(!theIsMultiFile)
+ SALOMEDS_Tool::RemoveTemporaryFiles(anURL, aListOfFileNames, true);
+
return aStreamFile._retn();
}
#include "MULTIPR_API.hxx"
#include "SALOMEDS_Tool.hxx"
+#include "HDFascii.hxx"
#include <boost/thread/thread.hpp>
#include <boost/bind.hpp>
::Save(SALOMEDS::SComponent_ptr theComponent,
const std::string& theURL,
bool theIsMultiFile,
+ bool theIsASCII,
TFileNames& theFileNames,
TFileNames& theFiles)
{
- INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<<this<<"\n");
-
bool anIsDone = Result_i::Save(theComponent,
theURL,
- theIsMultiFile,
+ theIsMultiFile,
+ theIsASCII,
theFileNames,
theFiles);
if(!anIsDone)
if(!myMultiprObj.isValidDistributedMEDFile())
return true;
+ INITMSG(MYDEBUG, "MultiResult_i::Save - this = "<<this<<"\n");
+ INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
+
// To generate an unique prefix for the set of multi sub files
std::string aPrefix;
if (theIsMultiFile) {
aFileName = aFileName + aSuffix;
INITMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
- if(theIsMultiFile){
- std::string aPathToCopy(theURL + aFileName);
- BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+ std::string aPathToCopy(theURL + aFileName);
+ BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+
+ if(theIsMultiFile)
if(!VISU::CopyFile(aFile, aPathToCopy))
return false;
- }
- if(!theIsMultiFile)
- theFileNames.push_back(aFileName);
+ if(theIsMultiFile || theIsASCII)
+ HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+ theFileNames.push_back(aFileName);
theFiles.push_back(aFile);
}
{
std::string aBase, aSuffix;
SplitName(GetName(), aBase, aSuffix);
- BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
+ INITMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
QFileInfo aFileInfo(myMultiprObj.getSequentialMEDFilename());
std::string aFilePrefix = aFileInfo.baseName(TRUE).latin1();
std::string aBase, aSuffix;
SplitName(GetName(), aBase, aSuffix);
- BEGMSG(MYDEBUG, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
+ INITMSGA(MYDEBUG, 0, "aBase = '"<<aBase<<"'; aSuffix = '"<<aSuffix<<"'\n");
std::string aSourceFileName = GetFileInfo().absFilePath().latin1();
BEGMSG(MYDEBUG, "aSourceFileName = '"<<aSourceFileName<<"'\n");
}
}
int aRes = multipr::merge(aFileNames, theMeshName.c_str(), theFieldName.c_str(), aFileName.c_str());
- BEGMSG(MYDEBUG, "aRes = "<<aRes<<"\n");
+ INITMSGA(MYDEBUG, 0, "aRes = "<<aRes<<"\n");
if (aRes == 0) {
QFile(aFileName.c_str()).remove();
throw std::runtime_error("empty mesh");
Save(SALOMEDS::SComponent_ptr theComponent,
const std::string& theURL,
bool theIsMultiFile,
+ bool theIsASCII,
TFileNames& theFileNames,
- TFileNames& theFullFileNames);
+ TFileNames& theFiles);
virtual
void
::Save(SALOMEDS::SComponent_ptr theComponent,
const std::string& theURL,
bool theIsMultiFile,
+ bool theIsASCII,
TFileNames& theFileNames,
TFileNames& theFiles)
{
case Result_i::eImportFile:
case Result_i::eCopyAndImportFile: {
INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
+ INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
std::string aPrefix;
if (theIsMultiFile) {
std::string aFile = GetFileInfo().filePath().latin1();
BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
- if(theIsMultiFile){
- std::string aPathToCopy(theURL + aFileName);
- BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+ std::string aPathToCopy(theURL + aFileName);
+ BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
+
+ if(theIsMultiFile || theIsASCII)
if(!VISU::CopyFile(aFile, aPathToCopy))
return false;
- }
- if(!theIsMultiFile)
- theFileNames.push_back(aFileName);
+ if(theIsASCII)
+ HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
+ theFileNames.push_back(aFileName);
theFiles.push_back(aFile);
return true;
}
-//---------------------------------------------------------------
-bool
-VISU::Result_i
-::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
- const std::string& theTmpDir,
- bool theIsMultiFile,
- std::string& theFileName)
-{
- switch(GetCreationId()){
- case Result_i::eImportFile:
- case Result_i::eCopyAndImportFile: {
- std::string aPrefix;
- if (theIsMultiFile) {
- CORBA::String_var anURL = GetStudyDocument()->URL();
- aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
- }
- theFileName = aPrefix + "_" + GetName();
-
- QString aTmpDir = QDir::convertSeparators(theTmpDir.c_str());
- QString aCommand;
- aCommand.sprintf("%s %s%s",
- GetFileInfo().filePath().latin1(),
- aTmpDir.latin1(),
- theFileName.c_str());
- aCommand = QDir::convertSeparators( aCommand );
- aCommand.prepend( COPY_COMMAND );
-
- if(system(aCommand.latin1())){
- if(MYDEBUG) MESSAGE("Result_i::SaveASCII - Can't execute the command :"<<aCommand);
- return false;
- }else
- if(MYDEBUG) MESSAGE("Result_i::SaveASCII - "<<aCommand);
-
- QString aStudyPath = aTmpDir.append(theFileName.c_str());
- HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aStudyPath.latin1()), true);
- return true;
- }}
-
- return false;
-}
-
-
//---------------------------------------------------------------
CORBA::Boolean
VISU::Result_i
Save(SALOMEDS::SComponent_ptr theComponent,
const std::string& theURL,
bool theIsMultiFile,
+ bool theIsASCII,
TFileNames& theFileNames,
- TFileNames& theFullFileNames);
-
- virtual
- bool
- SaveASCII(SALOMEDS::SComponent_ptr theComponent,
- const std::string& theURL,
- bool theIsMultiFile,
- std::string& theFileName);
+ TFileNames& theFiles);
//---------------------------------------------------------------
virtual