1 // SMESH SMESHDS : idl implementation based on 'SMESH' unit's classes
3 // Copyright (C) 2004 CEA
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMESHDS_Group.cxx
27 #include "SMESHDS_GroupBase.hxx"
28 #include "SMESHDS_Mesh.hxx"
30 #include "utilities.h"
34 //=============================================================================
38 //=============================================================================
40 SMESHDS_GroupBase::SMESHDS_GroupBase (const int theID,
41 const SMESHDS_Mesh* theMesh,
42 const SMDSAbs_ElementType theType):
43 myID(theID), myMesh(theMesh), myType(theType), myStoreName(""),
44 myCurIndex(0), myCurID(-1)
51 //=============================================================================
55 //=============================================================================
57 int SMESHDS_GroupBase::GetID (const int theIndex)
59 if (myCurIndex < 1 || myCurIndex > theIndex) {
60 myIterator = GetElements();
64 while (myCurIndex < theIndex && myIterator->more()) {
66 myCurID = myIterator->next()->GetID();
68 return myCurIndex == theIndex ? myCurID : -1;
71 //=============================================================================
75 //=============================================================================
77 const SMDS_MeshElement* SMESHDS_GroupBase::findInMesh (const int theID) const
79 SMDSAbs_ElementType aType = GetType();
80 const SMDS_MeshElement* aElem = NULL;
81 if (aType == SMDSAbs_Node) {
82 aElem = GetMesh()->FindNode(theID);
84 else if (aType != SMDSAbs_All) {
85 aElem = GetMesh()->FindElement(theID);
86 if (aElem && aType != aElem->GetType())
92 //=============================================================================
94 * Internal method: resets cached iterator, should be called by ancestors
95 * when they are modified (ex: Add() or Remove() )
97 //=============================================================================
98 void SMESHDS_GroupBase::resetIterator()
104 //=======================================================================
107 //=======================================================================
109 int SMESHDS_GroupBase::Extent()
111 SMDS_ElemIteratorPtr it = GetElements();
114 for ( ; it->more(); it->next() )
119 //=======================================================================
122 //=======================================================================
124 bool SMESHDS_GroupBase::IsEmpty()
126 SMDS_ElemIteratorPtr it = GetElements();
127 return ( !it || !it->more() );
130 //=======================================================================
131 //function : Contains
133 //=======================================================================
135 bool SMESHDS_GroupBase::Contains (const int theID)
137 SMDS_ElemIteratorPtr it = GetElements();
138 bool contains = false;
140 while ( !contains && it->more() )
141 contains = ( it->next()->GetID() == theID );
145 //=======================================================================
148 //=======================================================================
150 void SMESHDS_GroupBase::SetType(SMDSAbs_ElementType theType)