1 // Copyright (C) 2007-2008 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.
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
22 // SMESH SMDS : implementaion of Salome mesh data structure
23 // File : SMDS_MeshElementIDFactory.cxx
24 // Author : Jean-Michel BOULCOURT
28 #pragma warning(disable:4786)
31 #include "SMDS_MeshElementIDFactory.hxx"
32 #include "SMDS_MeshElement.hxx"
36 //=======================================================================
37 //function : SMDS_MeshElementIDFactory
39 //=======================================================================
40 SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
46 //=======================================================================
49 //=======================================================================
50 bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
52 if (myIDElements.IsBound(ID))
54 myIDElements.Bind(ID,elem);
60 //=======================================================================
61 //function : MeshElement
63 //=======================================================================
64 SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
66 if (!myIDElements.IsBound(ID))
68 return myIDElements.Find(ID);
72 //=======================================================================
73 //function : GetFreeID
75 //=======================================================================
76 int SMDS_MeshElementIDFactory::GetFreeID()
80 ID = SMDS_MeshIDFactory::GetFreeID();
81 } while (myIDElements.IsBound(ID));
85 //=======================================================================
86 //function : ReleaseID
88 //=======================================================================
89 void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
91 myIDElements.UnBind(ID);
92 SMDS_MeshIDFactory::ReleaseID(ID);
99 //=======================================================================
100 //function : GetMaxID
102 //=======================================================================
104 int SMDS_MeshElementIDFactory::GetMaxID() const
111 //=======================================================================
112 //function : GetMinID
114 //=======================================================================
116 int SMDS_MeshElementIDFactory::GetMinID() const
123 //=======================================================================
124 //function : updateMinMax
126 //=======================================================================
128 void SMDS_MeshElementIDFactory::updateMinMax() const
130 myMin = IntegerLast();
132 SMDS_IdElementMap::Iterator it(myIDElements);
133 for (; it.More(); it.Next())
134 updateMinMax (it.Key());
135 if (myMin == IntegerLast())
139 //=======================================================================
140 //function : elementsIterator
141 //purpose : Return an iterator on elements of the factory
142 //=======================================================================
144 class SMDS_Fact_MyElemIterator:public SMDS_ElemIterator
146 SMDS_IdElementMap::Iterator myIterator;
148 SMDS_Fact_MyElemIterator(const SMDS_IdElementMap& s):myIterator(s)
153 return myIterator.More() != Standard_False;
156 const SMDS_MeshElement* next()
158 const SMDS_MeshElement* current = myIterator.Value();
164 SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
166 return SMDS_ElemIteratorPtr
167 (new SMDS_Fact_MyElemIterator(myIDElements));
170 void SMDS_MeshElementIDFactory::Clear()
172 myIDElements.Clear();
174 SMDS_MeshIDFactory::Clear();