From: abn Date: Tue, 15 Jan 2019 13:09:52 +0000 (+0100) Subject: Rewrote eraseCurrent() in a more efficient way + disabling one test not stable enough... X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=043588c2cb1e028459901fdf9ce8cfaeae9a2d8f;p=tools%2Fmedcoupling.git Rewrote eraseCurrent() in a more efficient way + disabling one test not stable enough yet. --- diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx index e5188efae..dafabff99 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.cxx @@ -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(); +} diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx index db517eff3..acd68e865 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DAbstractEdge.hxx @@ -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::iterator _deep_it; std::list* _list_handle; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx index e19ba2dce..041bef41d 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.cxx @@ -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::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::const_iterator iter=_sub_edges.begin(); diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx index 69e381b4d..8b10dc3ff 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DComposedEdge.hxx @@ -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; diff --git a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx index a9da6a907..298a704ac 100644 --- a/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx +++ b/src/INTERP_KERNEL/Geometric2D/InterpKernelGeo2DQuadraticPolygon.cxx @@ -698,25 +698,20 @@ void QuadraticPolygon::buildPartitionsAbs(QuadraticPolygon& other, std::set 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; - } } }