From baf83bed4152b4ac101ebe43f442a4f8a1acd712 Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 22 Nov 2018 21:37:35 +0300 Subject: [PATCH] IMP 23613: EDF 15565 - Ponctual elements --- src/SMESHDS/SMESHDS_GroupOnGeom.cxx | 45 +++++++++++++++++------ src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx | 2 +- 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx index 65a39a7bc..ba68de567 100644 --- a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx @@ -66,13 +66,17 @@ class MyIterator: public SMDS_ElemIterator MyIterator(SMDSAbs_ElementType type, const SMESHDS_SubMesh* subMesh) : myType(type), myElem(0) { - if ( subMesh ) { - if ( myType == SMDSAbs_Node ) + if ( subMesh ) + { + if ( myType == SMDSAbs_Node || + myType == SMDSAbs_0DElement || + myType == SMDSAbs_Ball ) myNodeIt = subMesh->GetNodes(); - else { + else myElemIt = subMesh->GetElements(); + + if ( myType != SMDSAbs_Node ) next(); - } } } bool more() @@ -85,15 +89,30 @@ class MyIterator: public SMDS_ElemIterator { if ( myType == SMDSAbs_Node && myNodeIt ) return myNodeIt->next(); + const SMDS_MeshElement* res = myElem; myElem = 0; - while ( myElemIt && myElemIt->more() ) { - myElem = myElemIt->next(); - if ( myElem && myElem->GetType() == myType ) - break; - else - myElem = 0; - } + + if ( myElemIt ) + while ( myElemIt->more() ) { + myElem = myElemIt->next(); + if ( myElem && myElem->GetType() == myType ) + break; + else + myElem = 0; + } + + if ( !myElem && myNodeIt ) // look for a 0D element + while ( myNodeIt->more() ) { + const SMDS_MeshNode* n = myNodeIt->next(); + if (( myElemIt = n->GetInverseElementIterator( myType )) && + ( myElemIt->more() )) + { + myElem = myElemIt->next(); + break; + } + } + return res; } }; @@ -125,6 +144,10 @@ bool SMESHDS_GroupOnGeom::Contains (const int theID) bool SMESHDS_GroupOnGeom::Contains (const SMDS_MeshElement* elem) { + if ( GetType() == SMDSAbs_0DElement || + GetType() == SMDSAbs_Ball ) + return elem ? mySubMesh->Contains( elem->GetNode(0) ) : false; + return mySubMesh->Contains( elem ); } diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index 294c3c6b2..ab7b89b4e 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -210,7 +210,7 @@ static SMESH::ElementType elementType(GEOM::GEOM_Object_var geom) { if ( !geom->_is_nil() ) { switch ( geom->GetShapeType() ) { - case GEOM::VERTEX: return SMESH::NODE; + case GEOM::VERTEX: return SMESH::ELEM0D; // NODE; -- 0023613 case GEOM::EDGE: return SMESH::EDGE; case GEOM::WIRE: return SMESH::EDGE; case GEOM::FACE: return SMESH::FACE; -- 2.39.2