From: eap Date: Tue, 10 Sep 2013 13:41:19 +0000 (+0000) Subject: 22170: [CEA 704] Redirect NETGEN outup in a log file X-Git-Tag: V7_3_0a1~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5389785da839df275c0bada08cda03a0d7b6368;p=plugins%2Fnetgenplugin.git 22170: [CEA 704] Redirect NETGEN outup in a log file redirect cout-output to the file as well --- diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 5bbdc5b..86736d5 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -3592,13 +3592,17 @@ NETGENPlugin_NetgenLibWrapper::NETGENPlugin_NetgenLibWrapper() { Ng_Init(); + // redirect all netgen output (mycout,myerr,cout) to _outputFileName _isComputeOk = false; _outputFileName = getOutputFileName(); netgen::mycout = new ofstream ( _outputFileName.c_str() ); - netgen::myerr = netgen::mycout; + netgen::myerr = netgen::mycout; + _coutBuffer = std::cout.rdbuf(); #ifdef _DEBUG_ cout << "NOTE: netgen output is redirected to file " << _outputFileName << endl; #endif + std::cout.rdbuf( netgen::mycout->rdbuf() ); + _ngMesh = Ng_NewMesh(); } @@ -3613,6 +3617,7 @@ NETGENPlugin_NetgenLibWrapper::~NETGENPlugin_NetgenLibWrapper() Ng_DeleteMesh( _ngMesh ); Ng_Exit(); NETGENPlugin_Mesher::RemoveTmpFiles(); + std::cout.rdbuf( _coutBuffer ); #ifdef _DEBUG_ if( _isComputeOk ) #endif diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx index 1bf8b5b..41df61b 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx @@ -91,6 +91,8 @@ struct NETGENPLUGIN_EXPORT NETGENPlugin_NetgenLibWrapper std::string getOutputFileName(); void removeOutputFile(); std::string _outputFileName; + + std::streambuf* _coutBuffer; // to re-/store cout.rdbuf() }; //=============================================================================