Version: 6.3.1
Public Member Functions | Protected Member Functions | Protected Attributes

SMDS_MeshIDFactory Class Reference

#include <SMDS_MeshIDFactory.hxx>

Inheritance diagram for SMDS_MeshIDFactory:
Inheritance graph
[legend]

Public Member Functions

int GetFreeID ()
virtual void ReleaseID (int ID, int vtkId=-1)
virtual void Clear ()
void SetMesh (SMDS_Mesh *mesh)
SMDS_MeshGetMesh ()
bool isPoolIdEmpty ()
virtual void emptyPool (int maxId)
void adjustMaxId (int ID)

Protected Member Functions

 SMDS_MeshIDFactory ()

Protected Attributes

int myMaxID
std::set< intmyPoolOfID
SMDS_MeshmyMesh

Detailed Description

Definition at line 37 of file SMDS_MeshIDFactory.hxx.


Constructor & Destructor Documentation

SMDS_MeshIDFactory::SMDS_MeshIDFactory ( ) [protected]

Definition at line 39 of file SMDS_MeshIDFactory.cxx.

                                      :myMaxID(0), myMesh(0)
{
}

Member Function Documentation

void SMDS_MeshIDFactory.adjustMaxId ( int  ID)

Definition at line 48 of file SMDS_MeshIDFactory.hxx.

Referenced by SMDS_Mesh.AddNodeWithID().

{ if (ID > myMaxID) myMaxID = ID;};
void SMDS_MeshIDFactory::Clear ( ) [virtual]

Reimplemented in SMDS_MeshElementIDFactory, and SMDS_MeshNodeIDFactory.

Definition at line 92 of file SMDS_MeshIDFactory.cxx.

References myMaxID, and myPoolOfID.

{
        myMaxID = 0;
        myPoolOfID.clear();
}
void SMDS_MeshIDFactory::emptyPool ( int  maxId) [virtual]

Reimplemented in SMDS_MeshNodeIDFactory.

Definition at line 108 of file SMDS_MeshIDFactory.cxx.

References MESSAGE, myMaxID, and myPoolOfID.

{
        MESSAGE("SMDS_MeshIDFactory::emptyPool " << myMaxID << " --> " << maxId);
        myMaxID = maxId;
        myPoolOfID.clear();
}
int SMDS_MeshIDFactory::GetFreeID ( )

Reimplemented in SMDS_MeshElementIDFactory, and SMDS_MeshNodeIDFactory.

Definition at line 43 of file SMDS_MeshIDFactory.cxx.

References myMaxID, and myPoolOfID.

{
        int newid;
        if (myPoolOfID.empty())
        {
            newid = ++myMaxID;
            //MESSAGE("GetFreeID new " << newid);
        }
        else
        {
                set<int>::iterator i = myPoolOfID.begin();
                newid = *i;//myPoolOfID.top();
                myPoolOfID.erase( i );//myPoolOfID.pop();
                //MESSAGE("GetFreeID pool " << newid);
        }
    return newid;
}
SMDS_Mesh * SMDS_MeshIDFactory::GetMesh ( )

Definition at line 103 of file SMDS_MeshIDFactory.cxx.

References myMesh.

Referenced by SMDS_MeshNodeIDFactory.MeshElement(), and SMDS_MeshElementIDFactory.MeshElement().

{
        return myMesh;
}
bool SMDS_MeshIDFactory.isPoolIdEmpty ( )

Definition at line 46 of file SMDS_MeshIDFactory.hxx.

{ return myPoolOfID.empty(); };
void SMDS_MeshIDFactory::ReleaseID ( int  ID,
int  vtkId = -1 
) [virtual]

Reimplemented in SMDS_MeshElementIDFactory, and SMDS_MeshNodeIDFactory.

Definition at line 65 of file SMDS_MeshIDFactory.cxx.

References myMaxID, and myPoolOfID.

{
  if ( ID > 0 )
  {
    if ( ID < myMaxID )
    {
      myPoolOfID.insert(ID);
    }
    else if ( ID == myMaxID )
    {
      --myMaxID;
      if ( !myPoolOfID.empty() ) // assure that myMaxID is not in myPoolOfID
      {
        set<int>::iterator i = --myPoolOfID.end();
        while ( i != myPoolOfID.begin() && myMaxID == *i ) {
          --myMaxID; --i;
        }
        if ( myMaxID == *i )
          --myMaxID; // begin of myPoolOfID reached
        else
          ++i;
        myPoolOfID.erase( i, myPoolOfID.end() );
      }
    }
  }
}
void SMDS_MeshIDFactory::SetMesh ( SMDS_Mesh mesh)

Definition at line 98 of file SMDS_MeshIDFactory.cxx.

References PAL_MESH_041_mesh.mesh, and myMesh.

Referenced by SMDS_Mesh.SMDS_Mesh().

{
        myMesh = mesh;
}

Field Documentation

Definition at line 51 of file SMDS_MeshIDFactory.hxx.

Referenced by Clear(), emptyPool(), GetFreeID(), and ReleaseID().

std::set<int> SMDS_MeshIDFactory.myPoolOfID [protected]

Definition at line 52 of file SMDS_MeshIDFactory.hxx.

Referenced by Clear(), emptyPool(), GetFreeID(), and ReleaseID().

Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS