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
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);
130 myElements.insert(theElem);
133 //=======================================================================
136 //=======================================================================
138 void SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
140 myElements.erase(theElem);
141 if (myElements.empty()) myType = SMDSAbs_All;
144 //=======================================================================
145 //function : Contains
147 //=======================================================================
149 bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
151 return myElements.find(theElem)!=myElements.end();
154 //=======================================================================
157 //=======================================================================
159 void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)