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); 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 //function : ReleaseID
//purpose : //purpose :

View File

@ -45,6 +45,7 @@ public:
bool BindID(int ID, SMDS_MeshElement * elem); bool BindID(int ID, SMDS_MeshElement * elem);
int SetInVtkGrid(SMDS_MeshElement * elem); int SetInVtkGrid(SMDS_MeshElement * elem);
SMDS_MeshElement * MeshElement(int ID); SMDS_MeshElement * MeshElement(int ID);
virtual int GetFreeID();
virtual void ReleaseID(int ID, int vtkId = -1); virtual void ReleaseID(int ID, int vtkId = -1);
SMDS_ElemIteratorPtr elementsIterator() const; SMDS_ElemIteratorPtr elementsIterator() const;
virtual void Clear(); 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) SMDS_MeshElement* SMDS_MeshNodeIDFactory::MeshElement(int ID)
{ {
if ((ID < 1) || (ID > myMax)) // commented since myMax can be 0 after ReleaseID()
return NULL; // if ((ID < 1) || (ID > myMax))
// return NULL;
const SMDS_MeshElement* elem = GetMesh()->FindNode(ID); const SMDS_MeshElement* elem = GetMesh()->FindNode(ID);
return (SMDS_MeshElement*) (elem); 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 //function : ReleaseID
//purpose : //purpose :

View File

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