From 97b0a95536e8d44fecc9fda65393dfd325e450f7 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 20 Nov 2020 11:26:59 +0300 Subject: [PATCH] [bos #20282] EDF 22320 - general compute fails Correct tree icon of partially computed sub-mesh --- src/SMESH/SMESH_subMesh.cxx | 36 +++++++++++++++++++++++++++++++++++ src/SMESH/SMESH_subMesh.hxx | 3 +++ src/SMESH_I/SMESH_Gen_i_1.cxx | 20 +++++++++++++++++-- 3 files changed, 57 insertions(+), 2 deletions(-) diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index 4f8a56e85..4f9955cf3 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -272,6 +272,42 @@ bool SMESH_subMesh::IsMeshComputed() const return false; } +//================================================================================ +/*! + * \brief Check if any upper level sub-shape is not computed. + * Used to update a sub-mesh icon + */ +//================================================================================ + +bool SMESH_subMesh::IsComputedPartially() const +{ + SMESH_subMeshIteratorPtr smIt = getDependsOnIterator(/*includeSelf=*/true, + /*SolidFirst=*/true); + bool allComputed = true; + TopAbs_ShapeEnum readyType = TopAbs_VERTEX; // max value + while ( smIt->more() && allComputed ) + { + SMESH_subMesh* sm = smIt->next(); + + if ( sm->GetSubShape().ShapeType() > readyType ) + break; // lower dimension -> stop + if ( sm->GetComputeState() != SMESH_subMesh::NOT_READY ) + readyType = sm->GetSubShape().ShapeType(); + + switch ( sm->GetComputeState() ) + { + case SMESH_subMesh::READY_TO_COMPUTE: + case SMESH_subMesh::FAILED_TO_COMPUTE: + allComputed = false;// sm->IsMeshComputed(); + break; + case SMESH_subMesh::NOT_READY: + case SMESH_subMesh::COMPUTE_OK: + continue; + } + } + return !allComputed; +} + //============================================================================= /*! * Return true if all sub-meshes have been meshed diff --git a/src/SMESH/SMESH_subMesh.hxx b/src/SMESH/SMESH_subMesh.hxx index 6b610ea1d..a2eef50b1 100644 --- a/src/SMESH/SMESH_subMesh.hxx +++ b/src/SMESH/SMESH_subMesh.hxx @@ -257,6 +257,9 @@ public: bool IsMeshComputed() const; // check if _subMeshDS contains mesh elements unless _alwaysComputed==true + bool IsComputedPartially() const; + // check if any upper level sub-shape is not computed + /*! * \brief Set sub-shapes that are allowed to compute at once by a multidimensional algo */ diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index d7d61bcaf..a667ba59f 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -1009,8 +1009,23 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh ) { SMESH::array_of_ElementType_var elemTypes = idSrc->GetTypes(); isEmpty = ( elemTypes->length() == 0 ); + + if ( !isEmpty ) + { + // check if all sub-shapes of sub-mesh on group are computed + // (pb: "Compute sub-mesh" menu is missing if a sub-mesh is partially computed) + SMESH::SMESH_subMesh_var subMesh = SMESH::SMESH_subMesh::_narrow( obj ); + if ( !subMesh->_is_nil() ) + if ( SMESH_subMesh* sm = mesh_i->GetImpl().GetSubMeshContaining( subMesh->GetId() )) + if ( sm->IsComputedPartially() ) + { + SetPixMap( so, "ICON_SMESH_TREE_MESH_PARTIAL" ); + continue; + } + } } } + if ( isEmpty ) SetPixMap( so, "ICON_SMESH_TREE_MESH_WARN"); else if ( !isGroup ) @@ -1019,8 +1034,9 @@ void SMESH_Gen_i::UpdateIcons( SMESH::SMESH_Mesh_ptr theMesh ) SetPixMap( so, "ICON_SMESH_TREE_GROUP_ON_FILTER" ); else SetPixMap( so, "ICON_SMESH_TREE_GROUP" ); - } - } + + } // loop on sub-meshes or groups + } // loop on roots } //======================================================================= -- 2.30.2