From 9434254db5b1e745c54a9ee87c664f80c2b8608a Mon Sep 17 00:00:00 2001 From: eap Date: Mon, 27 Mar 2006 13:34:04 +0000 Subject: [PATCH] PAL11992. fix cleanMesh() --- src/SMESH/SMESH_Pattern.cxx | 51 +++++++++++++++++++++++++++---------- 1 file changed, 38 insertions(+), 13 deletions(-) diff --git a/src/SMESH/SMESH_Pattern.cxx b/src/SMESH/SMESH_Pattern.cxx index 3cf7d2eb5..909e9f5a4 100644 --- a/src/SMESH/SMESH_Pattern.cxx +++ b/src/SMESH/SMESH_Pattern.cxx @@ -3547,6 +3547,40 @@ bool SMESH_Pattern:: return makePoly; } +//======================================================================= +//function : clearSubMesh +//purpose : +//======================================================================= + +static bool clearSubMesh( SMESH_Mesh* theMesh, + const TopoDS_Shape& theShape) +{ + bool removed = false; + if ( SMESH_subMesh * aSubMesh = theMesh->GetSubMeshContaining( theShape )) + { + if ( aSubMesh->GetSubMeshDS() ) { + removed = + aSubMesh->GetSubMeshDS()->NbElements() || aSubMesh->GetSubMeshDS()->NbNodes(); + aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN ); + } + } + else { + SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); + if ( SMESHDS_SubMesh* aSubMeshDS = aMeshDS->MeshElements( theShape )) + { + SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); + removed = eIt->more(); + while ( eIt->more() ) + aMeshDS->RemoveElement( eIt->next() ); + SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes(); + removed = removed || nIt->more(); + while ( nIt->more() ) + aMeshDS->RemoveNode( static_cast( nIt->next() )); + } + } + return removed; +} + //======================================================================= //function : clearMesh //purpose : clear mesh elements existing on myShape in theMesh @@ -3557,20 +3591,11 @@ void SMESH_Pattern::clearMesh(SMESH_Mesh* theMesh) const if ( !myShape.IsNull() ) { - if ( SMESH_subMesh * aSubMesh = theMesh->GetSubMesh/*Containing*/( myShape )) - { - aSubMesh->ComputeStateEngine( SMESH_subMesh::CLEAN ); - } - else { - SMESHDS_Mesh* aMeshDS = theMesh->GetMeshDS(); - if ( SMESHDS_SubMesh* aSubMeshDS = aMeshDS->MeshElements( myShape )) + if ( !clearSubMesh( theMesh, myShape ) && !myIs2D ) { // myShape is SHELL but volumes may be bound to SOLID + TopTools_ListIteratorOfListOfShape it( theMesh->GetAncestors( myShape )); + for (; it.More() && it.Value().ShapeType() == TopAbs_SOLID; it.Next()) { - SMDS_ElemIteratorPtr eIt = aSubMeshDS->GetElements(); - while ( eIt->more() ) - aMeshDS->RemoveElement( eIt->next() ); - SMDS_NodeIteratorPtr nIt = aSubMeshDS->GetNodes(); - while ( nIt->more() ) - aMeshDS->RemoveNode( static_cast( nIt->next() )); + clearSubMesh( theMesh, it.Value() ); } } } -- 2.30.2