
URL: https://svn.lrde.epita.fr/svn/oln/trunk/milena ChangeLog: 2008-03-21 Matthieu Garrigues <garrigues@lrde.epita.fr> Add geom routine for Box. * mln/geom/max_col.hh: (mln_coord(B::point) max_col(const Box<B>& b)) New. * mln/geom/max_row.hh: (mln_coord(B::point) max_row(const Box<B>& b)) New. * mln/geom/min_col.hh: (mln_coord(B::point) min_col(const Box<B>& b)) New. * mln/geom/min_row.hh: (mln_coord(B::point) min_row(const Box<B>& b)) New. * mln/geom/ncols.hh: (unsigned ncols(const Box<B>& b)) New. * mln/geom/nrows.hh: (unsigned nrows(const Box<B>& b)) New. --- max_col.hh | 12 ++++++++++++ max_row.hh | 13 +++++++++++++ min_col.hh | 13 +++++++++++++ min_row.hh | 16 ++++++++++++++++ ncols.hh | 12 ++++++++++++ nrows.hh | 11 +++++++++++ 6 files changed, 77 insertions(+) Index: trunk/milena/mln/geom/max_col.hh =================================================================== --- trunk/milena/mln/geom/max_col.hh (revision 1795) +++ trunk/milena/mln/geom/max_col.hh (revision 1796) @@ -46,6 +46,9 @@ template <typename I> mln_coord(I) max_col(const Image<I>& ima); + /// Give the maximum col of an box 2d or 3d. + template <typename B> + mln_coord(B::point) max_col(const Box<B>& b); # ifndef MLN_INCLUDE_ONLY @@ -57,6 +60,15 @@ return exact(ima).bbox().pmax().col(); } + + template <typename B> + inline + mln_coord(B::point) max_col(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return exact(b).pmax().col(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: trunk/milena/mln/geom/nrows.hh =================================================================== --- trunk/milena/mln/geom/nrows.hh (revision 1795) +++ trunk/milena/mln/geom/nrows.hh (revision 1796) @@ -47,6 +47,10 @@ template <typename I> unsigned nrows(const Image<I>& ima); + /// Give the number of rows of a box 2d or 3d. + template <typename B> + unsigned nrows(const Box<B>& b); + # ifndef MLN_INCLUDE_ONLY @@ -58,6 +62,13 @@ return geom::max_row(ima) - geom::min_row(ima) + 1; } + template <typename B> + unsigned nrows(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return geom::max_row(b) - geom::min_row(b) + 1; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: trunk/milena/mln/geom/min_row.hh =================================================================== --- trunk/milena/mln/geom/min_row.hh (revision 1795) +++ trunk/milena/mln/geom/min_row.hh (revision 1796) @@ -35,6 +35,9 @@ # include <mln/core/concept/image.hh> +# include <mln/metal/bexpr.hh> +# include <mln/metal/int.hh> +# include <mln/metal/equal.hh> namespace mln { @@ -46,6 +49,10 @@ template <typename I> mln_coord(I) min_row(const Image<I>& ima); + /// Give the minimum row of an box 2d or 3d. + template <typename B> + mln_coord(B::point) min_row(const Box<B>& b); + # ifndef MLN_INCLUDE_ONLY @@ -57,6 +64,15 @@ return exact(ima).bbox().pmin().row(); } + + template <typename B> + inline + mln_coord(B::point) min_row(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return exact(b).pmin().row(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: trunk/milena/mln/geom/max_row.hh =================================================================== --- trunk/milena/mln/geom/max_row.hh (revision 1795) +++ trunk/milena/mln/geom/max_row.hh (revision 1796) @@ -47,6 +47,10 @@ mln_coord(I) max_row(const Image<I>& ima); + /// Give the maximum row of an box 2d or 3d. + template <typename B> + mln_coord(B::point) max_row(const Box<B>& b); + # ifndef MLN_INCLUDE_ONLY template <typename I> @@ -57,6 +61,15 @@ return exact(ima).bbox().pmax().row(); } + + template <typename B> + inline + mln_coord(B::point) max_row(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return exact(b).pmax().row(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: trunk/milena/mln/geom/ncols.hh =================================================================== --- trunk/milena/mln/geom/ncols.hh (revision 1795) +++ trunk/milena/mln/geom/ncols.hh (revision 1796) @@ -47,6 +47,10 @@ template <typename I> unsigned ncols(const Image<I>& ima); + /// Give the number of cols of a box 2d or 3d. + template <typename B> + unsigned ncols(const Box<B>& b); + # ifndef MLN_INCLUDE_ONLY @@ -58,6 +62,14 @@ return geom::max_col(ima) - geom::min_col(ima) + 1; } + + template <typename B> + unsigned ncols(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return geom::max_col(b) - geom::min_col(b) + 1; + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom Index: trunk/milena/mln/geom/min_col.hh =================================================================== --- trunk/milena/mln/geom/min_col.hh (revision 1795) +++ trunk/milena/mln/geom/min_col.hh (revision 1796) @@ -46,6 +46,10 @@ template <typename I> mln_coord(I) min_col(const Image<I>& ima); + /// Give the minimum column of an box 2d or 3d. + template <typename B> + mln_coord(B::point) min_col(const Box<B>& b); + # ifndef MLN_INCLUDE_ONLY @@ -57,6 +61,15 @@ return exact(ima).bbox().pmin().col(); } + + template <typename B> + inline + mln_coord(B::point) min_col(const Box<B>& b) + { + metal::not_<metal::equal<metal::int_<B::dim>, metal::int_<1> > >::check(); + return exact(b).pmin().col(); + } + # endif // ! MLN_INCLUDE_ONLY } // end of namespace mln::geom