Skip to content

Commit

Permalink
Add Cartesian_const_iterator to Bbox
Browse files Browse the repository at this point in the history
  • Loading branch information
afabri committed Dec 17, 2024
1 parent e7e80e5 commit 9b8be5e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Kernel_23/include/CGAL/Bbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <CGAL/use.h>
#include <CGAL/assertions.h>
#include <CGAL/Dimension.h>
#include <CGAL/Concatenate_iterator.h>
#include <boost/math/special_functions/next.hpp>

namespace CGAL {
Expand Down Expand Up @@ -164,12 +165,25 @@ template<int N, typename T>
class Bbox<Dimension_tag<N>, T> : public Impl::Bbox<std::array<T, N>, Bbox<Dimension_tag<N>,T>>
{
enum { D = N };
using array_const_iterator = typename std::array<T, N>::const_iterator;
public:
using Cartesian_const_iterator = Concatenate_iterator<array_const_iterator,array_const_iterator>;

inline constexpr int dimension() const { return D; }
Bbox(int d = 0 ) { CGAL_assertion(d==N || d==0); this->init(d ); }
Bbox(int d, const T& range) { CGAL_assertion(d==N || d==0); this->init(d, range); }
template <typename I>
Bbox(int d, I b, I e) { CGAL_assertion(d==N || d==0); this->init(d, b, e); }

Cartesian_const_iterator cartesian_begin() const
{
return Cartesian_const_iterator(min_values.end(), max_values.begin(), min_values.begin());
}

Cartesian_const_iterator cartesian_end() const
{
return Cartesian_const_iterator(min_values.end(), max_values.begin(), max_values.end(),0);
}
};

// A dynamic D-dimensional axis aligned box
Expand Down
7 changes: 7 additions & 0 deletions Kernel_23/test/Kernel_23/test_bbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,12 @@ int main()
assert(CGAL::do_overlap(bb3, bb3b));

std::cout << bb3b << std::endl;

BBox3::Cartesian_const_iterator beg = bb3b.cartesian_begin();
BBox3::Cartesian_const_iterator end = bb3b.cartesian_end();
for(; beg != end; ++beg){
std::cout << *beg << std::endl;
}

}
}

0 comments on commit 9b8be5e

Please sign in to comment.