1 // SMESH SMDS : implementaion of Salome mesh data structure
3 // Copyright (C) 2003 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : SMDS_MeshElementIDFactory.cxx
25 // Author : Jean-Michel BOULCOURT
29 #pragma warning(disable:4786)
32 #include "SMDS_MeshElementIDFactory.hxx"
33 #include "SMDS_MeshElement.hxx"
37 //=======================================================================
38 //function : SMDS_MeshElementIDFactory
40 //=======================================================================
41 SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
47 //=======================================================================
50 //=======================================================================
51 bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
53 if (myIDElements.IsBound(ID))
55 myIDElements.Bind(ID,elem);
61 //=======================================================================
62 //function : MeshElement
64 //=======================================================================
65 SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
67 if (!myIDElements.IsBound(ID))
69 return myIDElements.Find(ID);
73 //=======================================================================
74 //function : GetFreeID
76 //=======================================================================
77 int SMDS_MeshElementIDFactory::GetFreeID()
81 ID = SMDS_MeshIDFactory::GetFreeID();
82 } while (myIDElements.IsBound(ID));
86 //=======================================================================
87 //function : ReleaseID
89 //=======================================================================
90 void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
92 myIDElements.UnBind(ID);
93 SMDS_MeshIDFactory::ReleaseID(ID);
100 //=======================================================================
101 //function : GetMaxID
103 //=======================================================================
105 int SMDS_MeshElementIDFactory::GetMaxID() const
112 //=======================================================================
113 //function : GetMinID
115 //=======================================================================
117 int SMDS_MeshElementIDFactory::GetMinID() const
124 //=======================================================================
125 //function : updateMinMax
127 //=======================================================================
129 void SMDS_MeshElementIDFactory::updateMinMax() const
131 myMin = IntegerLast();
133 SMDS_IdElementMap::Iterator it(myIDElements);
134 for (; it.More(); it.Next())
135 updateMinMax (it.Key());
136 if (myMin == IntegerLast())
140 //=======================================================================
141 //function : elementsIterator
142 //purpose : Return an iterator on elements of the factory
143 //=======================================================================
145 class SMDS_Fact_MyElemIterator:public SMDS_ElemIterator
147 SMDS_IdElementMap::Iterator myIterator;
149 SMDS_Fact_MyElemIterator(const SMDS_IdElementMap& s):myIterator(s)
154 return myIterator.More() != Standard_False;
157 const SMDS_MeshElement* next()
159 const SMDS_MeshElement* current = myIterator.Value();
165 SMDS_ElemIteratorPtr SMDS_MeshElementIDFactory::elementsIterator() const
167 return SMDS_ElemIteratorPtr
168 (new SMDS_Fact_MyElemIterator(myIDElements));