]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Rewrote eraseCurrent() in a more efficient way + disabling one test not stable enough...
authorabn <adrien.bruneton@cea.fr>
Tue, 15 Jan 2019 13:09:52 +0000 (14:09 +0100)
committerabn <adrien.bruneton@cea.fr>
Wed, 16 Jan 2019 07:55:12 +0000 (08:55 +0100)
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx
src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx

index e5188efaedfe77a59c8cff6b160cf2de3baa8f9d..dafabff996423509785bc9f0b345438c574d34c5 100644 (file)
@@ -116,3 +116,13 @@ void IteratorOnComposedEdge::insertElemEdges(ComposedEdge *elems, bool changeMyS
     }
 }
 
+/*!
+ * Erase current element and place iterator onto the PREVIOUS element (eventually looping)
+ */
+void IteratorOnComposedEdge::eraseCurrent()
+{
+  delete(*_deep_it);
+  _deep_it = _list_handle->erase(_deep_it);
+  // By default erase place the iterator after the removed element:
+  previousLoop();
+}
index db517eff3ed4cb676f53cd1c4e7dc81d3d03f45b..acd68e865ea6143916cd65aefbc303fd4862ff17 100644 (file)
@@ -59,6 +59,7 @@ namespace INTERP_KERNEL
     INTERPKERNEL_EXPORT ElementaryEdge *current() { return *_deep_it; }
     INTERPKERNEL_EXPORT void assignMySelfToAllElems(ComposedEdge *elems);
     INTERPKERNEL_EXPORT void insertElemEdges(ComposedEdge *elems, bool changeMySelf);
+    INTERPKERNEL_EXPORT void eraseCurrent();
   private:
     std::list<ElementaryEdge *>::iterator _deep_it;
     std::list<ElementaryEdge *>* _list_handle;
index e19ba2dce671643b419dbd49a0b3d5ded74f7bd3..041bef41dbf83d79e2606807f4f6a72c0a60b3b7 100644 (file)
@@ -97,18 +97,6 @@ void ComposedEdge::pushBack(ComposedEdge *elem)
   _sub_edges.insert(_sub_edges.end(),elemsOfElem->begin(),elemsOfElem->end());
 }
 
-/*!
- * Warning! This is highly inefficient ...
- */
-void ComposedEdge::erase(int index)
-{
-  // Not the most efficient thing to do, but rarely called ...
-  std::list<ElementaryEdge *>::const_iterator it = _sub_edges.begin();  // we want const!
-  for (int i=0; i < index; i++, it++);
-  delete (*it);
-  _sub_edges.erase(it++, it);
-}
-
 ElementaryEdge *ComposedEdge::operator[](int i) const
 {
   std::list<ElementaryEdge *>::const_iterator iter=_sub_edges.begin();
index 69e381b4d3db4cce56a44d43bd70189f949438a3..8b10dc3ff445628d5e7105767d708aaabeb989c1 100644 (file)
@@ -98,7 +98,6 @@ namespace INTERP_KERNEL
     INTERPKERNEL_EXPORT void pushBack(Edge *edge, bool direction=true);
     INTERPKERNEL_EXPORT void pushBack(ElementaryEdge *elem);
     INTERPKERNEL_EXPORT void pushBack(ComposedEdge *elem);
-    INTERPKERNEL_EXPORT void erase(int index);
     INTERPKERNEL_EXPORT int size() const { return (int)_sub_edges.size(); }
     INTERPKERNEL_EXPORT ElementaryEdge *operator[](int i) const;
     INTERPKERNEL_EXPORT Node *getEndNode() const;
index a9da6a90795f0f514144e98531150f5df331c19a..298a704acd51a0de450b9aa58631bf891e6bc399 100644 (file)
@@ -698,25 +698,20 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, std::set<INTE
  */
 void QuadraticPolygon::cleanDegeneratedConsecutiveEdges()
 {
-  IteratorOnComposedEdge it2ii(this);
+  IteratorOnComposedEdge it(this);
   ElementaryEdge * prevEdge = 0;
-  int kk = 0;
   if  (recursiveSize() > 2)
-    for(it2ii.first();!it2ii.finished();it2ii.next())
+    for(it.first();!it.finished();it.next())
       {
-        ElementaryEdge * cur = it2ii.current();
+        ElementaryEdge * cur = it.current();
         if (prevEdge && prevEdge->hasSameExtremities(*cur))
           {
-            // Delete the two 'identical' edges:
-            it2ii.previousLoop(); it2ii.previousLoop();
-            erase(--kk); erase(kk);
-            prevEdge = it2ii.current();
+            it.eraseCurrent();
+            it.eraseCurrent();
+            prevEdge = it.current();
           }
         else
-          {
-            kk++;
             prevEdge = cur;
-          }
       }
 }