X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHDS%2FSMESHDS_GroupOnGeom.cxx;h=0c0460b2f3a9cac1a57e3f7a61d65d45cc3e75ed;hp=7127171f345d55563d854fec2cad04979b1269c4;hb=b09372829929f8f561495d6c16527134971a1909;hpb=bd8f1aee7c78f7d2eb82bd4fec5e08c9e3d280ce diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx index 7127171f3..0c0460b2f 100644 --- a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE +// Copyright (C) 2007-2021 CEA/DEN, EDF R&D, OPEN CASCADE // // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -6,7 +6,7 @@ // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -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; } }; @@ -113,7 +132,7 @@ SMDS_ElemIteratorPtr SMESHDS_GroupOnGeom::GetElements() const //purpose : //======================================================================= -bool SMESHDS_GroupOnGeom::Contains (const int theID) +bool SMESHDS_GroupOnGeom::Contains (const smIdType theID) { return mySubMesh->Contains( findInMesh( theID )); } @@ -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 ); }