Salome HOME
NRI : First integration.
[modules/smesh.git] / src / SMDS / SMDS_MeshElementIDFactory.lxx
1 // File:        SMDS_MeshElementIDFactory.lxx
2 // Created:     Tue May  7 16:30:34 2002
3 // Author:      Jean-Michel BOULCOURT
4 //              <jmb@localhost.localdomain>
5
6 //=======================================================================
7 //function : GetFreeID
8 //purpose  : 
9 //=======================================================================
10 inline Standard_Integer  SMDS_MeshElementIDFactory::GetFreeID()
11 {
12   if (myPoolOfID.IsEmpty()) {
13     ++myMaxID;
14     while (myIDElements.IsBound(myMaxID)) ++myMaxID;
15     return myMaxID;
16   } else {
17     Standard_Integer ID = myPoolOfID.Top();
18     myPoolOfID.Pop();
19     return ID;
20   }
21
22 }
23
24 //=======================================================================
25 //function : ReleaseID
26 //purpose  : 
27 //=======================================================================
28 inline void SMDS_MeshElementIDFactory::ReleaseID(const Standard_Integer ID)
29 {
30   myIDElements.UnBind(ID);
31   if (ID < myMaxID)
32     myPoolOfID.Push(ID);
33
34 }
35
36 //=======================================================================
37 //function : BindID
38 //purpose  : 
39 //=======================================================================
40 inline Standard_Boolean SMDS_MeshElementIDFactory::BindID(const Standard_Integer ID,
41                                               const Handle(SMDS_MeshElement)& elem)
42 {
43   return myIDElements.Bind(ID,elem);
44
45 }
46
47 //=======================================================================
48 //function : MeshElement
49 //purpose  : 
50 //=======================================================================
51 inline Handle(SMDS_MeshElement) SMDS_MeshElementIDFactory::MeshElement(const Standard_Integer ID) const
52 {
53   return myIDElements.Find(ID);
54
55 }
56