* mln/geom/bottom_left.hh,
* mln/geom/top_right.hh: New.
* mln/geom/all.hh: Add includes.
---
milena/ChangeLog | 9 ++
milena/mln/geom/all.hh | 4 +-
milena/mln/geom/bottom_left.hh | 160 ++++++++++++++++++++++++++++++++++++++++
milena/mln/geom/top_right.hh | 160 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 332 insertions(+), 1 deletions(-)
create mode 100644 milena/mln/geom/bottom_left.hh
create mode 100644 milena/mln/geom/top_right.hh
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 0f3a431..9ece21f 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,14 @@
2012-05-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+ New routines to get bottom left and top right sites.
+
+ * mln/geom/bottom_left.hh,
+ * mln/geom/top_right.hh: New.
+
+ * mln/geom/all.hh: Add includes.
+
+2012-05-25 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Improve conversion between algebra::h_mat and algebra::quat.
* mln/algebra/h_mat.hh,
diff --git a/milena/mln/geom/all.hh b/milena/mln/geom/all.hh
index 70a719f..fb258f0 100644
--- a/milena/mln/geom/all.hh
+++ b/milena/mln/geom/all.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2007, 2008, 2009, 2010, 2011 EPITA Research and
+// Copyright (C) 2007, 2008, 2009, 2010, 2011, 2012 EPITA Research and
// Development Laboratory (LRDE)
//
// This file is part of Olena.
@@ -68,6 +68,8 @@ namespace mln
# include <mln/geom/size1d.hh>
# include <mln/geom/size2d.hh>
# include <mln/geom/size3d.hh>
+# include <mln/geom/top_right.hh>
+# include <mln/geom/bottom_left.hh>
# include <mln/geom/translate.hh>
diff --git a/milena/mln/geom/bottom_left.hh b/milena/mln/geom/bottom_left.hh
new file mode 100644
index 0000000..a7ee930
--- /dev/null
+++ b/milena/mln/geom/bottom_left.hh
@@ -0,0 +1,160 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_GEOM_BOTTOM_LEFT_HH
+# define MLN_GEOM_BOTTOM_LEFT_HH
+
+/// \file
+///
+/// Give the bottom left point of an image.
+
+# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /*! \brief Give the bottom left point of a 2d or 3d image.
+
+ In 3d, the top-right point corresponds to the bottom left corner
+ of the front face.
+ */
+ template <typename I>
+ mln_site(I) bottom_left(const Image<I>& ima);
+
+
+ /*! \brief Give the bottom left point of a box 2d or 3d.
+ \overload
+ */
+ template <typename B>
+ mln_site(B) bottom_left(const Box<B>& b);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template <typename B>
+ inline
+ mln_site(B) bottom_left_2d(const Box<B>& b_)
+ {
+ const B& b = exact(b_);
+ mln_site(B) bottom_left(b.pmax().row(),
+ b.pmin().col());
+ return bottom_left;
+ }
+
+ template <typename B>
+ inline
+ mln_site(B) bottom_left_3d(const Box<B>& b_)
+ {
+ const B& b = exact(b_);
+ mln_site(B) bottom_left(b.pmax().sli(),
+ b.pmax().row(),
+ b.pmin().col());
+ return bottom_left;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ namespace internal
+ {
+
+ // Not implemented.
+ template <unsigned n>
+ struct bottom_left_dispatch_impl;
+
+ // 2d
+ template <>
+ struct bottom_left_dispatch_impl<2>
+ {
+ template <typename B>
+ inline
+ mln_site(B) run(const Box<B>& box) const
+ {
+ return impl::bottom_left_2d(box);
+ }
+ };
+
+ // 3d
+ template <>
+ struct bottom_left_dispatch_impl<3>
+ {
+ template <typename B>
+ inline
+ mln_site(B) run(const Box<B>& box) const
+ {
+ return impl::bottom_left_3d(box);
+ }
+ };
+
+
+ template <typename B>
+ inline
+ mln_site(B) bottom_left_dispatch(const Box<B>& box)
+ {
+ typedef mln_site(B) P;
+ return bottom_left_dispatch_impl<P::dim>().run(box);
+ }
+
+ } // end of namespace mln::geom::internal
+
+
+ // Facades
+
+ template <typename I>
+ inline
+ mln_site(I) bottom_left(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).is_valid());
+ mln_site(I) output = internal::bottom_left_dispatch(exact(ima).domain());
+
+ return output;
+ }
+
+ template <typename B>
+ inline
+ mln_site(B) bottom_left(const Box<B>& b)
+ {
+ mln_precondition(exact(b).is_valid());
+ mln_site(B) output = internal::bottom_left_dispatch(b);
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_BOTTOM_LEFT_HH
diff --git a/milena/mln/geom/top_right.hh b/milena/mln/geom/top_right.hh
new file mode 100644
index 0000000..655eef0
--- /dev/null
+++ b/milena/mln/geom/top_right.hh
@@ -0,0 +1,160 @@
+// Copyright (C) 2012 EPITA Research and Development Laboratory (LRDE)
+//
+// This file is part of Olena.
+//
+// Olena is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free
+// Software Foundation, version 2 of the License.
+//
+// Olena 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 Olena. If not, see <http://www.gnu.org/licenses/>.
+//
+// As a special exception, you may use this file as part of a free
+// software project 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 MLN_GEOM_TOP_RIGHT_HH
+# define MLN_GEOM_TOP_RIGHT_HH
+
+/// \file
+///
+/// Give the top right point of an image.
+
+# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
+
+
+namespace mln
+{
+
+ namespace geom
+ {
+
+ /*! \brief Give the top right point of a 2d or 3d image.
+
+ In 3d, the top-right point corresponds to the top right corner
+ of the back face.
+ */
+ template <typename I>
+ mln_site(I) top_right(const Image<I>& ima);
+
+
+ /*! \brief Give the top right point of a box 2d or 3d.
+ \overload
+ */
+ template <typename B>
+ mln_site(B) top_right(const Box<B>& b);
+
+# ifndef MLN_INCLUDE_ONLY
+
+
+ namespace impl
+ {
+
+ template <typename B>
+ inline
+ mln_site(B) top_right_2d(const Box<B>& b_)
+ {
+ const B& b = exact(b_);
+ mln_site(B) top_right(b.pmin().row(),
+ b.pmax().col());
+ return top_right;
+ }
+
+ template <typename B>
+ inline
+ mln_site(B) top_right_3d(const Box<B>& b_)
+ {
+ const B& b = exact(b_);
+ mln_site(B) top_right(b.pmin().sli(),
+ b.pmin().row(),
+ b.pmax().col());
+ return top_right;
+ }
+
+ } // end of namespace mln::geom::impl
+
+
+ namespace internal
+ {
+
+ // Not implemented.
+ template <unsigned n>
+ struct top_right_dispatch_impl;
+
+ // 2d
+ template <>
+ struct top_right_dispatch_impl<2>
+ {
+ template <typename B>
+ inline
+ mln_site(B) run(const Box<B>& box) const
+ {
+ return impl::top_right_2d(box);
+ }
+ };
+
+ // 3d
+ template <>
+ struct top_right_dispatch_impl<3>
+ {
+ template <typename B>
+ inline
+ mln_site(B) run(const Box<B>& box) const
+ {
+ return impl::top_right_3d(box);
+ }
+ };
+
+
+ template <typename B>
+ inline
+ mln_site(B) top_right_dispatch(const Box<B>& box)
+ {
+ typedef mln_site(B) P;
+ return top_right_dispatch_impl<P::dim>().run(box);
+ }
+
+ } // end of namespace mln::geom::internal
+
+
+ // Facades
+
+ template <typename I>
+ inline
+ mln_site(I) top_right(const Image<I>& ima)
+ {
+ mln_precondition(exact(ima).is_valid());
+ mln_site(I) output = internal::top_right_dispatch(exact(ima).domain());
+
+ return output;
+ }
+
+ template <typename B>
+ inline
+ mln_site(B) top_right(const Box<B>& b)
+ {
+ mln_precondition(exact(b).is_valid());
+ mln_site(B) output = internal::top_right_dispatch(b);
+
+ return output;
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+ } // end of namespace mln::geom
+
+} // end of namespace mln
+
+
+#endif // ! MLN_GEOM_TOP_RIGHT_HH
--
1.7.2.5