WIP: after my conversation with myself on github

This commit is contained in:
Andreas Fabri 2024-08-14 17:04:14 +01:00
parent 68ecd6d45d
commit 9ade3d221e
3 changed files with 10 additions and 5 deletions

View File

@ -19,6 +19,7 @@
#include <iostream> #include <iostream>
#include <iterator> #include <iterator>
#include <CGAL/assertions.h> #include <CGAL/assertions.h>
#include <CGAL/Dimension.h>
namespace CGAL { namespace CGAL {
namespace Impl { namespace Impl {
@ -122,9 +123,12 @@ protected:
} }
template <typename Di, typename T>
class Bbox;
// A fixed D-dimensional axis aligned box // A fixed D-dimensional axis aligned box
template<unsigned int N, typename T> template<unsigned int N, typename T>
class Bbox : public Impl::Bbox<std::array<T, N>, Bbox<N,T>> class Bbox<Dimension_tag<N>> : public Impl::Bbox<std::array<T, N>, Bbox<N,T>>
{ {
enum { D = N }; enum { D = N };
public: public:
@ -137,7 +141,7 @@ public:
// A dynamic D-dimensional axis aligned box // A dynamic D-dimensional axis aligned box
template<typename T> template<typename T>
class Bbox<0,T> : public Impl::Bbox<std::vector<T>, Bbox<0,T>> class Bbox<Dynamic_dimension_tag,T> : public Impl::Bbox<std::vector<T>, Bbox<0,T>>
{ {
public: public:
inline int dimension() const { return this->min_values.size(); } inline int dimension() const { return this->min_values.size(); }

View File

@ -82,7 +82,7 @@ int main()
{ {
//Dimension d //Dimension d
typedef CGAL::Bbox<3,double> BBox3; typedef CGAL::Bbox<CGAL::Dimension_tag<3>,double> BBox3;
BBox3 bb3(3), bb3a(3,1.0); BBox3 bb3(3), bb3a(3,1.0);
assert(bb3.dimension() == 3); assert(bb3.dimension() == 3);
assert(bb3 != bb3a); assert(bb3 != bb3a);

View File

@ -1010,15 +1010,16 @@ namespace CartesianDKernelFunctors {
template<class R_> struct ConstructBbox : private Store_kernel<R_> { template<class R_> struct ConstructBbox : private Store_kernel<R_> {
CGAL_FUNCTOR_INIT_STORE(ConstructBbox) CGAL_FUNCTOR_INIT_STORE(ConstructBbox)
typedef R_ R; typedef R_ R;
typedef typename R::Dimension Dimension;
typedef typename Get_type<R, RT_tag>::type RT; typedef typename Get_type<R, RT_tag>::type RT;
typedef typename Get_type<R, Point_tag>::type Point; typedef typename Get_type<R, Point_tag>::type Point;
typedef typename Get_functor<R, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CI; typedef typename Get_functor<R, Construct_ttag<Point_cartesian_const_iterator_tag> >::type CI;
typedef Bbox<DIM,double> result_type; typedef Bbox<Dimension,double> result_type;
typedef Point argument_type; typedef Point argument_type;
result_type operator()(Point const&a)const{ result_type operator()(Point const&a)const{
CI ci(this->kernel()); CI ci(this->kernel());
To_interval f; To_interval f;
return result_type(DIM, make_transforming_iterator(ci(a,Begin_tag()),f), make_transforming_iterator(ci(a,End_tag())), f); return result_type(a.dimension(), make_transforming_iterator(ci(a,Begin_tag()),f), make_transforming_iterator(ci(a,End_tag())), f);
} }
}; };
} }