0020978: EDF 1475 SMESH: Convert linear to quadratic on a submesh

fix the problem with adding elements (elements are not added) after
  {elems removal + addition of elements with specified IDs}:
  1) add elems with IDs 1,2,3
  2) remove elem 1 (1 stored in the pool )
  3) add elem with id 1 (1 remains in the pool)
  4) add elem with no id specified -> not added as GetFreeID() returns
     1 which is already occupied

+  virtual int GetFreeID();
This commit is contained in:
eap 2011-03-16 15:35:00 +00:00
parent fcae5eda64
commit 098d6b0723
4 changed files with 32 additions and 2 deletions

View File

@ -126,6 +126,20 @@ SMDS_MeshElement* SMDS_MeshElementIDFactory::MeshElement(int ID)
return (SMDS_MeshElement*)(elem);
}
//=======================================================================
//function : GetFreeID
//purpose :
//=======================================================================
int SMDS_MeshElementIDFactory::GetFreeID()
{
int ID;
do {
ID = SMDS_MeshIDFactory::GetFreeID();
} while ( MeshElement( ID ));
return ID;
}
//=======================================================================
//function : ReleaseID
//purpose :

View File

@ -45,6 +45,7 @@ public:
bool BindID(int ID, SMDS_MeshElement * elem);
int SetInVtkGrid(SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID);
virtual int GetFreeID();
virtual void ReleaseID(int ID, int vtkId = -1);
SMDS_ElemIteratorPtr elementsIterator() const;
virtual void Clear();

View File

@ -62,12 +62,26 @@ bool SMDS_MeshNodeIDFactory::BindID(int ID, SMDS_MeshElement * elem)
//=======================================================================
SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
{
if ((ID < 1) || (ID > myMax))
return NULL;
// commented since myMax can be 0 after ReleaseID()
// if ((ID < 1) || (ID > myMax))
// return NULL;
const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
return (SMDS_MeshElement*) (elem);
}
//=======================================================================
//function : GetFreeID
//purpose :
//=======================================================================
int SMDS_MeshNodeIDFactory::GetFreeID()
{
int ID;
do {
ID = SMDS_MeshIDFactory::GetFreeID();
} while ( MeshElement( ID ));
return ID;
}
//=======================================================================
//function : ReleaseID
//purpose :

View File

@ -41,6 +41,7 @@ public:
SMDS_MeshNodeIDFactory();
bool BindID(int ID, SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID);
virtual int GetFreeID();
virtual void ReleaseID(int ID, int vtkId = -1);
int GetMaxID() const;
int GetMinID() const;