Salome HOME
0020978: EDF 1475 SMESH: Convert linear to quadratic on a submesh
authoreap <eap@opencascade.com>
Wed, 16 Mar 2011 15:35:00 +0000 (15:35 +0000)
committereap <eap@opencascade.com>
Wed, 16 Mar 2011 15:35:00 +0000 (15:35 +0000)
  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
src/SMDS/SMDS_MeshElementIDFactory.hxx
src/SMDS/SMDS_MeshNodeIDFactory.cxx
src/SMDS/SMDS_MeshNodeIDFactory.hxx

index ae315ba0f9dad3ee7c3632de908825494d97c908..1abf9e81f24928a9d0c42c65c1d3cdc6f624d1c5 100644 (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  : 
index 3ce1674b4b05857da742e93c8fd108649df64b74..5dee3f3a1fb538516969a72803bd3c3a465afc1f 100644 (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();
index 4a310419d644f877a7c09f68399b4123137848b3..67e819e85ac07371635dcf3a8aaffc834cc850b2 100644 (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  : 
index a79d68ea1a2c6a578b637480dd4cce8f6359b62f..ab553bd8d5e0b99e94c02a5e97b65a95765f9603 100644 (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;