X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSMESH%2FSMESH_subMesh.cxx;h=0b697d7a0b9eeaafb6d6a37a3cd2aa5898edfb5d;hb=HEAD;hp=b5661535a85de400479c9b1160a6a5e135fd45e9;hpb=c9a5231c3266eab79a74e3c50b702c7467d8df91;p=modules%2Fsmesh.git diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index b5661535a..18b6c3cdf 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2024 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 @@ -37,6 +37,7 @@ #include "SMESH_Mesh.hxx" #include "SMESH_MesherHelper.hxx" #include "SMESH_subMeshEventListener.hxx" +#include "SMESH_MeshLocker.hxx" #include "utilities.h" #include "Basics_Utils.hxx" @@ -62,10 +63,9 @@ using namespace std; #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. @@ -891,7 +891,10 @@ SMESH_Hypothesis::Hypothesis_Status ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; } else if (!_father->IsUsedHypothesis( anHyp, this )) - ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; + { + if ( anHyp->GetDim() == this->GetAlgo()->GetDim() ) + ret = SMESH_Hypothesis::HYP_INCOMPATIBLE; + } if (SMESH_Hypothesis::IsStatusFatal( ret )) { @@ -1393,16 +1396,13 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) 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(); @@ -1516,12 +1516,11 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) 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 - if (_father->HasShapeToMesh() && !_father->IsParallel()) { + // 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() || shape.ShapeType() != _father->GetParallelElement() )) { bool subComputed = false, subFailed = false; if (!algo->OnlyUnaryInput()) { // --- commented for bos#22320 to compute all sub-shapes at once if possible; @@ -1650,10 +1649,9 @@ bool SMESH_subMesh::ComputeStateEngine(compute_event event) #ifdef PRINT_WHO_COMPUTE_WHAT for (subS.ReInit(); subS.More(); subS.Next()) { - _father->Lock(); + SMESH_MeshLocker myLocker(_father); const std::list & hyps = - _algo->GetUsedHypothesis( *_father, _subShape ); - _father->Unlock(); + _algo->GetUsedHypothesis( *_father, _subShape ); SMESH_Comment hypStr; if ( !hyps.empty() ) { @@ -2193,10 +2191,13 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/, { SMESH_subMesh* subMesh = smIt->next(); const TopoDS_Shape& S = subMesh->_subShape; - if ( S.ShapeType() != this->_subShape.ShapeType() ) + + if ( S.ShapeType() != this->_subShape.ShapeType() ){ continue; - if ( _allowedSubShapes && !_allowedSubShapes->IsEmpty() && !_allowedSubShapes->Contains( S )) + } + if ( _allowedSubShapes && !_allowedSubShapes->IsEmpty() && !_allowedSubShapes->Contains( S )){ continue; + } if ( subMesh == this ) { aBuilder.Add( aCompound, S ); @@ -2205,6 +2206,7 @@ TopoDS_Shape SMESH_subMesh::getCollection(SMESH_Gen * /*theGen*/, else if ( subMesh->GetComputeState() == READY_TO_COMPUTE ) { SMESH_Algo* anAlgo = subMesh->GetAlgo(); + if (( anAlgo->IsSameName( *theAlgo )) && // same algo ( anAlgo->GetUsedHypothesis( *_father, S, skipAuxHyps ) == usedHyps ) && // same hyps ( anAlgo->GetAssignedShapes() == assiShapes ) && // on same sub-shapes