Adding control of netgen log file

This commit is contained in:
Yoann Audouin 2022-10-03 16:15:33 +02:00
parent 61e4da3b0d
commit 3d82214289
3 changed files with 28 additions and 12 deletions

View File

@ -4437,18 +4437,7 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper():
_ngcerr = NULL;
if ( !getenv( "KEEP_NETGEN_OUTPUT" ))
{
// redirect all netgen output (mycout,myerr,cout) to _outputFileName
_outputFileName = getOutputFileName();
_ngcout = netgen::mycout;
_ngcerr = netgen::myerr;
netgen::mycout = new ofstream ( _outputFileName.c_str() );
netgen::myerr = netgen::mycout;
_coutBuffer = std::cout.rdbuf();
#ifdef _DEBUG_
std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
#else
std::cout.rdbuf( netgen::mycout->rdbuf() );
#endif
setOutputFile(getOutputFileName());
}
setMesh( Ng_NewMesh() );
@ -4569,6 +4558,27 @@ std::string NETGENPlugin_NetgenLibWrapper::getOutputFileName()
return aGenericName.ToCString();
}
//================================================================================
/*!
* \brief Set output file name for netgen log
*/
//================================================================================
void NETGENPlugin_NetgenLibWrapper::setOutputFile(std::string outputfile)
{
// redirect all netgen output (mycout,myerr,cout) to _outputFileName
_outputFileName = outputfile;
_ngcout = netgen::mycout;
_ngcerr = netgen::myerr;
netgen::mycout = new ofstream ( _outputFileName.c_str() );
netgen::myerr = netgen::mycout;
_coutBuffer = std::cout.rdbuf();
#ifdef _DEBUG_
std::cout << "NOTE: netgen output is redirected to file " << _outputFileName << std::endl;
#else
std::cout.rdbuf( netgen::mycout->rdbuf() );
#endif
}
//================================================================================
/*!

View File

@ -105,6 +105,7 @@ struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper
static void RemoveTmpFiles();
static int& instanceCounter();
void setOutputFile(std::string);
private:
std::string getOutputFileName();

View File

@ -202,6 +202,11 @@ bool NETGENPlugin_NETGEN_3D_SA::Compute(TopoDS_Shape &aShape, SMESH_Mesh& aMesh,
int endWith = netgen::MESHCONST_OPTVOLUME;
int Netgen_NbOfNodes=0;
// Changing netgen log_file putting it next to new_element_file
fs::path netgen_log_file = fs::path(new_element_file).remove_filename() / fs::path("NETGEN.out");
ngLib.setOutputFile(netgen_log_file.string());
NETGENPlugin_NETGEN_3D::computeFillNgMesh(aMesh, aShape, nodeVec, ngLib, helper, Netgen_NbOfNodes);
netgen::OCCGeometry occgeo;