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>
31 //=============================================================================
35 //=============================================================================
37 SMESHDS_Group::SMESHDS_Group (const SMESHDS_Mesh* theMesh,
38 const SMDSAbs_ElementType theType)
39 : SMDS_MeshGroup(theMesh,theType), myStoreName(""),
40 myCurIndex(0), myCurID(0)
44 //=============================================================================
48 //=============================================================================
50 bool SMESHDS_Group::Contains (const int theID) const
52 const SMDS_MeshElement* aElem = findInMesh (theID);
54 return SMDS_MeshGroup::Contains(aElem);
58 //=============================================================================
62 //=============================================================================
64 bool SMESHDS_Group::Add (const int theID)
66 const SMDS_MeshElement* aElem = findInMesh (theID);
67 if (!aElem || SMDS_MeshGroup::Contains(aElem))
69 SMDS_MeshGroup::Add (aElem);
73 //=============================================================================
77 //=============================================================================
79 bool SMESHDS_Group::Remove (const int theID)
81 const SMDS_MeshElement* aElem = findInMesh (theID);
82 if (!aElem || !SMDS_MeshGroup::Contains(aElem))
84 SMDS_MeshGroup::Remove (aElem);
88 //=============================================================================
92 //=============================================================================
94 int SMESHDS_Group::GetID (const int theIndex)
96 if (theIndex < 1 || theIndex > Extent())
98 if (myCurIndex < 1 || myCurIndex > theIndex) {
103 while (myCurIndex < theIndex && More()) {
105 myCurID = Next()->GetID();
110 //=============================================================================
114 //=============================================================================
116 const SMDS_MeshElement* SMESHDS_Group::findInMesh (const int theID) const
118 SMDSAbs_ElementType aType = GetType();
119 const SMDS_MeshElement* aElem = NULL;
120 if (aType == SMDSAbs_Node) {
121 aElem = GetMesh()->FindNode(theID);
123 else if (aType != SMDSAbs_All) {
124 aElem = GetMesh()->FindElement(theID);
125 if (aElem && aType != aElem->GetType())