-// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 CEA, EDF, OPEN CASCADE
//
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
#include "SMESH_Mesh.hxx"
#include "SMESH_MesherHelper.hxx"
#include "SMESH_subMeshEventListener.hxx"
+#include "SMESH_MeshLocker.hxx"
#include "utilities.h"
#include "Basics_Utils.hxx"
#ifdef _DEBUG_
// enable printing algo + shape id + hypo used while meshing
-//#define PRINT_WHO_COMPUTE_WHAT
+#define PRINT_WHO_COMPUTE_WHAT
#endif
-//#define PRINT_WHO_COMPUTE_WHAT
//=============================================================================
/*!
* \brief Allocate some memory at construction and release it at destruction.
else if (( event == COMPUTE || event == COMPUTE_SUBMESH )
&& !_alwaysComputed )
{
- // LOCK: Adding node to mesh
- _father->Lock();
+ SMESH_MeshLocker myLocker(_father);
const TopoDS_Vertex & V = TopoDS::Vertex( _subShape );
gp_Pnt P = BRep_Tool::Pnt(V);
if ( SMDS_MeshNode * n = _father->GetMeshDS()->AddNode(P.X(), P.Y(), P.Z()) ) {
_father->GetMeshDS()->SetNodeOnVertex(n,_Id);
_computeState = COMPUTE_OK;
}
- _father->Unlock();
- // UNLOCK
}
if ( event == MODIF_ALGO_STATE )
cleanDependants();
break;
}
TopoDS_Shape shape = _subShape;
- _father->Lock();
- algo->SubMeshesToCompute().assign( 1, this );
- _father->Unlock();
+ algo->setSubMeshesToCompute(this);
// check submeshes needed
- // In parallel there would be no submesh to check
+ // When computing in parallel mode we do not have a additional layer of submesh
+ // The check should not be done in parallel as that check is not thread-safe
if (_father->HasShapeToMesh() && !_father->IsParallel()) {
bool subComputed = false, subFailed = false;
if (!algo->OnlyUnaryInput()) {
#ifdef PRINT_WHO_COMPUTE_WHAT
for (subS.ReInit(); subS.More(); subS.Next())
{
- _father->Lock();
- const std::list <const SMESHDS_Hypothesis *> hyps =
- _algo->GetUsedHypothesis( *_father, _subShape );
- _father->Unlock();
+ SMESH_MeshLocker myLocker(_father);
+ const std::list <const SMESHDS_Hypothesis *> & hyps =
+ _algo->GetUsedHypothesis( *_father, _subShape );
SMESH_Comment hypStr;
if ( !hyps.empty() )
{
break;
}
- //notifyListenersOnEvent( event, COMPUTE_EVENT );
+ notifyListenersOnEvent( event, COMPUTE_EVENT );
return ret;
}