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.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : SMDS_MeshGroup.cxx
24 // Author : Jean-Michel BOULCOURT
28 #pragma warning(disable:4786)
31 #include "SMDS_MeshGroup.hxx"
32 #include "utilities.h"
36 //=======================================================================
37 //function : SMDS_MeshGroup
39 //=======================================================================
41 SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
42 const SMDSAbs_ElementType theType)
43 :myMesh(theMesh),myType(theType), myParent(NULL)
47 //=======================================================================
48 //function : SMDS_MeshGroup
50 //=======================================================================
52 SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * theParent,
53 const SMDSAbs_ElementType theType)
54 :myMesh(theParent->myMesh),myType(theType), myParent(theParent)
58 //=======================================================================
59 //function : AddSubGroup
61 //=======================================================================
63 const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup
64 (const SMDSAbs_ElementType theType)
66 const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this,theType);
67 myChildren.insert(myChildren.end(),subgroup);
71 //=======================================================================
72 //function : RemoveSubGroup
74 //=======================================================================
76 bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * theGroup)
79 list<const SMDS_MeshGroup*>::iterator itgroup;
80 for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
82 const SMDS_MeshGroup* subgroup=*itgroup;
83 if (subgroup == theGroup)
86 myChildren.erase(itgroup);
93 //=======================================================================
94 //function : RemoveFromParent
96 //=======================================================================
98 bool SMDS_MeshGroup::RemoveFromParent()
101 if (myParent==NULL) return false;
104 return (myParent->RemoveSubGroup(this));
107 //=======================================================================
110 //=======================================================================
112 void SMDS_MeshGroup::Clear()
115 myType = SMDSAbs_All;
118 //=======================================================================
121 //=======================================================================
123 void SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
125 // the type of the group is determined by the first element added
126 if (myElements.empty()) myType = theElem->GetType();
127 else if (theElem->GetType() != myType) {
128 MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
132 myElements.insert(theElem);
135 //=======================================================================
138 //=======================================================================
140 bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
142 TIterator found = myElements.find(theElem);
143 if ( found != myElements.end() ) {
144 myElements.erase(found);
145 if (myElements.empty()) myType = SMDSAbs_All;
151 //=======================================================================
152 //function : Contains
154 //=======================================================================
156 bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
158 return myElements.find(theElem)!=myElements.end();
161 //=======================================================================
164 //=======================================================================
166 void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)