
Index: ChangeLog from Nicolas Ballas <ballas@lrde.epita.fr> Add internal::box_ and box2d classes. * oln/core/rle/rle_image.hh, oln/core/sparse/sparse_image.hh * oln/core/encode/sparse_encode.hh, oln/core/encode/rle_encode.hh: change licence and header name * oln/core/1d/box1d.hh: move box_ to gen_box * oln/core/2d/box2d.hh: box2d is know a real class * oln/core/gen/box.hh: rename box_ class as gen_box * oln/core/gen/fbbox.hh: move box_ to gen_box * oln/core/internal/box.hh: New class internal::box_ * oln/core/internal/point_set_base.hh, oln/core/internal/image_base.hh: . * oln/core/internal/point_set_std_based.hh: Change vtypes 1d/box1d.hh | 2 2d/box2d.hh | 50 ++++ encode/rle_encode.hh | 1 encode/sparse_encode.hh | 9 gen/box.hh | 142 ++++++------- gen/fbbox.hh | 10 internal/box.hh | 464 +++++++++++++++++++++++++++++++++++++++++++++ internal/image_base.hh | 14 - internal/point_set_base.hh | 7 rle/rle_image.hh | 3 sparse/sparse_image.hh | 12 - 11 files changed, 620 insertions(+), 94 deletions(-) Index: oln/core/rle/rle_image.hh --- oln/core/rle/rle_image.hh (revision 902) +++ oln/core/rle/rle_image.hh (working copy) @@ -1,5 +1,4 @@ -// Copyright (C) 2007 EPITA -// Research and Development Laboratory +// Copyright (C) 2007 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms Index: oln/core/sparse/sparse_image.hh --- oln/core/sparse/sparse_image.hh (revision 902) +++ oln/core/sparse/sparse_image.hh (working copy) @@ -1,4 +1,4 @@ -// Copyright (C) 2006, 2007 EPITA Research and Development Laboratory +// Copyright (C) 2007 EPITA Research and Development Laboratory // // This file is part of the Olena Library. This library is free // software; you can redistribute it and/or modify it under the terms @@ -25,9 +25,11 @@ // reasons why the executable file might be covered by the GNU General // Public License. + #ifndef OLN_CORE_GEN_SPARSE_IMAGE_HH # define OLN_CORE_GEN_SPARSE_IMAGE_HH + # include <vector> # include <map> @@ -64,12 +66,17 @@ typedef rle_pset<point> pset; - //FIXME: + //FIXME: set correct trait typedef mlc::none plain; typedef std::pair< pset, std::map<point, std::vector<value> > > data; }; + /*! + ** \class sparse_image + ** \brief represent an image not plain + ** + */ template < typename P, typename T> class sparse_image : public internal::primitive_image_< sparse_image<P, T> > { @@ -159,3 +166,4 @@ } // end of namespace oln #endif // ! OLN_CORE_GEN_SPARSE_IMAGE_HH + Index: oln/core/encode/sparse_encode.hh --- oln/core/encode/sparse_encode.hh (revision 902) +++ oln/core/encode/sparse_encode.hh (working copy) @@ -52,9 +52,12 @@ sparse_image<typename I::point, typename I::value> output; typename I::piter p(input.points()); unsigned len = 1; - typename I::coord old = 1; /*!< old point first dim coordinate */ - typename I::point rstart; /*!< range pointstart */ - std::vector<typename I::value> values; /*!< range value */ + /// old point first dim coordinate + typename I::coord old = 1; + /// range pointstart + typename I::point rstart; + /// range value + std::vector<typename I::value> values; p.start(); if (!p.is_valid()) Index: oln/core/encode/rle_encode.hh --- oln/core/encode/rle_encode.hh (revision 902) +++ oln/core/encode/rle_encode.hh (working copy) @@ -33,6 +33,7 @@ # include <oln/core/rle/rle_image.hh> + namespace oln { Index: oln/core/1d/box1d.hh --- oln/core/1d/box1d.hh (revision 902) +++ oln/core/1d/box1d.hh (working copy) @@ -36,7 +36,7 @@ { // FIXME: box1d should be an actual type, not an alias... - typedef box_<point1d> box1d; + typedef gen_box<point1d> box1d; } // end of namespace oln Index: oln/core/2d/box2d.hh --- oln/core/2d/box2d.hh (revision 902) +++ oln/core/2d/box2d.hh (working copy) @@ -30,6 +30,7 @@ # include <oln/core/concept/point_set.hh> // for internal::tag::box_t # include <oln/core/2d/point2d.hh> +# include <oln/core/internal/box.hh> namespace oln @@ -39,11 +40,39 @@ template <typename P> class box_; - // FIXME: box2d should be an actual type, not an alias... - typedef box_<point2d> box2d; + // Forward declarations + struct box2d; + // Super type + template <> + struct super_trait_< box2d > + { + typedef box2d current; + typedef internal::box_<box2d> ret; + }; + + // Virtual types + template <> + struct vtypes<box2d> + { + typedef point2d point; + typedef box2d box; + }; + + // Class box2d + class box2d : public internal::box_< box2d > + { + typedef box2d current; + typedef internal::box_< box2d > super; + public: + // Note: we can't use stc_using because box2d isn't a templated class + typedef super::point point; + + box2d(); + box2d(const box2d::from_to_t& dat); + box2d(const point2d& pmin, const point2d& pmax); + }; - /// init__ namespace internal { @@ -68,6 +97,21 @@ namespace oln { + box2d::box2d() + { + } + + box2d::box2d(const box2d::from_to_t& dat) : + super(dat) + { + } + + box2d::box2d(const point2d& pmin, const point2d& pmax) : + super(pmin, pmax) + { + } + + namespace internal { Index: oln/core/gen/box.hh --- oln/core/gen/box.hh (revision 902) +++ oln/core/gen/box.hh (working copy) @@ -39,37 +39,37 @@ // Forward declarations. - template <typename P> class box_; - template <typename P> class box_fwd_piter_; - template <typename P> class box_bkd_piter_; + template <typename P> class gen_box; + template <typename P> class gen_box_fwd_piter_; + template <typename P> class gen_box_bkd_piter_; // Super type declaration. template <typename P> - struct super_trait_< box_<P> > + struct super_trait_< gen_box<P> > { - typedef box_<P> current__; + typedef gen_box<P> current__; typedef internal::point_set_base_<current__> ret; }; - /// Virtual types associated to oln::box_<P>. + /// Virtual types associated to oln::gen_box<P>. template <typename P> - struct vtypes< box_<P> > + struct vtypes< gen_box<P> > { typedef P point; - typedef box_fwd_piter_<P> fwd_piter; - typedef box_bkd_piter_<P> bkd_piter; + typedef gen_box_fwd_piter_<P> fwd_piter; + typedef gen_box_bkd_piter_<P> bkd_piter; }; /// Generic box class based on a point class. template <typename P> - class box_ : public internal::point_set_base_< box_<P> >, + class gen_box : public internal::point_set_base_< gen_box<P> >, private mlc::assert_< mlc_is_a(P, Point) > { - typedef box_<P> current; + typedef gen_box<P> current; typedef internal::point_set_base_<current> super; typedef internal::initializer_< @@ -87,16 +87,16 @@ public: - box_(); - box_(const P& pmin, const P& pmax); - box_(const from_to_t& data); + gen_box(); + gen_box(const P& pmin, const P& pmax); + gen_box(const from_to_t& data); template <typename D> - box_(const internal::initializer_<D>& data); + gen_box(const internal::initializer_<D>& data); unsigned impl_npoints() const; bool impl_has(const P& p) const; - const box_<P>& impl_bbox() const; + const gen_box<P>& impl_bbox() const; const P& pmin() const; P& pmin(); @@ -106,17 +106,17 @@ protected: point pmin_, pmax_; - }; // end of class oln::box_<P> + }; // end of class oln::gen_box<P> template <typename P> - std::ostream& operator<<(std::ostream& ostr, const box_<P>& b) + std::ostream& operator<<(std::ostream& ostr, const gen_box<P>& b) { return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }"; } - // -------------------- iterators on box_<P> + // -------------------- iterators on gen_box<P> @@ -124,16 +124,16 @@ /// Super types. template <typename P> - struct super_trait_< box_fwd_piter_<P> > + struct super_trait_< gen_box_fwd_piter_<P> > { - typedef box_fwd_piter_<P> current__; + typedef gen_box_fwd_piter_<P> current__; typedef Iterator_on_Points<current__> ret; }; template <typename P> - struct super_trait_< box_bkd_piter_<P> > + struct super_trait_< gen_box_bkd_piter_<P> > { - typedef box_bkd_piter_<P> current__; + typedef gen_box_bkd_piter_<P> current__; typedef Iterator_on_Points<current__> ret; }; @@ -141,28 +141,28 @@ /// Virtual types. template <typename P> - struct vtypes< box_fwd_piter_<P> > + struct vtypes< gen_box_fwd_piter_<P> > { typedef P point; }; template <typename P> - struct vtypes< box_bkd_piter_<P> > + struct vtypes< gen_box_bkd_piter_<P> > { typedef P point; }; - /// Class box_fwd_piter_<P>. + /// Class gen_box_fwd_piter_<P>. template <typename P> - class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<P> >, + class gen_box_fwd_piter_ : public Iterator_on_Points< gen_box_fwd_piter_<P> >, private mlc::assert_< mlc_is_a(P, Point) > { public: - box_fwd_piter_(); - box_fwd_piter_(const Point_Set< box_<P> >& b); - void set_box(const box_<P>& b); + gen_box_fwd_piter_(); + gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b); + void set_box(const gen_box<P>& b); void impl_start(); void impl_next(); @@ -172,21 +172,21 @@ const P* impl_point_adr() const; private: - box_<P> b_; + gen_box<P> b_; P p_, nop_; }; - /// Class box_bkd_piter_<P>. + /// Class gen_box_bkd_piter_<P>. template <typename P> - class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<P> >, + class gen_box_bkd_piter_ : public Iterator_on_Points< gen_box_bkd_piter_<P> >, private mlc::assert_< mlc_is_a(P, Point) > { public: - box_bkd_piter_(); - box_bkd_piter_(const Point_Set< box_<P> >& b); - void set_box(const box_<P>& b); + gen_box_bkd_piter_(); + gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b); + void set_box(const gen_box<P>& b); void impl_start(); void impl_next(); @@ -196,7 +196,7 @@ const P* impl_point_adr() const; private: - box_<P> b_; + gen_box<P> b_; P p_, nop_; }; @@ -206,16 +206,16 @@ # ifndef OLN_INCLUDE_ONLY - // -------------------- box_<P> + // -------------------- gen_box<P> template <typename P> - box_<P>::box_() + gen_box<P>::gen_box() { } template <typename P> - box_<P>::box_(const P& pmin, const P& pmax) + gen_box<P>::gen_box(const P& pmin, const P& pmax) { for (unsigned i = 0; i < n; ++i) precondition(pmax[i] >= pmin[i]); @@ -224,7 +224,7 @@ } template <typename P> - box_<P>::box_(const typename box_<P>::from_to_t& dat) + gen_box<P>::gen_box(const typename gen_box<P>::from_to_t& dat) { this->pmin_ = dat->first.value; this->pmax_ = dat->second.value; @@ -232,7 +232,7 @@ template <typename P> template <typename D> - box_<P>::box_(const internal::initializer_<D>& data) + gen_box<P>::gen_box(const internal::initializer_<D>& data) { bool box_ok = internal::init__(internal::tag::box_t(), *this, data.value()); postcondition(box_ok); @@ -240,7 +240,7 @@ template <typename P> unsigned - box_<P>::impl_npoints() const + gen_box<P>::impl_npoints() const { unsigned count = 1; for (unsigned i = 0; i < n; ++i) @@ -250,7 +250,7 @@ template <typename P> bool - box_<P>::impl_has(const P& p) const + gen_box<P>::impl_has(const P& p) const { for (unsigned i = 0; i < n; ++i) if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i]) @@ -259,15 +259,15 @@ } template <typename P> - const box_<P>& - box_<P>::impl_bbox() const + const gen_box<P>& + gen_box<P>::impl_bbox() const { return *this; } template <typename P> const P& - box_<P>::pmin() const + gen_box<P>::pmin() const { for (unsigned i = 0; i < n; ++i) invariant(this->pmin_[i] <= this->pmax_[i]); @@ -276,7 +276,7 @@ template <typename P> const P& - box_<P>::pmax() const + gen_box<P>::pmax() const { for (unsigned i = 0; i < n; ++i) invariant(this->pmax_[i] >= this->pmin_[i]); @@ -285,35 +285,35 @@ template <typename P> P& - box_<P>::pmin() + gen_box<P>::pmin() { return this->pmin_; } template <typename P> P& - box_<P>::pmax() + gen_box<P>::pmax() { return this->pmax_; } - // -------------------- box_fwd_piter_<P> + // -------------------- gen_box_fwd_piter_<P> template <typename P> - box_fwd_piter_<P>::box_fwd_piter_() + gen_box_fwd_piter_<P>::gen_box_fwd_piter_() { } template <typename P> - box_fwd_piter_<P>::box_fwd_piter_(const Point_Set< box_<P> >& b) + gen_box_fwd_piter_<P>::gen_box_fwd_piter_(const Point_Set< gen_box<P> >& b) { this->set_box(exact(b)); } template <typename P> - void box_fwd_piter_<P>::set_box(const box_<P>& b) + void gen_box_fwd_piter_<P>::set_box(const gen_box<P>& b) { b_ = b; nop_ = b_.pmax(); @@ -322,13 +322,13 @@ } template <typename P> - void box_fwd_piter_<P>::impl_start() + void gen_box_fwd_piter_<P>::impl_start() { p_ = b_.pmin(); } template <typename P> - void box_fwd_piter_<P>::impl_next() + void gen_box_fwd_piter_<P>::impl_next() { for (int i = P::n - 1; i >= 0; --i) if (p_[i] == b_.pmax()[i]) @@ -343,47 +343,47 @@ } template <typename P> - void box_fwd_piter_<P>::impl_invalidate() + void gen_box_fwd_piter_<P>::impl_invalidate() { p_ = nop_; } template <typename P> - bool box_fwd_piter_<P>::impl_is_valid() const + bool gen_box_fwd_piter_<P>::impl_is_valid() const { return p_ != nop_; } template <typename P> - P box_fwd_piter_<P>::impl_to_point() const + P gen_box_fwd_piter_<P>::impl_to_point() const { return p_; } template <typename P> - const P* box_fwd_piter_<P>::impl_point_adr() const + const P* gen_box_fwd_piter_<P>::impl_point_adr() const { return &p_; } - // -------------------- box_bkd_piter_<P> + // -------------------- gen_box_bkd_piter_<P> template <typename P> - box_bkd_piter_<P>::box_bkd_piter_() + gen_box_bkd_piter_<P>::gen_box_bkd_piter_() { } template <typename P> - box_bkd_piter_<P>::box_bkd_piter_(const Point_Set< box_<P> >& b) + gen_box_bkd_piter_<P>::gen_box_bkd_piter_(const Point_Set< gen_box<P> >& b) { this->set_box(exact(b)); } template <typename P> - void box_bkd_piter_<P>::set_box(const box_<P>& b) + void gen_box_bkd_piter_<P>::set_box(const gen_box<P>& b) { b_ = b; nop_ = b_.pmin(); @@ -392,13 +392,13 @@ } template <typename P> - void box_bkd_piter_<P>::impl_start() + void gen_box_bkd_piter_<P>::impl_start() { p_ = b_.pmax(); } template <typename P> - void box_bkd_piter_<P>::impl_next() + void gen_box_bkd_piter_<P>::impl_next() { for (int i = P::n - 1; i >= 0; --i) if (p_[i] == b_.pmin()[i]) @@ -413,30 +413,30 @@ } template <typename P> - void box_bkd_piter_<P>::impl_invalidate() + void gen_box_bkd_piter_<P>::impl_invalidate() { p_ = nop_; } template <typename P> - bool box_bkd_piter_<P>::impl_is_valid() const + bool gen_box_bkd_piter_<P>::impl_is_valid() const { return p_ != nop_; } template <typename P> - P box_bkd_piter_<P>::impl_to_point() const + P gen_box_bkd_piter_<P>::impl_to_point() const { return p_; } template <typename P> - const P* box_bkd_piter_<P>::impl_point_adr() const + const P* gen_box_bkd_piter_<P>::impl_point_adr() const { return &p_; } -# endif // OLN_INCLUDE_ONLY +# endif // !OLN_INCLUDE_ONLY } // end of namespace oln Index: oln/core/gen/fbbox.hh --- oln/core/gen/fbbox.hh (revision 902) +++ oln/core/gen/fbbox.hh (working copy) @@ -49,16 +49,16 @@ public: fbbox_(); - operator box_<P>() const; + operator gen_box<P>() const; bool is_valid() const; void flush(); fbbox_<P>& take(const P& p); - const box_<P>& box() const; + const gen_box<P>& box() const; private: bool is_valid_; - box_<P> b_; + gen_box<P> b_; }; // end of class oln::fbbox_<P> @@ -73,7 +73,7 @@ } template <typename P> - fbbox_<P>::operator box_<P>() const + fbbox_<P>::operator gen_box<P>() const { precondition(this->is_valid_); return this->b_; @@ -112,7 +112,7 @@ } template <typename P> - const box_<P>& fbbox_<P>::box() const + const gen_box<P>& fbbox_<P>::box() const { precondition(this->is_valid_); return this->b_; Index: oln/core/internal/box.hh --- oln/core/internal/box.hh (revision 0) +++ oln/core/internal/box.hh (revision 0) @@ -0,0 +1,464 @@ +// Copyright (C) 2007 EPITA Research and Development Laboratory +// +// This file is part of the Olena Library. This library is free +// software; you can redistribute it and/or modify it under the terms +// of the GNU General Public License version 2 as published by the +// Free Software Foundation. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this library; see the file COPYING. If not, write to +// the Free Software Foundation, 51 Franklin Street, Fifth Floor, +// Boston, MA 02111-1307, USA. +// +// As a special exception, you may use this file as part of a free +// software library without restriction. Specifically, if other files +// instantiate templates or use macros or inline functions from this +// file, or you compile this file and link it with other files to +// produce an executable, this file does not by itself cause the +// resulting executable to be covered by the GNU General Public +// License. This exception does not however invalidate any other +// reasons why the executable file might be covered by the GNU General +// Public License. + +#ifndef OLN_CORE_INTERNAL_BOX_HH +# define OLN_CORE_INTERNAL_BOX_HH + +//# include <oln/core/concept/point.hh> +# include <oln/core/concept/point_set.hh> +# include <oln/core/concept/iterator_on_points.hh> +# include <oln/core/internal/point_set_base.hh> + + +namespace oln +{ + + + // Forward declarations. + namespace internal + { + template <typename Exact> class box_; + template <typename Exact> class box_fwd_piter_; + template <typename Exact> class box_bkd_piter_; + } + + // Super type declaration. + template <typename Exact> + struct super_trait_< internal::box_<Exact> > + { + // typedef box_<Exact> current__; + typedef internal::point_set_base_<Exact> ret; + }; + + + /// Virtual types associated to oln::box_<P>. + template <typename Exact> + struct vtypes< internal::box_<Exact> > + { + //typedef point2d point; + typedef stc::final< internal::box_fwd_piter_<Exact> > fwd_piter; + typedef stc::final< internal::box_bkd_piter_<Exact> > bkd_piter; + }; + + + + namespace internal + { + /// Generic box class based on a point class. + template <typename Exact> + class box_ : public point_set_base_< Exact > + { + typedef box_<Exact> current; + typedef point_set_base_<Exact> super; + public: + stc_using(point); + stc_using(box); + + + typedef internal::initializer_< + internal::pair< internal::from_t<point>, internal::to_t<point> > + > from_to_t; + + private: + typedef stc_type(point, dim) dim__; + + public: + enum { n = mlc_value(dim__) }; + + + unsigned impl_npoints() const; + bool impl_has(const point& p) const; + const Exact& impl_bbox() const; + + const point& pmin() const; + point& pmin(); + const point& pmax() const; + point& pmax(); + + protected: + box_(); + box_(const point& pmin, const point& pmax); + box_(const from_to_t& data); + + point pmin_, pmax_; + + }; // end of class oln::box_<P> + + template <typename Exact> + std::ostream& operator<<(std::ostream& ostr, const box_<Exact>& b) + { + return ostr << "{ " << b.pmin() << " .. " << b.pmax() << " }"; + } + + } // end of namespace internal + + + // -------------------- iterators on box_<Exact> + + + + + /// Super types. + + template <typename B> + struct super_trait_< internal::box_fwd_piter_<B> > + { + typedef internal::box_fwd_piter_<B> current__; + typedef Iterator_on_Points<current__> ret; + }; + + template <typename B> + struct super_trait_<internal:: box_bkd_piter_<B> > + { + typedef internal::box_bkd_piter_<B> current__; + typedef Iterator_on_Points<current__> ret; + }; + + + /// Virtual types. + + template <typename B> + struct vtypes< internal::box_fwd_piter_<B> > + { + typedef typename B::point point; + }; + + template <typename B> + struct vtypes< internal::box_bkd_piter_<B> > + { + typedef typename B::point point; + }; + + + namespace internal + { + /// Class box_fwd_piter_<P>. + + template <typename B> + class box_fwd_piter_ : public Iterator_on_Points< box_fwd_piter_<B> >, + private mlc::assert_< mlc_is_a(B, Point_Set) > + { + typedef box_fwd_piter_<B> current; + typedef Iterator_on_Points<current> super; + public: + stc_using(point); + + box_fwd_piter_(); + box_fwd_piter_(const Point_Set< B >& b); + void set_box(const B& b); + + void impl_start(); + void impl_next(); + void impl_invalidate(); + bool impl_is_valid() const; + point impl_to_point() const; + const point* impl_point_adr() const; + + private: + B b_; + point p_, nop_; + }; + + + /// Class box_bkd_piter_<B>. + + template <typename B> + class box_bkd_piter_ : public Iterator_on_Points< box_bkd_piter_<B> >, + private mlc::assert_< mlc_is_a(B, Point_Set) > + { + typedef box_bkd_piter_<B> current; + typedef Iterator_on_Points<current> super; + public: + stc_using(point); + + box_bkd_piter_(); + box_bkd_piter_(const Point_Set< B >& b); + void set_box(const B& b); + + void impl_start(); + void impl_next(); + void impl_invalidate(); + bool impl_is_valid() const; + point impl_to_point() const; + const point* impl_point_adr() const; + + private: + B b_; + point p_, nop_; + }; + + + + +# ifndef OLN_INCLUDE_ONLY + + + // -------------------- box_<Exact> + + + template <typename Exact> + box_<Exact>::box_() + { + } + + template <typename Exact> + box_<Exact>::box_(const box_<Exact>::point& pmin, + const box_<Exact>::point& pmax) + { + for (unsigned i = 0; i < n; ++i) + precondition(pmax[i] >= pmin[i]); + this->pmin_ = pmin; + this->pmax_ = pmax; + } + + template <typename P> + box_<P>::box_(const typename box_<P>::from_to_t& dat) + { + this->pmin_ = dat->first.value; + this->pmax_ = dat->second.value; + } + + + template <typename Exact> + unsigned + box_<Exact>::impl_npoints() const + { + unsigned count = 1; + for (unsigned i = 0; i < n; ++i) + count *= (this->pmax_[i] - this->pmin_[i] + 1); + return count; + } + + template <typename Exact> + bool + box_<Exact>::impl_has(const box_<Exact>::point& p) const + { + for (unsigned i = 0; i < n; ++i) + if (p[i] < this->pmin_[i] or p[i] > this->pmax_[i]) + return false; + return true; + } + + template <typename Exact> + const Exact& + box_<Exact>::impl_bbox() const + { + return *exact(this); + } + + template <typename Exact> + const typename box_<Exact>::point& + box_<Exact>::pmin() const + { + for (unsigned i = 0; i < n; ++i) + invariant(this->pmin_[i] <= this->pmax_[i]); + return this->pmin_; + } + + template <typename Exact> + const typename box_<Exact>::point& + box_<Exact>::pmax() const + { + for (unsigned i = 0; i < n; ++i) + invariant(this->pmax_[i] >= this->pmin_[i]); + return this->pmax_; + } + + template <typename Exact> + typename box_<Exact>::point& + box_<Exact>::pmin() + { + return this->pmin_; + } + + template <typename Exact> + typename box_<Exact>::point& + box_<Exact>::pmax() + { + return this->pmax_; + } + + + // -------------------- box_fwd_piter_<B> + + + template <typename B> + box_fwd_piter_<B>::box_fwd_piter_() + { + } + + template <typename B> + box_fwd_piter_<B>::box_fwd_piter_(const Point_Set< B >& b) + { + this->set_box(exact(b)); + } + + template <typename B> + void + box_fwd_piter_<B>::set_box(const B& b) + { + b_ = b; + nop_ = b_.pmax(); + ++nop_[0]; + p_ = nop_; + } + + template <typename B> + void + box_fwd_piter_<B>::impl_start() + { + p_ = b_.pmin(); + } + + template <typename B> + void + box_fwd_piter_<B>::impl_next() + { + for (int i = B::n - 1; i >= 0; --i) + if (p_[i] == b_.pmax()[i]) + p_[i] = b_.pmin()[i]; + else + { + ++p_[i]; + break; + } + if (p_ == b_.pmin()) + p_ = nop_; + } + + template <typename B> + void + box_fwd_piter_<B>::impl_invalidate() + { + p_ = nop_; + } + + template <typename B> + bool + box_fwd_piter_<B>::impl_is_valid() const + { + return p_ != nop_; + } + + template <typename B> + typename box_fwd_piter_<B>::point + box_fwd_piter_<B>::impl_to_point() const + { + return p_; + } + + template <typename B> + const typename box_fwd_piter_<B>::point* + box_fwd_piter_<B>::impl_point_adr() const + { + return &p_; + } + + + + // -------------------- box_bkd_piter_<P> + + + template <typename B> + box_bkd_piter_<B>::box_bkd_piter_() + { + } + + template <typename B> + box_bkd_piter_<B>::box_bkd_piter_(const Point_Set< B >& b) + { + this->set_box(exact(b)); + } + + template <typename B> + void + box_bkd_piter_<B>::set_box(const B& b) + { + b_ = b; + nop_ = b_.pmin(); + --nop_[0]; + p_ = nop_; + } + + template <typename B> + void + box_bkd_piter_<B>::impl_start() + { + p_ = b_.pmax(); + } + + template <typename B> + void + box_bkd_piter_<B>::impl_next() + { + for (int i = B::n - 1; i >= 0; --i) + if (p_[i] == b_.pmin()[i]) + p_[i] = b_.pmax()[i]; + else + { + --p_[i]; + break; + } + if (p_ == b_.pmax()) + p_ = nop_; + } + + template <typename B> + void + box_bkd_piter_<B>::impl_invalidate() + { + p_ = nop_; + } + + template <typename B> + bool + box_bkd_piter_<B>::impl_is_valid() const + { + return p_ != nop_; + } + + template <typename B> + typename box_bkd_piter_<B>::point + box_bkd_piter_<B>::impl_to_point() const + { + return p_; + } + + template <typename B> + const typename box_bkd_piter_<B>::point* + box_bkd_piter_<B>::impl_point_adr() const + { + return &p_; + } + +# endif // OLN_INCLUDE_ONLY + } // end of namespace internal + +} // end of namespace oln + + +#endif // ! OLN_CORE_INTERNAL_BOX_HH Index: oln/core/internal/point_set_base.hh --- oln/core/internal/point_set_base.hh (revision 902) +++ oln/core/internal/point_set_base.hh (working copy) @@ -34,9 +34,11 @@ namespace oln { + // point_set_base_ class + /// Fwd decls. namespace internal { template <typename Exact> struct point_set_base_; } - template <typename P> class box_; + template <typename P> class gen_box; /// Super type. @@ -59,7 +61,8 @@ typedef stc_deferred(fwd_piter) fwd_piter__; typedef stc::final< stc::is<Point_Set> > category; - typedef stc::final< box_<point__> > box; + //FIXME: + typedef gen_box<point__> box; typedef stc::final< oln_grid(point__) > grid; typedef stc::final< fwd_piter__ > piter; }; Index: oln/core/internal/image_base.hh --- oln/core/internal/image_base.hh (revision 902) +++ oln/core/internal/image_base.hh (working copy) @@ -148,7 +148,9 @@ // Final. typedef stc::final< stc::is<Image> > category; - typedef stc::final< box_<point__> > box; + // FIXME: + //typedef stc::final< box_<point__> > box; + typedef stc::final <typename pset__::box> box; typedef stc::final< oln_grid(point__) > grid; typedef stc::final< oln_dpoint(point__) > dpoint; typedef stc::final< oln_fwd_piter(pset__) > fwd_piter; @@ -433,19 +435,20 @@ // init template <typename P, typename I> - bool init_(box_<P>* this_, const internal::image_base_<I>& data); + bool init_(typename internal::image_base_<I>::box* this_, const internal::image_base_<I>& data); template <typename Target, typename I> bool init_(Any<Target>* this_, const internal::single_image_morpher_<I>& data); template <typename P, typename I> // for disambiguation purpose - bool init_(box_<P>* this_, const internal::single_image_morpher_<I>& data); + bool + init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data); # ifndef OLN_INCLUDE_ONLY template <typename P, typename I> - bool init_(box_<P>* this_, const internal::image_base_<I>& data) + bool init_(typename internal::image_base_<I>::box** this_, const internal::image_base_<I>& data) { *this_ = data.bbox(); return true; @@ -458,7 +461,8 @@ } template <typename P, typename I> - bool init_(box_<P>* this_, const internal::single_image_morpher_<I>& data) + bool + init_(typename internal::image_base_<I>::box** this_, const internal::single_image_morpher_<I>& data) { *this_ = data.bbox(); return true; Index: oln/core/internal/point_set_std_based.hh