Iterating over each point within a geometry::box
I want to iterate over every point within a geometry::model::box<point>. I
want to be able to do that with iterators so that I can also use all (or
most of) the standard algorithms like for_each or all_of or etc.
Initially my code used several loops, one for each axis, like so for a 2d
point:
for (int x = box.min_corner().template get<0>(); x <=
box.max_corner().template get<0>(); ++x) {
for (int y = box.min_corner().template get<1>(); y <=
box.max_corner().template get<1>(); ++y) {
callback(point(x,y))
}
}
There are several places where this occurs. Some loops have the x axis
first, others the y axis first -- and this has performance issues when
translating the point to a container. Some loops were erroneously
considering right-open intervals with less-than instead of
less-than-or-equal-to comparisons. So I've had to fix bounding bugs and
performance issues in multiple places that are caused by these manual loops.
I've gone and unified a lot of that to use templated functions that
basically duplicate some of the functionality in the standard. But that's
not tractable and still doesn't use iterators so most of <algorithm> is
still off-limits:
namespace mynamespace {
template
participants (1)
-
Keith Bennett