From 098d6b0723b6dea4120e4238fc2c9ec3972efb29 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 16 Mar 2011 15:35:00 +0000 Subject: [PATCH] 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(); --- src/SMDS/SMDS_MeshElementIDFactory.cxx | 14 ++++++++++++++ src/SMDS/SMDS_MeshElementIDFactory.hxx | 1 + src/SMDS/SMDS_MeshNodeIDFactory.cxx | 18 ++++++++++++++++-- src/SMDS/SMDS_MeshNodeIDFactory.hxx | 1 + 4 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/SMDS/SMDS_MeshElementIDFactory.cxx b/src/SMDS/SMDS_MeshElementIDFactory.cxx index ae315ba0f..1abf9e81f 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.cxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.cxx @@ -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 : diff --git a/src/SMDS/SMDS_MeshElementIDFactory.hxx b/src/SMDS/SMDS_MeshElementIDFactory.hxx index 3ce1674b4..5dee3f3a1 100644 --- a/src/SMDS/SMDS_MeshElementIDFactory.hxx +++ b/src/SMDS/SMDS_MeshElementIDFactory.hxx @@ -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(); diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.cxx b/src/SMDS/SMDS_MeshNodeIDFactory.cxx index 4a310419d..67e819e85 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.cxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.cxx @@ -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 : diff --git a/src/SMDS/SMDS_MeshNodeIDFactory.hxx b/src/SMDS/SMDS_MeshNodeIDFactory.hxx index a79d68ea1..ab553bd8d 100644 --- a/src/SMDS/SMDS_MeshNodeIDFactory.hxx +++ b/src/SMDS/SMDS_MeshNodeIDFactory.hxx @@ -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; -- 2.39.2