1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 OPEN CASCADE
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.opencascade.org or email : webmaster@opencascade.org
23 // File : SMDS_MeshGroup.cxx
24 // Author : Jean-Michel BOULCOURT
27 #include "SMDS_MeshGroup.hxx"
28 #include "utilities.h"
32 //=======================================================================
33 //function : SMDS_MeshGroup
35 //=======================================================================
37 SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
38 const SMDSAbs_ElementType theType)
39 :myMesh(theMesh),myType(theType), myParent(NULL)
43 //=======================================================================
44 //function : SMDS_MeshGroup
46 //=======================================================================
48 SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * theParent,
49 const SMDSAbs_ElementType theType)
50 :myMesh(theParent->myMesh),myType(theType), myParent(theParent)
54 //=======================================================================
55 //function : AddSubGroup
57 //=======================================================================
59 const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup
60 (const SMDSAbs_ElementType theType)
62 const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this,theType);
63 myChildren.insert(myChildren.end(),subgroup);
67 //=======================================================================
68 //function : RemoveSubGroup
70 //=======================================================================
72 bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * theGroup)
75 list<const SMDS_MeshGroup*>::iterator itgroup;
76 for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
78 const SMDS_MeshGroup* subgroup=*itgroup;
79 if (subgroup == theGroup)
82 myChildren.erase(itgroup);
89 //=======================================================================
90 //function : RemoveFromParent
92 //=======================================================================
94 bool SMDS_MeshGroup::RemoveFromParent()
97 if (myParent==NULL) return false;
100 return (myParent->RemoveSubGroup(this));
103 //=======================================================================
106 //=======================================================================
108 void SMDS_MeshGroup::Clear()
111 myType = SMDSAbs_All;
114 //=======================================================================
117 //=======================================================================
119 void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
121 // the type of the group is determined by the first element added
122 if (myElements.empty()) myType = theElem->GetType();
123 else if (theElem->GetType() != myType)
124 MESSAGE("SMDS_MeshGroup::Add : Type Mismatch");
126 myElements.insert(theElem);
129 //=======================================================================
132 //=======================================================================
134 void SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
136 myElements.erase(theElem);
137 if (myElements.empty()) myType = SMDSAbs_All;
140 //=======================================================================
141 //function : Contains
143 //=======================================================================
145 bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
147 return myElements.find(theElem)!=myElements.end();
150 //=======================================================================
153 //=======================================================================
155 void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)