Salome HOME
[bos #38045][EDF] (2023-T3) suppress compilation warnings of new and refactored classes. cce/38045 6/head
authorcconopoima <cesar.conopoima@gmail.com>
Wed, 3 Jan 2024 12:47:10 +0000 (12:47 +0000)
committercesarconopoima <cesar.conopoima@opencascade.com>
Thu, 18 Jan 2024 10:30:12 +0000 (10:30 +0000)
Allow compilation in windows.

src/NETGENPlugin/NETGENPlugin_Mesher.cxx
src/NETGENPlugin/NETGENPlugin_Mesher.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_1D2D3D_SA.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_ONLY.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_Remote.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_2D_SA.hxx

index 9f7268332c7f910e65dd2b45167483e8d3567121..5bed48c9deaae883a48e80cd811c446e0fdb393f 100644 (file)
@@ -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;
index f33b154f63d52eff1d4fd031ac92b57a43124a52..39bd494c3c37afcaabc391e70e0adccde4b5c94a 100644 (file)
@@ -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 );
index bcaa38cf8575034ad0a003aad72089a01bc307c1..1ae83b4c81efcdba5e2be36a0a903eff6fa90ac8 100644 (file)
@@ -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;
 }
index c2695673b4f0641772bf7dcfe3da5b33a3ee8b73..3851a8f658e4afe88f8ba6763fa2a1ca0bfa0ca9 100644 (file)
@@ -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 );
index 4c4e1e6ab20cf51c17c301cee5163f2de2aa04ce..70b63cb4118c25623f4a413179a09fedb10d1c2e 100644 (file)
@@ -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<bool,bool> NETGENPlugin_NETGEN_2D_ONLY::SetParameteres( SMESH_Mesh& aMesh, const TopoDS_Shape& aShape, 
@@ -703,7 +703,6 @@ std::tuple<bool,bool> 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) );
index 5e870e86f749ee262e7e39537654036f93d3157f..12165d6641d5f1794b32d40af0c05f0e79233789 100644 (file)
@@ -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
index 4e906665e64f112f1142096db1503c40491d0fe8..d13e175551813f08c0382027674e8a2a91230d3a 100644 (file)
@@ -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);
index d06d4e933fb9abc1d5fdadbe7165cd261a87f64d..4bffed735974eb614906d086ce33e950ce868c56 100644 (file)
@@ -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<SMESH_Mesh> 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;
 }
index 99e47065ec6bada4722c8bbb7f61d2d4ac2815f3..5f4c028a028fdf92f278bce271eff99e3c54a5e6 100644 (file)
@@ -55,8 +55,9 @@ public:
                            std::map<int,const SMDS_MeshNode*>& premeshedNodes, 
                            std::map<int,std::vector<double>>& newNetgenCoordinates,
                            std::map<int,std::vector<smIdType>>& newNetgenElements );
-protected:
+private:
   
+  bool checkOrientationFile( const std::string element_orientation_file );
   void fillHyp(const std::string param_file, netgen_params aParams);
 };