Using MeshLocker + implementing call to assign for remote plugin

This commit is contained in:
Yoann Audouin 2022-10-03 08:02:37 +02:00
parent 9f2b637978
commit 1a79294029
3 changed files with 37 additions and 23 deletions

View File

@ -35,12 +35,15 @@
#include "NETGENPlugin_DriverParam.hxx" #include "NETGENPlugin_DriverParam.hxx"
#include "NETGENPlugin_Hypothesis.hxx" #include "NETGENPlugin_Hypothesis.hxx"
#include "Utils_SALOME_Exception.hxx"
#include <SMESH_Gen.hxx> #include <SMESH_Gen.hxx>
#include <SMESH_Mesh.hxx> #include <SMESH_Mesh.hxx>
#include <SMESH_MesherHelper.hxx> #include <SMESH_MesherHelper.hxx>
#include <SMESH_DriverShape.hxx> #include <SMESH_DriverShape.hxx>
#include <SMESH_DriverMesh.hxx> #include <SMESH_DriverMesh.hxx>
#include <SMESHDS_Mesh.hxx> #include <SMESHDS_Mesh.hxx>
#include <SMESH_MeshLocker.hxx>
#include <QString> #include <QString>
#include <QProcess> #include <QProcess>
@ -199,9 +202,11 @@ void NETGENPlugin_NETGEN_3D_Remote::exportElementOrientation(SMESH_Mesh& aMesh,
bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh, bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape) const TopoDS_Shape& aShape)
{ {
aMesh.Lock(); {
SMESH_Hypothesis::Hypothesis_Status hypStatus; SMESH_MeshLocker myLocker(&aMesh);
NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus); SMESH_Hypothesis::Hypothesis_Status hypStatus;
NETGENPlugin_NETGEN_3D::CheckHypothesis(aMesh, aShape, hypStatus);
}
// Temporary folder for run // Temporary folder for run
@ -221,19 +226,21 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
//TODO: Handle variable mesh_name //TODO: Handle variable mesh_name
std::string mesh_name = "MESH"; 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 //Writing hypo
netgen_params aParams; netgen_params aParams;
fillParameters(_hypParameters, aParams); fillParameters(_hypParameters, aParams);
exportNetgenParams(param_file.string(), aParams); exportNetgenParams(param_file.string(), aParams);
// Exporting element orientation // Exporting element orientation
exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string()); exportElementOrientation(aMesh, aShape, aParams, element_orientation_file.string());
}
aMesh.Unlock();
// Calling run_mesher // Calling run_mesher
// TODO: check if we need to handle the .exe for windows // TODO: check if we need to handle the .exe for windows
std::string cmd; std::string cmd;
@ -282,14 +289,14 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
if(ret != 0){ if(ret != 0){
// Run crahed // Run crahed
std::cerr << "Issue with command: " << std::endl; std::string msg = "Issue with command: \n";
std::cerr << "See log for more details: " << log_file.string() << std::endl; msg += "See log for more details: " + log_file.string() + "\n";
std::cerr << cmd << std::endl; msg += cmd + "\n";
return false; throw SALOME_Exception(msg);
} }
aMesh.Lock();
{ {
SMESH_MeshLocker myLocker(&aMesh);
std::ifstream df(new_element_file.string(), ios::binary); std::ifstream df(new_element_file.string(), ios::binary);
int Netgen_NbOfNodes; int Netgen_NbOfNodes;
@ -344,7 +351,12 @@ bool NETGENPlugin_NETGEN_3D_Remote::Compute(SMESH_Mesh& aMesh,
} }
} }
aMesh.Unlock();
return true; return true;
} }
void NETGENPlugin_NETGEN_3D_Remote::setSubMeshesToCompute(SMESH_subMesh * aSubMesh)
{
SMESH_MeshLocker myLocker(aSubMesh->GetFather());
SMESH_Algo::setSubMeshesToCompute(aSubMesh);
}

View File

@ -53,10 +53,12 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_Remote: public NETGENPlugin_NET
// Function whould not be used with remote Computing // Function whould not be used with remote Computing
bool CheckHypothesis (SMESH_Mesh& aMesh, bool CheckHypothesis (SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape, 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, bool Compute(SMESH_Mesh& aMesh,
const TopoDS_Shape& aShape); const TopoDS_Shape& aShape) override;
void setSubMeshesToCompute(SMESH_subMesh * aSubMesh) override;
protected: protected:

View File

@ -78,7 +78,7 @@ class NETGENPLUGIN_EXPORT NETGENPlugin_NETGEN_3D_SA: public NETGENPlugin_NETGEN_
SMESH_MesherHelper &helper, SMESH_MesherHelper &helper,
netgen_params &aParams, netgen_params &aParams,
std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements std::map<const SMDS_MeshElement*, tuple<bool, bool>>& listElements
); ) override;
std::string _element_orientation_file=""; std::string _element_orientation_file="";
SMESH_Gen *_gen=nullptr; SMESH_Gen *_gen=nullptr;