mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-12 17:50:34 +05:00
Clean up of cout replaced by MESSAGE + minor corrections
This commit is contained in:
parent
ee7ca3d826
commit
a91b37ceb3
@ -25,6 +25,8 @@
|
||||
// Module : SMESH
|
||||
//
|
||||
|
||||
#include "utilities.h"
|
||||
|
||||
#include "SMESH_DriverMesh.hxx"
|
||||
|
||||
#include "SMESH_Mesh.hxx"
|
||||
@ -53,7 +55,8 @@ bool diffMEDFile(const std::string mesh_file1, const std::string mesh_file2, con
|
||||
}
|
||||
|
||||
std::string getMeshName(std::string mesh_file){
|
||||
std::unique_ptr<MEDFileUMesh> myMedMesh=MEDFileUMesh::New(mesh_file);
|
||||
// TODO: Memory leak but desctructor private check with AG
|
||||
MEDFileUMesh * myMedMesh = MEDFileUMesh::New(mesh_file);
|
||||
|
||||
return myMedMesh->getLevel0Mesh()->getName();
|
||||
}
|
||||
@ -70,7 +73,7 @@ std::string getMeshName(std::string mesh_file){
|
||||
int importMesh(const std::string mesh_file, SMESH_Mesh& aMesh){
|
||||
// TODO: change that as it depends on the language
|
||||
std::string mesh_name = getMeshName(mesh_file);
|
||||
std::cout << "Importing mesh from " << mesh_file << " mesh " << mesh_name2 << std::endl;
|
||||
MESSAGE("Importing mesh from " << mesh_file << " mesh " << mesh_name);
|
||||
int ret = aMesh.MEDToMesh(mesh_file.c_str(), mesh_name.c_str());
|
||||
return ret;
|
||||
}
|
||||
@ -86,8 +89,7 @@ int importMesh(const std::string mesh_file, SMESH_Mesh& aMesh){
|
||||
*/
|
||||
int exportMesh(const std::string mesh_file, SMESH_Mesh& aMesh, const std::string mesh_name){
|
||||
|
||||
// TODO: See how to get the name of the mesh. Is it usefull ?
|
||||
std::cout << "Exporting mesh to " << mesh_file << std::endl;
|
||||
MESSAGE("Exporting mesh to " << mesh_file);
|
||||
aMesh.ExportMED(mesh_file.c_str(), // theFile
|
||||
mesh_name.c_str(), // theMeshName
|
||||
false, // theAutoGroups
|
||||
|
@ -25,6 +25,7 @@
|
||||
// Module : SMESH
|
||||
//
|
||||
|
||||
#include <utilities.h>
|
||||
#include "SMESH_DriverShape.hxx"
|
||||
|
||||
// step include
|
||||
@ -53,22 +54,24 @@ namespace fs = boost::filesystem;
|
||||
*/
|
||||
int importSTEPShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||
|
||||
std::cout << "Importing STEP shape from " << shape_file << std::endl;
|
||||
MESSAGE("Importing STEP shape from " << shape_file);
|
||||
STEPControl_Reader reader;
|
||||
// Forcing Unit in meter
|
||||
Interface_Static::SetCVal("xstep.cascade.unit","M");
|
||||
Interface_Static::SetIVal("read.step.ideas", 1);
|
||||
Interface_Static::SetIVal("read.step.nonmanifold", 1);
|
||||
IFSelect_ReturnStatus aStat = reader.ReadFile(shape_file.c_str());
|
||||
if(aStat != IFSelect_RetDone)
|
||||
std::cout << "Reading error for " << shape_file << std::endl;
|
||||
if(aStat != IFSelect_RetDone){
|
||||
std::cerr << "Reading error for " << shape_file << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
int NbTrans = reader.TransferRoots();
|
||||
// There should be only one shape within the file
|
||||
assert(NbTrans==1);
|
||||
aShape = reader.OneShape();
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +84,7 @@ int importSTEPShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||
*/
|
||||
int exportSTEPShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||
|
||||
std::cout << "Exporting STEP shape to " << shape_file << std::endl;
|
||||
MESSAGE("Exporting STEP shape to " << shape_file);
|
||||
|
||||
STEPControl_Writer aWriter;
|
||||
// Forcing Unit in meter
|
||||
@ -90,14 +93,17 @@ int exportSTEPShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||
Interface_Static::SetIVal("write.step.nonmanifold", 1);
|
||||
|
||||
IFSelect_ReturnStatus aStat = aWriter.Transfer(aShape,STEPControl_AsIs);
|
||||
if(aStat != IFSelect_RetDone)
|
||||
std::cout << "Transfer error for " << shape_file << std::endl;
|
||||
if(aStat != IFSelect_RetDone){
|
||||
std::cerr << "Transfer error for " << shape_file << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
aStat = aWriter.Write(shape_file.c_str());
|
||||
|
||||
if(aStat != IFSelect_RetDone)
|
||||
std::cout << "Writing error for " << shape_file << std::endl;
|
||||
|
||||
if(aStat != IFSelect_RetDone){
|
||||
std::cerr << "Writing error for " << shape_file << std::endl;
|
||||
return true;
|
||||
}
|
||||
return aStat;
|
||||
}
|
||||
|
||||
@ -111,11 +117,11 @@ int exportSTEPShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||
*/
|
||||
int importBREPShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||
|
||||
std::cout << "Importing BREP shape from " << shape_file << std::endl;
|
||||
MESSAGE("Importing BREP shape from " << shape_file);
|
||||
BRep_Builder builder;
|
||||
BRepTools::Read(aShape, shape_file.c_str(), builder);
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -128,10 +134,10 @@ int importBREPShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||
*/
|
||||
int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||
|
||||
std::cout << "Exporting BREP shape to " << shape_file << std::endl;
|
||||
MESSAGE("Exporting BREP shape to " << shape_file);
|
||||
BRepTools::Write(aShape, shape_file.c_str());
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -150,8 +156,8 @@ int importShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||
} else if (type == ".step"){
|
||||
return importSTEPShape(shape_file, aShape);
|
||||
} else {
|
||||
std::cout << "Unknow format: " << type << std::endl;
|
||||
return false;
|
||||
std::cerr << "Unknow format: " << type << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -171,7 +177,7 @@ int exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||
} else if (type == ".step"){
|
||||
return exportSTEPShape(shape_file, aShape);
|
||||
} else {
|
||||
std::cout << "Unknow format: " << type << std::endl;
|
||||
return false;
|
||||
std::cerr << "Unknow format: " << type << std::endl;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -48,7 +48,6 @@
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#include "memoire.h"
|
||||
#include <chrono>
|
||||
#include <functional>
|
||||
|
||||
#ifdef WIN32
|
||||
@ -249,8 +248,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
|
||||
TopAbs_ShapeEnum previousShapeType = TopAbs_VERTEX;
|
||||
int nbThreads = aMesh.GetNbThreads();
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
std::cout << "Running mesh with threads: " << nbThreads << " mesher: " << aMesh.GetMesherNbThreads() << std::endl;
|
||||
MESSAGE("Running mesh with threads: " << nbThreads << " mesher: " << aMesh.GetMesherNbThreads());
|
||||
|
||||
|
||||
smIt = shapeSM->getDependsOnIterator(includeSelf, !complexShapeFirst);
|
||||
@ -267,7 +265,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
aMesh.SetNbThreads(0);
|
||||
else
|
||||
aMesh.SetNbThreads(nbThreads);
|
||||
//DEBUG std::cout << "Shape Type" << shapeType << " previous" << previousShapeType << std::endl;
|
||||
if ((aMesh.IsParallel()||nbThreads!=0) && shapeType != previousShapeType) {
|
||||
// Waiting for all threads for the previous type to end
|
||||
aMesh.wait();
|
||||
@ -312,8 +309,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
shapeSM, aShapeOnly, allowedSubShapes,
|
||||
aShapesId));
|
||||
} else {
|
||||
auto begin2 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
compute_function(1 ,smToCompute, computeEvent,
|
||||
shapeSM, aShapeOnly, allowedSubShapes,
|
||||
aShapesId);
|
||||
@ -333,13 +328,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
}
|
||||
|
||||
aMesh.GetMeshDS()->Modified();
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
|
||||
std::cout << "Time for All: " << elapsed.count()*1e-9 << std::endl;
|
||||
|
||||
// Pool of thread for computation
|
||||
if(aMesh.IsParallel())
|
||||
aMesh.DeletePoolThreads();
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -351,7 +339,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
// the most complex shapes and collect sub-meshes with algos that
|
||||
// DO support sub-meshes
|
||||
// ================================================================
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
list< SMESH_subMesh* > smWithAlgoSupportingSubmeshes[4]; // for each dim
|
||||
|
||||
// map to sort sm with same dim algos according to dim of
|
||||
@ -547,11 +534,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
continue;
|
||||
sm->SetAllowedSubShapes( fillAllowed( shapeSM, aShapeOnly, allowedSubShapes ));
|
||||
setCurrentSubMesh( sm );
|
||||
auto begin = std::chrono::high_resolution_clock::now();
|
||||
sm->ComputeStateEngine( computeEvent );
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
|
||||
std::cout << "Time for seq:alldim:compute: " << elapsed.count()*1e-9 << std::endl;
|
||||
|
||||
setCurrentSubMesh( NULL );
|
||||
sm->SetAllowedSubShapes( nullptr );
|
||||
@ -565,9 +548,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh & aMesh,
|
||||
// mesh the rest sub-shapes starting from vertices
|
||||
// -----------------------------------------------
|
||||
ret = Compute( aMesh, aShape, aFlags | UPWARD, aDim, aShapesId, allowedSubShapes );
|
||||
auto end = std::chrono::high_resolution_clock::now();
|
||||
auto elapsed = std::chrono::duration_cast<std::chrono::nanoseconds>(end - begin);
|
||||
std::cout << "Time for All: " << elapsed.count()*1e-9 << std::endl;
|
||||
|
||||
}
|
||||
|
||||
|
@ -174,13 +174,11 @@ namespace
|
||||
#ifndef WIN32
|
||||
void deleteMeshDS(SMESHDS_Mesh* meshDS)
|
||||
{
|
||||
//cout << "deleteMeshDS( " << meshDS << endl;
|
||||
delete meshDS;
|
||||
}
|
||||
#else
|
||||
static void* deleteMeshDS(void* meshDS)
|
||||
{
|
||||
//cout << "deleteMeshDS( " << meshDS << endl;
|
||||
SMESHDS_Mesh* m = (SMESHDS_Mesh*)meshDS;
|
||||
if(m) {
|
||||
delete m;
|
||||
@ -240,10 +238,12 @@ SMESH_Mesh::~SMESH_Mesh()
|
||||
pthread_t thread;
|
||||
int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS);
|
||||
#endif
|
||||
|
||||
//fs::remove_all(tmp_folder);
|
||||
|
||||
}
|
||||
|
||||
if(_pool)
|
||||
DeletePoolThreads();
|
||||
if (!MYDEBUG)
|
||||
fs::remove_all(tmp_folder);
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
@ -541,7 +541,7 @@ int SMESH_Mesh::MEDToMesh(const char* theFileName, const char* theMeshName)
|
||||
Driver_Mesh::Status status = myReader.Perform();
|
||||
#ifdef _DEBUG_
|
||||
SMESH_ComputeErrorPtr er = myReader.GetError();
|
||||
if ( er && !er->IsOK() ) std::cout << er->myComment << std::endl;
|
||||
if ( er && !er->IsOK() ) MESSAGE(er->myComment);
|
||||
#endif
|
||||
|
||||
// Reading groups (sub-meshes are out of scope of MED import functionality)
|
||||
@ -1770,7 +1770,6 @@ double SMESH_Mesh::GetComputeProgress() const
|
||||
rate = algo->GetProgressByTic();
|
||||
computedCost += algoDoneCost + rate * algoNotDoneCost;
|
||||
}
|
||||
// cout << "rate: "<<rate << " algoNotDoneCost: " << algoNotDoneCost << endl;
|
||||
}
|
||||
|
||||
// get cost of already treated sub-meshes
|
||||
@ -1791,9 +1790,6 @@ double SMESH_Mesh::GetComputeProgress() const
|
||||
}
|
||||
}
|
||||
}
|
||||
// cout << "Total: " << totalCost
|
||||
// << " computed: " << computedCost << " progress: " << computedCost / totalCost
|
||||
// << " nbElems: " << GetMeshDS()->GetMeshInfo().NbElements() << endl;
|
||||
return computedCost / totalCost;
|
||||
}
|
||||
|
||||
|
@ -3324,7 +3324,7 @@ double SMESH_MesherHelper::GetAngle( const TopoDS_Edge & theE1,
|
||||
if ( ++nbLoops > 10 )
|
||||
{
|
||||
#ifdef _DEBUG_
|
||||
cout << "SMESH_MesherHelper::GetAngle(): Captured in a sigularity" << endl;
|
||||
MESSAGE("SMESH_MesherHelper::GetAngle(): Captured in a singularity");
|
||||
#endif
|
||||
return angle;
|
||||
}
|
||||
@ -5588,8 +5588,5 @@ void SMESH_MesherHelper::WriteShape(const TopoDS_Shape& s)
|
||||
{
|
||||
const char* name = "/tmp/shape.brep";
|
||||
BRepTools::Write( s, name );
|
||||
#ifdef _DEBUG_
|
||||
std::cout << name << std::endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1583,7 +1583,7 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event)
|
||||
_computeError = SMESH_ComputeError::Worst( _computeError, algo->GetComputeError() );
|
||||
}
|
||||
catch ( ::SMESH_ComputeError& comperr ) {
|
||||
cout << " SMESH_ComputeError caught" << endl;
|
||||
MESSAGE(" SMESH_ComputeError caught");
|
||||
if ( !_computeError ) _computeError = SMESH_ComputeError::New();
|
||||
*_computeError = comperr;
|
||||
}
|
||||
|
@ -6645,8 +6645,6 @@ CORBA::Boolean SMESH_Gen_i::IsApplicable ( const char* theAlgoType,
|
||||
|
||||
SMESH_CATCH( SMESH::doNothing );
|
||||
|
||||
#ifdef _DEBUG_
|
||||
cout << "SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : "") << endl;
|
||||
#endif
|
||||
MESSAGE("SMESH_Gen_i::IsApplicable(): exception in " << ( theAlgoType ? theAlgoType : ""));
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user