#include <TopTools_MapOfShape.hxx>
#include <TopoDS.hxx>
+#include <Basics_Utils.hxx>
+
static void removeFile( const TCollection_AsciiString& fileName )
{
try {
TCollection_AsciiString aTmpDir;
char *Tmp_dir = getenv("SALOME_TMP_DIR");
+#ifdef WIN32
+ if(Tmp_dir == NULL) {
+ Tmp_dir = getenv("TEMP");
+ if( Tmp_dir== NULL )
+ Tmp_dir = getenv("TMP");
+#endif
+
if(Tmp_dir != NULL) {
aTmpDir = Tmp_dir;
- #ifdef WIN32
+#ifdef WIN32
if(aTmpDir.Value(aTmpDir.Length()) != '\\') aTmpDir+='\\';
#else
if(aTmpDir.Value(aTmpDir.Length()) != '/') aTmpDir+='/';
return aTmpDir;
}
+//=======================================================================
+//function : getSuffix
+//purpose : Returns a suffix that will be unique for the current process
+//=======================================================================
+
+static TCollection_AsciiString getSuffix()
+{
+ TCollection_AsciiString aSuffix = "";
+ aSuffix += "_";
+ aSuffix += getenv("USER");
+ aSuffix += "_";
+ aSuffix += Kernel_Utils::GetHostname().c_str();
+ aSuffix += "_";
+ aSuffix += getpid();
+
+ return aSuffix;
+}
+
//================================================================================
/*!
* \brief Returns a command to run Hexotic mesher
#endif
TCollection_AsciiString Hexotic_In(""), Hexotic_Out;
TCollection_AsciiString modeFile_In( "chmod 666 " ), modeFile_Out( "chmod 666 " );
- TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic.log"; // log
+ TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic"+getSuffix()+".log"; // log
std::map <int,int> aSmdsToHexoticIdMap;
std::map <int,const SMDS_MeshNode*> aHexoticIdToNodeMap;
- Hexotic_Out = aTmpDir + "Hexotic_Out.mesh";
+ Hexotic_Out = aTmpDir + "Hexotic"+getSuffix()+"_Out.mesh";
#ifdef WITH_BLSURFPLUGIN
bool defaultInputFile = true;
if (_blsurfHypo && !_blsurfHypo->GetQuadAllowed()) {
}
if (defaultInputFile) {
#endif
- Hexotic_In = aTmpDir + "Hexotic_In.mesh";
+ Hexotic_In = aTmpDir + "Hexotic"+getSuffix()+"_In.mesh";
removeHexoticFiles(Hexotic_In, Hexotic_Out);
cout << std::endl;
cout << "Creating Hexotic input mesh file : " << Hexotic_In << std::endl;
this,
#endif
meshDS, _nbShape, tabShape, tabBox );
- if(Ok)
+ if(Ok) {
/*********************
// TODO: Detect and remove elements in holes in case of sd mode = 4
// Remove previous nodes and elements
if (myError)
*/
hexahedraMessage = "success";
- else
+ removeFile(Hexotic_Out);
+ removeFile(Hexotic_In);
+ removeFile(aLogFileName);
+ }
+ else {
hexahedraMessage = "failed";
}
+ }
else {
hexahedraMessage = "failed";
cout << "Problem with Hexotic output file " << Hexotic_Out.ToCString() << std::endl;
TCollection_AsciiString aTmpDir = getTmpDir();
TCollection_AsciiString Hexotic_In, Hexotic_Out;
TCollection_AsciiString modeFile_In( "chmod 666 " ), modeFile_Out( "chmod 666 " );
- TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic.log"; // log
+ TCollection_AsciiString aLogFileName = aTmpDir + "Hexotic"+getSuffix()+".log"; // log
std::map <int,int> aSmdsToHexoticIdMap;
std::map <int,const SMDS_MeshNode*> aHexoticIdToNodeMap;
- Hexotic_In = aTmpDir + "Hexotic_In.mesh";
- Hexotic_Out = aTmpDir + "Hexotic_Out.mesh";
+ Hexotic_In = aTmpDir + "Hexotic"+getSuffix()+"_In.mesh";
+ Hexotic_Out = aTmpDir + "Hexotic"+getSuffix()+"_Out.mesh";
std::string run_Hexotic = getHexoticCommand(Hexotic_In, Hexotic_Out);
run_Hexotic += std::string(" 1 > ") + aLogFileName.ToCString(); // dump into file
if(_compute_canceled)
return error(SMESH_Comment("interruption initiated by user"));
#endif
+ removeFile(Hexotic_Out);
+ removeFile(Hexotic_In);
+ removeFile(aLogFileName);
return Ok;
/*
return myError->IsOK();
std::string HexoticPlugin_Hypothesis::GetDefaultHexoticWorkingDirectory()
{
- TCollection_AsciiString aTmpDir;
+ std::string aTmpDir;
char *Tmp_dir = getenv("SALOME_TMP_DIR");
- if(Tmp_dir != NULL) {
- aTmpDir = Tmp_dir;
+#ifdef WIN32
+ if(Tmp_dir == NULL) {
+ Tmp_dir = getenv("TEMP");
+ if( Tmp_dir== NULL )
+ Tmp_dir = getenv("TMP");
+ }
+#endif
+ if( Tmp_dir != NULL ) {
+ aTmpDir = std::string(Tmp_dir);
+#ifdef WIN32
+ if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\';
+#else
+ if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/';
+#endif
}
else {
#ifdef WIN32
- aTmpDir = TCollection_AsciiString("C:\\");
+ aTmpDir = "C:\\";
#else
- aTmpDir = TCollection_AsciiString("/tmp/");
+ aTmpDir = "/tmp/";
#endif
}
- return aTmpDir.ToCString();
+ return aTmpDir;
}
int HexoticPlugin_Hypothesis::GetDefaultHexoticSdMode()