]> SALOME platform Git repositories - plugins/netgenplugin.git/commitdiff
Salome HOME
Using MeshLocker + implementing call to assign for remote plugin
authorYoann Audouin <yoann.audouin@edf.fr>
Mon, 3 Oct 2022 06:02:37 +0000 (08:02 +0200)
committerYoann Audouin <yoann.audouin@edf.fr>
Mon, 3 Oct 2022 06:02:37 +0000 (08:02 +0200)
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.cxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_Remote.hxx
src/NETGENPlugin/NETGENPlugin_NETGEN_3D_SA.hxx

index dc70cf4af5c66501f8011fb02149fc6b10b1cbd8..d0a1ad6d80181c8e8e2765d64c6679f7bc29fd9e 100644 (file)
 #include "NETGENPlugin_DriverParam.hxx"
 #include "NETGENPlugin_Hypothesis.hxx"
 
+#include "Utils_SALOME_Exception.hxx"
+
 #include <SMESH_Gen.hxx>
 #include <SMESH_Mesh.hxx>
 #include <SMESH_MesherHelper.hxx>
 #include <SMESH_DriverShape.hxx>
 #include <SMESH_DriverMesh.hxx>
 #include <SMESHDS_Mesh.hxx>
+#include <SMESH_MeshLocker.hxx>
 
 #include <QString>
 #include <QProcess>
@@ -199,9 +202,11 @@ void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
 bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
                                            const TopoDS_Shape& aShape)
 {
-  aMesh.Lock();
-  SMESH_Hypothesis::Hypothesis_Status hypStatus;
-  NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
+  {
+    SMESH_MeshLocker myLocker(&aMesh);
+    SMESH_Hypothesis::Hypothesis_Status hypStatus;
+    NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
+  }
 
 
   // Temporary folder for run
@@ -221,19 +226,21 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
   //TODO: Handle variable mesh_name
   std::string mesh_name = "MESH";
 
-  //Writing Shape
-  exportShape(shape_file.string(), aShape);
+  {
+    SMESH_MeshLocker myLocker(&aMesh);
+    //Writing Shape
+    exportShape(shape_file.string(), aShape);
 
-  //Writing hypo
-  netgen_params aParams;
-  fillParameters(_hypParameters, aParams);
+    //Writing hypo
+    netgen_params aParams;
+    fillParameters(_hypParameters, aParams);
 
-  exportNetgenParams(param_file.string(), aParams);
+    exportNetgenParams(param_file.string(), aParams);
 
-  // Exporting element orientation
-  exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
+    // Exporting element orientation
+    exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
+  }
 
-  aMesh.Unlock();
   // Calling run_mesher
   // TODO: check if we need to handle the .exe for windows
   std::string cmd;
@@ -282,14 +289,14 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
 
   if(ret != 0){
     // Run crahed
-    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;
+    std::string msg = "Issue with command: \n";
+    msg += "See log for more details: " + log_file.string() + "\n";
+    msg += cmd + "\n";
+    throw SALOME_Exception(msg);
   }
 
-  aMesh.Lock();
   {
+    SMESH_MeshLocker myLocker(&aMesh);
     std::ifstream df(new_element_file.string(), ios::binary);
 
     int Netgen_NbOfNodes;
@@ -344,7 +351,12 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh&         aMesh,
     }
   }
 
-  aMesh.Unlock();
-
   return true;
-}
\ No newline at end of file
+}
+
+
+void NETGENPlugin_NETGEN_3D_Remote::setSubMeshesToCompute(SMESH_subMesh * aSubMesh)
+{
+  SMESH_MeshLocker myLocker(aSubMesh->GetFather());
+  SMESH_Algo::setSubMeshesToCompute(aSubMesh);
+}
index bfa3bda7b00766f05b8f4ad5364a4d69028e489e..210fa080dd7ec3a0dc37d0a0d7b0ae14994b3a68 100644 (file)
@@ -53,10 +53,12 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_Remote: public NETGENPlugin_NET
   // Function whould not be used with remote Computing
   bool CheckHypothesis (SMESH_Mesh&         aMesh,
                         const TopoDS_Shape& aShape,
-                        Hypothesis_Status&  aStatus){aStatus = HYP_OK;return true;};
+                        Hypothesis_Status&  aStatus) override {(void)aMesh;(void)aShape;aStatus = HYP_OK;return true;};
 
   bool Compute(SMESH_Mesh&         aMesh,
-              const TopoDS_Shape& aShape);
+              const TopoDS_Shape& aShape) override;
+
+  void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override;
 
 
  protected:
index 6c10fb0ad739fb23c40ba898b7d57db68adc2f44..b3ebe1a0a3b6698fda21629bbe94c1f672dfd052 100644 (file)
@@ -78,7 +78,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
     SMESH_MesherHelper &helper,
     netgen_params &aParams,
     std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
-    );
+    ) override;
 
    std::string _element_orientation_file="";
    SMESH_Gen *_gen=nullptr;