From 2e446e7121ea4e7ab033e96d67ae45f4580f16c4 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 19 Dec 2007 15:02:14 +0000 Subject: [PATCH] PAL16617 (Modification/Transformation operations with copy don't create a new mesh) + virtual bool Contains (const SMDS_MeshElement* elem); --- src/SMESHDS/SMESHDS_Group.cxx | 12 ++++++++++++ src/SMESHDS/SMESHDS_Group.hxx | 2 ++ src/SMESHDS/SMESHDS_GroupBase.cxx | 23 +++++++++++++++++------ src/SMESHDS/SMESHDS_GroupBase.hxx | 2 ++ src/SMESHDS/SMESHDS_GroupOnGeom.cxx | 11 +++++++++++ src/SMESHDS/SMESHDS_GroupOnGeom.hxx | 2 ++ 6 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/SMESHDS/SMESHDS_Group.cxx b/src/SMESHDS/SMESHDS_Group.cxx index 1955f56bf..e6b0759c1 100644 --- a/src/SMESHDS/SMESHDS_Group.cxx +++ b/src/SMESHDS/SMESHDS_Group.cxx @@ -77,6 +77,18 @@ bool SMESHDS_Group::Contains (const int theID) return false; } +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +bool SMESHDS_Group::Contains (const SMDS_MeshElement* elem) +{ + if (elem) + return myGroup.Contains(elem); + return false; +} + //============================================================================= /*! * diff --git a/src/SMESHDS/SMESHDS_Group.hxx b/src/SMESHDS/SMESHDS_Group.hxx index 2d41756a5..7f5c98c9c 100644 --- a/src/SMESHDS/SMESHDS_Group.hxx +++ b/src/SMESHDS/SMESHDS_Group.hxx @@ -51,6 +51,8 @@ class SMESHDS_EXPORT SMESHDS_Group : public SMESHDS_GroupBase virtual bool Contains (const int theID); + virtual bool Contains (const SMDS_MeshElement* elem); + virtual SMDS_ElemIteratorPtr GetElements(); bool Add (const int theID); diff --git a/src/SMESHDS/SMESHDS_GroupBase.cxx b/src/SMESHDS/SMESHDS_GroupBase.cxx index 5221743a9..0b2cad051 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.cxx +++ b/src/SMESHDS/SMESHDS_GroupBase.cxx @@ -132,12 +132,23 @@ bool SMESHDS_GroupBase::IsEmpty() bool SMESHDS_GroupBase::Contains (const int theID) { - SMDS_ElemIteratorPtr it = GetElements(); - bool contains = false; - if ( it ) - while ( !contains && it->more() ) - contains = ( it->next()->GetID() == theID ); - return contains; + if ( SMDS_ElemIteratorPtr it = GetElements() ) { + while ( it->more() ) + if ( it->next()->GetID() == theID ) + return true; + } + return false; +} + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +bool SMESHDS_GroupBase::Contains (const SMDS_MeshElement* elem) +{ + if ( elem ) + return Contains( elem->GetID() ); } //======================================================================= diff --git a/src/SMESHDS/SMESHDS_GroupBase.hxx b/src/SMESHDS/SMESHDS_GroupBase.hxx index 7e2d521e0..dc4714e8a 100644 --- a/src/SMESHDS/SMESHDS_GroupBase.hxx +++ b/src/SMESHDS/SMESHDS_GroupBase.hxx @@ -63,6 +63,8 @@ class SMESHDS_EXPORT SMESHDS_GroupBase virtual bool Contains (const int theID); + virtual bool Contains (const SMDS_MeshElement* elem); + virtual SMDS_ElemIteratorPtr GetElements() = 0; int GetID (const int theIndex); diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx index ede4f0566..f7cb20d39 100644 --- a/src/SMESHDS/SMESHDS_GroupOnGeom.cxx +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.cxx @@ -110,3 +110,14 @@ bool SMESHDS_GroupOnGeom::Contains (const int theID) { return mySubMesh->Contains( findInMesh( theID )); } + +//======================================================================= +//function : Contains +//purpose : +//======================================================================= + +bool SMESHDS_GroupOnGeom::Contains (const SMDS_MeshElement* elem) +{ + return mySubMesh->Contains( elem ); +} + diff --git a/src/SMESHDS/SMESHDS_GroupOnGeom.hxx b/src/SMESHDS/SMESHDS_GroupOnGeom.hxx index eaee815f8..d2c3a1dc4 100644 --- a/src/SMESHDS/SMESHDS_GroupOnGeom.hxx +++ b/src/SMESHDS/SMESHDS_GroupOnGeom.hxx @@ -47,6 +47,8 @@ class SMESHDS_EXPORT SMESHDS_GroupOnGeom: public SMESHDS_GroupBase virtual bool Contains (const int theID); + virtual bool Contains (const SMDS_MeshElement* elem); + virtual SMDS_ElemIteratorPtr GetElements(); private: -- 2.39.2