From 4264181864c7f4b6b425ef8ef0029c56cf446fc2 Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Wed, 21 Sep 2022 16:36:10 +0200 Subject: [PATCH] cout replaced by MESSAGE + clean up --- src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx | 8 ++++---- src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx | 12 ------------ src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx | 11 +++++------ src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx | 11 ++++++----- 4 files changed, 15 insertions(+), 27 deletions(-) diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index 1d17270..73552cb 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -354,8 +354,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh, + output_mesh_file.string() + " >> " + log_file.string(); - std::cout << "Running command: " << std::endl; - std::cout << cmd << std::endl; + MESSAGE("Running command: "); + MESSAGE(cmd); // Writing command in log std::ofstream flog(log_file.string()); @@ -410,8 +410,8 @@ bool NETGENPlugin_NETGEN_2D_ONLY::RemoteCompute(SMESH_Mesh& aMesh, } } if(nodeVec.at(nodeIndex) == nullptr){ - std::cout << "Error could not identify id"; - return false; + std::cerr << "Error could not identify id"; + return true; } } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx index ed8ce44..6984a20 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D.cxx @@ -627,8 +627,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, vector< const SMDS_MeshNode* >& nodeVec, NETGENPlugin_NetgenLibWrapper& ngLib) { - auto time0 = std::chrono::high_resolution_clock::now(); - netgen::multithread.terminate = 0; netgen::Mesh* ngMesh = ngLib._ngMesh; @@ -691,7 +689,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, try { OCC_CATCH_SIGNALS; - auto time0 = std::chrono::high_resolution_clock::now(); ngLib.CalcLocalH(ngMesh); err = ngLib.GenerateMesh(occgeo, startWith, endWith); @@ -725,9 +722,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, str << " at " << netgen::multithread.task; error(str); } - auto time1 = std::chrono::high_resolution_clock::now(); - auto elapsed = std::chrono::duration_cast(time1-time0); - std::cout << "Time for seq:compute: " << elapsed.count() * 1e-9 << std::endl; int Netgen_NbOfNodesNew = Ng_GetNP(Netgen_mesh); int Netgen_NbOfTetra = Ng_GetNE(Netgen_mesh); @@ -774,10 +768,6 @@ bool NETGENPlugin_NETGEN_3D::compute(SMESH_Mesh& aMesh, } } } - auto time2 = std::chrono::high_resolution_clock::now(); - elapsed = std::chrono::duration_cast(time2-time1); - std::cout << "Time for seq:compute: " << elapsed.count() * 1e-9 << std::endl; - return !err; } @@ -903,14 +893,12 @@ double NETGENPlugin_NETGEN_3D::GetProgress() const strncmp( netgen::multithread.task, volMeshing, 3 ) == 0 )) { res = 0.001 + meshingRatio * netgen::multithread.percent / 100.; - //cout << netgen::multithread.task << " " <<_progressTic << "-" << netgen::multithread.percent << endl; } else // different otimizations { if ( _progressByTic < 0. ) ((NETGENPlugin_NETGEN_3D*)this)->_progressByTic = meshingRatio / _progressTic; res = _progressByTic * _progressTic; - //cout << netgen::multithread.task << " " << _progressTic << " " << res << endl; } return Min ( res, 0.98 ); } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx index 3729fc5..dc70cf4 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx @@ -226,7 +226,6 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, //Writing hypo netgen_params aParams; - std::cout << _hypParameters << std::endl; fillParameters(_hypParameters, aParams); exportNetgenParams(param_file.string(), aParams); @@ -258,8 +257,8 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, flog << cmd << endl; flog << endl; } - //std::cout << "Running command: " << std::endl; - //std::cout << cmd << std::endl; + MESSAGE("Running command: "); + MESSAGE(cmd); // Building arguments for QProcess @@ -283,9 +282,9 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, if(ret != 0){ // Run crahed - std::cout << "Issue with command: " << std::endl; - std::cout << "See log for more details: " << log_file.string() << std::endl; - std::cout << cmd << std::endl; + std::cerr << "Issue with command: " << std::endl; + std::cerr << "See log for more details: " << log_file.string() << std::endl; + std::cerr << cmd << std::endl; return false; } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx index da00345..3953896 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.cxx @@ -214,19 +214,20 @@ int NETGENPlugin_NETGEN_3D_SA::run(const std::string input_mesh_file, // Setting number of threads for netgen myParams.nbThreads = nbThreads; - std::cout << "Meshing with netgen3d" << std::endl; + MESSAGE("Meshing with netgen3d"); int ret = Compute(myShape, *myMesh, myParams, new_element_file, element_orientation_file, !output_mesh_file.empty()); if(ret){ - std::cout << "Meshing failed" << std::endl; + std::cerr << "Meshing failed" << std::endl; return ret; } if(!output_mesh_file.empty()){ - exportMesh(output_mesh_file, *myMesh, mesh_name); + std::string meshName = "MESH"; + exportMesh(output_mesh_file, *myMesh, meshName); } return ret; @@ -250,7 +251,7 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements( { // Setting all element orientation to false if there no element orientation file if(_element_orientation_file.empty()){ - std::cout << "No element orientation file" << std::endl; + MESSAGE("No element orientation file"); SMDS_ElemIteratorPtr iteratorElem = meshDS->elementsIterator(SMDSAbs_Face); while ( iteratorElem->more() ) // loop on elements on a geom face @@ -260,7 +261,7 @@ bool NETGENPlugin_NETGEN_3D_SA::getSurfaceElements( elemOrientation[elem->GetID()] = false; } } else { - std::cout << "Reading from elements from file: " << _element_orientation_file << std::endl; + MESSAGE("Reading from elements from file: " << _element_orientation_file); std::ifstream df(_element_orientation_file, ios::binary|ios::in); int nbElement; bool orient; -- 2.39.2