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.org
23 // File : SMESHDS_Group.cxx
24 // Author : Michael Sazonov, OCC
28 #include <SMESHDS_Group.hxx>
29 #include <SMESHDS_Mesh.hxx>
33 //=============================================================================
37 //=============================================================================
39 SMESHDS_Group::SMESHDS_Group (const int theID,
40 const SMESHDS_Mesh* theMesh,
41 const SMDSAbs_ElementType theType)
42 : SMDS_MeshGroup(theMesh,theType),
43 myID(theID), myStoreName(""),
44 myCurIndex(0), myCurID(0)
48 //=============================================================================
52 //=============================================================================
54 bool SMESHDS_Group::Contains (const int theID) const
56 const SMDS_MeshElement* aElem = findInMesh (theID);
58 return SMDS_MeshGroup::Contains(aElem);
62 //=============================================================================
66 //=============================================================================
68 bool SMESHDS_Group::Add (const int theID)
70 const SMDS_MeshElement* aElem = findInMesh (theID);
71 if (!aElem || SMDS_MeshGroup::Contains(aElem))
73 SMDS_MeshGroup::Add (aElem);
77 //=============================================================================
81 //=============================================================================
83 bool SMESHDS_Group::Remove (const int theID)
85 const SMDS_MeshElement* aElem = findInMesh (theID);
86 if (!aElem || !SMDS_MeshGroup::Contains(aElem))
88 SMDS_MeshGroup::Remove (aElem);
92 //=============================================================================
96 //=============================================================================
98 int SMESHDS_Group::GetID (const int theIndex)
100 if (theIndex < 1 || theIndex > Extent())
102 if (myCurIndex < 1 || myCurIndex > theIndex) {
107 while (myCurIndex < theIndex && More()) {
109 myCurID = Next()->GetID();
114 //=============================================================================
118 //=============================================================================
120 const SMDS_MeshElement* SMESHDS_Group::findInMesh (const int theID) const
122 SMDSAbs_ElementType aType = GetType();
123 const SMDS_MeshElement* aElem = NULL;
124 if (aType == SMDSAbs_Node) {
125 aElem = GetMesh()->FindNode(theID);
127 else if (aType != SMDSAbs_All) {
128 aElem = GetMesh()->FindElement(theID);
129 if (aElem && aType != aElem->GetType())