Use standard std::count_if. NFC.
This commit is contained in:
parent
8c750cef9c
commit
93184c54ac
@ -480,11 +480,6 @@ public:
|
||||
const T *cbegin() const { return begin(); }
|
||||
const T *cend() const { return end(); }
|
||||
|
||||
template<typename F>
|
||||
size_t CountIf(F &&predicate) const {
|
||||
return std::count_if(begin(), end(), std::forward<F&&>(predicate));
|
||||
}
|
||||
|
||||
void ClearTags() {
|
||||
for(auto &elt : *this) { elt.tag = 0; }
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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<int>(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<int>(winding);
|
||||
}
|
||||
|
||||
void SPolygon::FixContourDirections() {
|
||||
|
Loading…
Reference in New Issue
Block a user