diff --git a/src/dsc.h b/src/dsc.h index 087a664..ce92c59 100644 --- a/src/dsc.h +++ b/src/dsc.h @@ -480,11 +480,6 @@ public: const T *cbegin() const { return begin(); } const T *cend() const { return end(); } - template - size_t CountIf(F &&predicate) const { - return std::count_if(begin(), end(), std::forward(predicate)); - } - void ClearTags() { for(auto &elt : *this) { elt.tag = 0; } } diff --git a/src/group.cpp b/src/group.cpp index 3e863f5..ad00efe 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -50,7 +50,8 @@ bool Group::IsVisible() { } size_t Group::GetNumConstraints() { - return SK.constraint.CountIf([&](Constraint const & c) { return c.group == h; }); + return std::count_if(SK.constraint.begin(), SK.constraint.end(), + [&](Constraint const &c) { return c.group == h; }); } Vector Group::ExtrusionGetVector() { diff --git a/src/polygon.cpp b/src/polygon.cpp index 4589f81..33f9b01 100644 --- a/src/polygon.cpp +++ b/src/polygon.cpp @@ -302,16 +302,10 @@ bool SEdgeList::AssemblePolygon(SPolygon *dest, SEdge *errorAt, bool keepDir) co // but they are considered to cross if they are coincident and overlapping. // If pi is not NULL, then a crossing is returned in that. //----------------------------------------------------------------------------- -int SEdgeList::AnyEdgeCrossings(Vector a, Vector b, - Vector *ppi, SPointList *spl) const -{ - int cnt = 0; - for(const SEdge *se = l.First(); se; se = l.NextAfter(se)) { - if(se->EdgeCrosses(a, b, ppi, spl)) { - cnt++; - } - } - return cnt; +int SEdgeList::AnyEdgeCrossings(Vector a, Vector b, Vector *ppi, SPointList *spl) const { + auto cnt = std::count_if(l.begin(), l.end(), + [&](SEdge const &se) { return se.EdgeCrosses(a, b, ppi, spl); }); + return static_cast(cnt); } //----------------------------------------------------------------------------- @@ -707,15 +701,10 @@ bool SPolygon::ContainsPoint(Vector p) const { } int SPolygon::WindingNumberForPoint(Vector p) const { - int winding = 0; - int i; - for(i = 0; i < l.n; i++) { - const SContour *sc = &(l[i]); - if(sc->ContainsPointProjdToNormal(normal, p)) { - winding++; - } - } - return winding; + auto winding = std::count_if(l.begin(), l.end(), [&](const SContour &sc) { + return sc.ContainsPointProjdToNormal(normal, p); + }); + return static_cast(winding); } void SPolygon::FixContourDirections() {