}
}
+/*!
+ * 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();
+}
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;
_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();
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;
*/
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;
- }
}
}