+SMDS_MeshElementIDFactory::SMDS_MeshElementIDFactory():
+ SMDS_MeshIDFactory(),
+ myMin(0), myMax(0)
+{
+}
+
+//=======================================================================
+//function : BindID
+//purpose :
+//=======================================================================
+bool SMDS_MeshElementIDFactory::BindID(int ID, SMDS_MeshElement * elem)
+{
+ if (myIDElements.IsBound(ID))
+ return false;
+ myIDElements.Bind(ID,elem);
+ elem->myID=ID;
+ updateMinMax (ID);
+ return true;
+}
+
+//=======================================================================
+//function : MeshElement
+//purpose :
+//=======================================================================
+SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
+{
+ if (!myIDElements.IsBound(ID))
+ return NULL;
+ return myIDElements.Find(ID);
+}
+
+
+//=======================================================================
+//function : GetFreeID
+//purpose :
+//=======================================================================
+int SMDS_MeshElementIDFactory::GetFreeID()
+{
+ int ID;
+ do {
+ ID = SMDS_MeshIDFactory::GetFreeID();
+ } while (myIDElements.IsBound(ID));
+ return ID;
+}
+
+//=======================================================================
+//function : ReleaseID
+//purpose :
+//=======================================================================
+void SMDS_MeshElementIDFactory::ReleaseID(const int ID)
+{
+ myIDElements.UnBind(ID);
+ SMDS_MeshIDFactory::ReleaseID(ID);
+ if (ID == myMax)
+ myMax = 0;
+ if (ID == myMin)
+ myMin = 0;
+}
+
+//=======================================================================
+//function : GetMaxID
+//purpose :
+//=======================================================================
+
+int SMDS_MeshElementIDFactory::GetMaxID() const
+{
+ if (myMax == 0)
+ updateMinMax();
+ return myMax;
+}
+
+//=======================================================================
+//function : GetMinID
+//purpose :
+//=======================================================================
+
+int SMDS_MeshElementIDFactory::GetMinID() const
+{
+ if (myMin == 0)
+ updateMinMax();
+ return myMin;
+}
+
+//=======================================================================
+//function : updateMinMax
+//purpose :
+//=======================================================================