From c56027a4a2806b9372c4a6b0eab3daa6510ebde2 Mon Sep 17 00:00:00 2001 From: cconopoima Date: Wed, 3 Jan 2024 12:47:10 +0000 Subject: [PATCH] [bos #38045][EDF] (2023-T3) suppress compilation warnings of new and refactored classes. Allow compilation in windows. --- src/NETGENPlugin/NETGENPlugin_Mesher.cxx | 9 ++-- src/NETGENPlugin/NETGENPlugin_Mesher.hxx | 2 +- .../NETGENPlugin_NETGEN_1D2D3D_SA.cxx | 45 ++++++++++++++---- .../NETGENPlugin_NETGEN_1D2D3D_SA.hxx | 3 +- .../NETGENPlugin_NETGEN_2D_ONLY.cxx | 9 ++-- .../NETGENPlugin_NETGEN_2D_Remote.cxx | 8 ++-- .../NETGENPlugin_NETGEN_2D_Remote.hxx | 6 +-- .../NETGENPlugin_NETGEN_2D_SA.cxx | 46 +++++++++++++++---- .../NETGENPlugin_NETGEN_2D_SA.hxx | 3 +- 9 files changed, 92 insertions(+), 39 deletions(-) diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx index 9f72683..5bed48c 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.cxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.cxx @@ -3185,7 +3185,7 @@ int NETGENPlugin_Mesher::CallNetgenMeshVolumens( NETGENPlugin_NetgenLibWrapper& return err; } -void NETGENPlugin_Mesher::MakeSecondOrder( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo, +void NETGENPlugin_Mesher::MakeSecondOrder( netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo, list< SMESH_subMesh* >* meshedSM, NETGENPlugin_ngMeshInfo& initState, SMESH_Comment& comment ) { if ( mparams.secondorder > 0 ) @@ -3386,7 +3386,6 @@ void NETGENPlugin_Mesher::InitialSetup( NETGENPlugin_NetgenLibWrapper& ngLib, ne SMESH_MesherHelper &quadHelper, NETGENPlugin_ngMeshInfo& initState, netgen::MeshingParameters &mparams ) { - int err = 0; // Init occ geometry maps for non meshed object and fill meshedSM with premeshed objects PrepareOCCgeometry( occgeo, _shape, *_mesh, meshedSM, internals ); _occgeom = &occgeo; @@ -3557,7 +3556,7 @@ bool NETGENPlugin_Mesher::Compute2D( NETGENPlugin_NetgenLibWrapper& ngLib, netge int err = CallNetgenMeshFaces( ngLib, occgeo, comment ); if ( !err && dim == DIM::D2 /* if mesh is 3D then second order is defined after volumens are computed*/ ) - MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment ); + MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment ); return err; } @@ -3579,7 +3578,7 @@ bool NETGENPlugin_Mesher::Compute3D( NETGENPlugin_NetgenLibWrapper& ngLib, netge } if ( !err ) - MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment ); + MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment ); return err; } @@ -3657,7 +3656,7 @@ bool NETGENPlugin_Mesher::Compute() } if (!err ) - MakeSecondOrder( ngLib, mparams, occgeo, meshedSM, initState, comment ); + MakeSecondOrder( mparams, occgeo, meshedSM, initState, comment ); } _ticTime = 0.98 / _progressTic; diff --git a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx index f33b154..39bd494 100644 --- a/src/NETGENPlugin/NETGENPlugin_Mesher.hxx +++ b/src/NETGENPlugin/NETGENPlugin_Mesher.hxx @@ -208,7 +208,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_Mesher int CallNetgenMeshEdges( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo ); int CallNetgenMeshFaces( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment ); int CallNetgenMeshVolumens( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::OCCGeometry& occgeo, SMESH_Comment& comment ); - void MakeSecondOrder( NETGENPlugin_NetgenLibWrapper& ngLib, netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo, + void MakeSecondOrder( netgen::MeshingParameters &mparams, netgen::OCCGeometry& occgeo, list< SMESH_subMesh* >* meshedSM, NETGENPlugin_ngMeshInfo& initState, SMESH_Comment& comment ); int FillInternalElements( NETGENPlugin_NetgenLibWrapper& ngLib, NETGENPlugin_Internals& internals, netgen::OCCGeometry& occgeo, NETGENPlugin_ngMeshInfo& initState, SMESH_MesherHelper &quadHelper, list< SMESH_subMesh* >* meshedSM ); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.cxx index bcaa38c..1ae83b4 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.cxx @@ -72,6 +72,28 @@ NETGENPlugin_NETGEN_1D2D3D_SA::~NETGENPlugin_NETGEN_1D2D3D_SA() { } +/** + * @brief Check presence and content of orientation file. Implemented for completness and future reference. + * + * @param element_orientation_file Binary file containing the orientation of surface elemnts + * @return true, false + */ +bool NETGENPlugin_NETGEN_1D2D3D_SA::checkOrientationFile( const std::string element_orientation_file ) +{ + if(element_orientation_file.empty()){ + MESSAGE("No element orientation file"); + return true; + } else { + MESSAGE("Reading from elements from file: " << element_orientation_file); + // By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing + int nbElement; + std::ifstream df(element_orientation_file, ios::binary|ios::in); + df.read((char*)&nbElement, sizeof(int)); + df.close(); + return (nbElement == 0); + } +} + /** * @brief fill plugin hypothesis from the netgen_params structure * @@ -341,17 +363,24 @@ int NETGENPlugin_NETGEN_1D2D3D_SA::run(const std::string input_mesh_file, netgen_params myParams; importNetgenParams(hypo_file, myParams); fillHyp(myParams); + int ret = 1; - int ret = Compute( *myMesh, myShape, new_element_file, !output_mesh_file.empty(), dim ); - if(ret){ - std::cerr << "Meshing failed" << std::endl; - return ret; - } + if ( checkOrientationFile(element_orientation_file) ) + { + ret = Compute( *myMesh, myShape, new_element_file, !output_mesh_file.empty(), dim ); + if(ret){ + std::cerr << "Meshing failed" << std::endl; + return ret; + } - if(!output_mesh_file.empty()){ - std::string meshName = "MESH"; - SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName); + if(!output_mesh_file.empty()){ + std::string meshName = "MESH"; + SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName); + } } + else + std::cerr << "For NETGENPlugin_NETGEN_1D2D3D_SA, orientation file should be market with 0 or be empty!" << std::endl; + return ret; } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.hxx index c269567..3851a8f 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.hxx @@ -51,8 +51,9 @@ public: const std::string output_mesh_file, const NETGENPlugin_Mesher::DIM dim ); -protected: +private: + bool checkOrientationFile( const std::string element_orientation_file ); void fillHyp(netgen_params aParams); bool FillNewElementFile( std::vector< const SMDS_MeshNode* > &nodeVec, NETGENPlugin_NetgenLibWrapper &ngLib, std::string new_element_file, const NETGENPlugin_Mesher::DIM dim ); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx index 4c4e1e6..70b63cb 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx @@ -149,7 +149,7 @@ namespace // copied class from StdMesher_Importe_1D div.Parameter( i ), div.Parameter( i+1 ), enlarge, curve ); } - catch ( Standard_Failure ) { + catch ( Standard_Failure& ) { _segments.resize( _segments.size() - 1 ); --i; } @@ -523,7 +523,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::MapSegmentsToEdges(SMESH_Mesh& aMesh, const To const int numberOfPremeshedNodes = aMesh.NbNodes(); TopTools_IndexedMapOfShape faces; TopExp::MapShapes( aShape, TopAbs_FACE, faces ); - + int err = 0; for ( int i = 1; i <= faces.Size(); ++i ) { int numOfEdges = 0; @@ -676,7 +676,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::MapSegmentsToEdges(SMESH_Mesh& aMesh, const To ngMesh->CalcSurfacesOfNode(); const int startWith = MESHCONST_MESHSURFACE; const int endWith = MESHCONST_OPTSURFACE; - int err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh); + err = ngLib.GenerateMesh(occgeom, startWith, endWith, ngMesh); // Ng_Mesh * ngMeshptr = (Ng_Mesh*) ngLib._ngMesh; // int NetgenNodes = Ng_GetNP(ngMeshptr); @@ -693,7 +693,7 @@ bool NETGENPlugin_NETGEN_2D_ONLY::MapSegmentsToEdges(SMESH_Mesh& aMesh, const To FillNodesAndElements( aMesh, helper, ngMesh, nodeVec, ng2smesh, newNetgenCoordinates, newNetgenElements, numberOfPremeshedNodes ); } // Face iteration - return false; + return (bool) err; } std::tuple NETGENPlugin_NETGEN_2D_ONLY::SetParameteres( SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, @@ -703,7 +703,6 @@ std::tuple NETGENPlugin_NETGEN_2D_ONLY::SetParameteres( SMESH_Mesh& a SMESHDS_Mesh* meshDS = aMesh.GetMeshDS(); aMesher.SetParameters( _hypParameters ); // _hypParameters -> netgen::mparam - const bool toOptimize = _hypParameters ? _hypParameters->GetOptimize() : true; if ( _hypMaxElementArea ) { netgen::mparam.maxh = sqrt( 2. * _hypMaxElementArea->GetMaxArea() / sqrt(3.0) ); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.cxx index 5e870e8..12165d6 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.cxx @@ -148,9 +148,7 @@ void NETGENPlugin_NETGEN_2D_Remote::fillParameters(const NETGENPlugin_Hypothesis * @param aShape the shape associated to the mesh * @param output_file name of the binary file */ -void NETGENPlugin_NETGEN_2D_Remote::exportElementOrientation(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - const std::string output_file) +void NETGENPlugin_NETGEN_2D_Remote::exportElementOrientation(const std::string output_file) { std::ofstream df(output_file, ios::out|ios::binary); int size=0; @@ -205,13 +203,13 @@ bool NETGENPlugin_NETGEN_2D_Remote::Compute(SMESH_Mesh& aMesh, // exportNetgenParams(param_file.string(), aParams); { // Simply write the file with the proper name - std::ofstream myfile(param_file); + std::ofstream myfile(param_file.string()); myfile << 1 << std::endl; myfile.close(); } // Exporting element orientation - exportElementOrientation(aMesh, aShape, element_orientation_file.string()); + exportElementOrientation(element_orientation_file.string()); } // Calling run_mesher diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.hxx index 4e90666..d13e175 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.hxx @@ -61,10 +61,8 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_2D_Remote: public NETGENPlugin_NET void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override; - protected: - void exportElementOrientation(SMESH_Mesh& aMesh, - const TopoDS_Shape& aShape, - const std::string output_file); + private: + void exportElementOrientation(const std::string output_file); void fillParameters(const NETGENPlugin_Hypothesis* hyp, netgen_params &aParams); diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.cxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.cxx index d06d4e9..4bffed7 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.cxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.cxx @@ -77,6 +77,28 @@ NETGENPlugin_NETGEN_2D_SA::~NETGENPlugin_NETGEN_2D_SA() { } +/** + * @brief Check presence and content of orientation file. Implemented for completness and future reference. + * + * @param element_orientation_file Binary file containing the orientation of surface elemnts + * @return true, false + */ +bool NETGENPlugin_NETGEN_2D_SA::checkOrientationFile( const std::string element_orientation_file ) +{ + if(element_orientation_file.empty()){ + MESSAGE("No element orientation file"); + return true; + } else { + MESSAGE("Reading from elements from file: " << element_orientation_file); + // By construction the orientation file written by Remote version has a zero written to mark no need of orientation in 2D meshing + int nbElement; + std::ifstream df(element_orientation_file, ios::binary|ios::in); + df.read((char*)&nbElement, sizeof(int)); + df.close(); + return (nbElement == 0); + } +} + /** * @brief fill plugin hypothesis from the netgen_params structure * @@ -244,7 +266,7 @@ int NETGENPlugin_NETGEN_2D_SA::run(const std::string input_mesh_file, { std::unique_ptr myMesh(_gen->CreateMesh(false)); - + SMESH_DriverMesh::importMesh(input_mesh_file, *myMesh); // Importing shape TopoDS_Shape myShape; @@ -254,17 +276,23 @@ int NETGENPlugin_NETGEN_2D_SA::run(const std::string input_mesh_file, importNetgenParams(hypo_file, myParams); fillHyp(hypo_file,myParams); MESSAGE("Meshing with netgen2d"); - int ret = (int) Compute( *myMesh, myShape, new_element_file ); + int ret = 1; + if ( checkOrientationFile(element_orientation_file) ) + { + ret = (int) Compute( *myMesh, myShape, new_element_file ); - if(ret){ - std::cerr << "Meshing failed" << std::endl; - return ret; - } + if(ret){ + std::cerr << "Meshing failed" << std::endl; + return ret; + } - if(!output_mesh_file.empty()){ - std::string meshName = "MESH"; - SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName); + if(!output_mesh_file.empty()){ + std::string meshName = "MESH"; + SMESH_DriverMesh::exportMesh(output_mesh_file, *myMesh, meshName); + } } + else + std::cerr << "For NETGENPlugin_NETGEN_2D_SA orientation file should be market with 0 or be empty!" << std::endl; return ret; } diff --git a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.hxx b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.hxx index 99e4706..5f4c028 100644 --- a/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.hxx +++ b/src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.hxx @@ -55,8 +55,9 @@ public: std::map& premeshedNodes, std::map>& newNetgenCoordinates, std::map>& newNetgenElements ); -protected: +private: + bool checkOrientationFile( const std::string element_orientation_file ); void fillHyp(const std::string param_file, netgen_params aParams); }; -- 2.39.2