1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMDS : implementaion of Salome mesh data structure
24 // File : SMDS_MeshGroup.cxx
25 // Author : Jean-Michel BOULCOURT
29 #pragma warning(disable:4786)
32 #include "SMDS_MeshGroup.hxx"
33 #include "utilities.h"
37 //=======================================================================
38 //function : SMDS_MeshGroup
40 //=======================================================================
42 SMDS_MeshGroup::SMDS_MeshGroup(const SMDS_Mesh * theMesh,
43 const SMDSAbs_ElementType theType)
44 :myMesh(theMesh),myType(theType), myParent(NULL), myTic(0)
48 //=======================================================================
49 //function : SMDS_MeshGroup
51 //=======================================================================
53 SMDS_MeshGroup::SMDS_MeshGroup(SMDS_MeshGroup * theParent,
54 const SMDSAbs_ElementType theType)
55 :myMesh(theParent->myMesh),myType(theType), myParent(theParent)
59 //=======================================================================
60 //function : AddSubGroup
62 //=======================================================================
64 const SMDS_MeshGroup *SMDS_MeshGroup::AddSubGroup
65 (const SMDSAbs_ElementType theType)
67 const SMDS_MeshGroup * subgroup = new SMDS_MeshGroup(this,theType);
68 myChildren.insert(myChildren.end(),subgroup);
72 //=======================================================================
73 //function : RemoveSubGroup
75 //=======================================================================
77 bool SMDS_MeshGroup::RemoveSubGroup(const SMDS_MeshGroup * theGroup)
80 list<const SMDS_MeshGroup*>::iterator itgroup;
81 for(itgroup=myChildren.begin(); itgroup!=myChildren.end(); itgroup++)
83 const SMDS_MeshGroup* subgroup=*itgroup;
84 if (subgroup == theGroup)
87 myChildren.erase(itgroup);
94 //=======================================================================
95 //function : RemoveFromParent
97 //=======================================================================
99 bool SMDS_MeshGroup::RemoveFromParent()
102 if (myParent==NULL) return false;
105 return (myParent->RemoveSubGroup(this));
108 //=======================================================================
111 //=======================================================================
113 void SMDS_MeshGroup::Clear()
116 myType = SMDSAbs_All;
120 //=======================================================================
123 //=======================================================================
125 bool SMDS_MeshGroup::Add(const SMDS_MeshElement * theElem)
127 // the type of the group is determined by the first element added
128 if (myElements.empty()) {
129 myType = theElem->GetType();
131 else if (theElem->GetType() != myType) {
132 MESSAGE("SMDS_MeshGroup::Add : Type Mismatch "<<theElem->GetType()<<"!="<<myType);
136 myElements.insert(myElements.end(), theElem);
142 //=======================================================================
145 //=======================================================================
147 bool SMDS_MeshGroup::Remove(const SMDS_MeshElement * theElem)
149 set<const SMDS_MeshElement *>::iterator found = myElements.find(theElem);
150 if ( found != myElements.end() ) {
151 myElements.erase(found);
152 if (myElements.empty()) myType = SMDSAbs_All;
159 //=======================================================================
160 //function : Contains
162 //=======================================================================
164 bool SMDS_MeshGroup::Contains(const SMDS_MeshElement * theElem) const
166 return myElements.find(theElem)!=myElements.end();
169 //=======================================================================
172 //=======================================================================
174 void SMDS_MeshGroup::SetType(const SMDSAbs_ElementType theType)