* mln/world/k2/is_non_primary_2_face.hh,
* mln/world/k2/is_primary_2_face.hh: Make use of kn version.
* mln/world/kn/is_non_primary_2_face.hh,
* mln/world/kn/is_primary_2_face.hh: New.
---
milena/ChangeLog | 10 ++++
milena/mln/world/k2/is_non_primary_2_face.hh | 4 +-
milena/mln/world/k2/is_primary_2_face.hh | 7 ++-
.../mln/world/{k2 => kn}/is_non_primary_2_face.hh | 38 ++++++++++----
milena/mln/world/{k2 => kn}/is_primary_2_face.hh | 51 +++++++++++++------
5 files changed, 78 insertions(+), 32 deletions(-)
copy milena/mln/world/{k2 => kn}/is_non_primary_2_face.hh (65%)
copy milena/mln/world/{k2 => kn}/is_primary_2_face.hh (56%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 5d5f642..84feb27 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,5 +1,15 @@
2012-10-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+ Add kn::is_primary_2_face and kn::is_not_primary_2_face.
+
+ * mln/world/k2/is_non_primary_2_face.hh,
+ * mln/world/k2/is_primary_2_face.hh: Make use of kn version.
+
+ * mln/world/kn/is_non_primary_2_face.hh,
+ * mln/world/kn/is_primary_2_face.hh: New.
+
+2012-10-29 Guillaume Lazzara <z(a)lrde.epita.fr>
+
Move kn::internal::face_dim to kn.
* mln/world/kn/internal/face_dim.hh: Move...
diff --git a/milena/mln/world/k2/is_non_primary_2_face.hh
b/milena/mln/world/k2/is_non_primary_2_face.hh
index d4d7944..038b62f 100644
--- a/milena/mln/world/k2/is_non_primary_2_face.hh
+++ b/milena/mln/world/k2/is_non_primary_2_face.hh
@@ -32,7 +32,7 @@
# include <mln/core/alias/point2d.hh>
# include <mln/world/kn/is_2_face.hh>
-# include <mln/world/k2/is_primary_2_face.hh>
+# include <mln/world/kn/is_primary_2_face.hh>
namespace mln
@@ -68,7 +68,7 @@ namespace mln
bool is_non_primary_2_face(const mln::def::coord& row,
const mln::def::coord& col)
{
- return kn::is_2_face(row, col) && !is_primary_2_face(row, col);
+ return kn::is_2_face(row, col) && !kn::is_primary_2_face<2>(row, col);
}
diff --git a/milena/mln/world/k2/is_primary_2_face.hh
b/milena/mln/world/k2/is_primary_2_face.hh
index 442a8f5..48e842f 100644
--- a/milena/mln/world/k2/is_primary_2_face.hh
+++ b/milena/mln/world/k2/is_primary_2_face.hh
@@ -31,6 +31,7 @@
# define MLN_WORLD_K2_IS_PRIMARY_2_FACE_HH
# include <mln/core/alias/point2d.hh>
+# include <mln/world/kn/is_primary_2_face.hh>
namespace mln
@@ -48,7 +49,7 @@ namespace mln
/// \overload
bool is_primary_2_face(const mln::def::coord& row,
- const mln::def::coord& col);
+ const mln::def::coord& col);
# ifndef MLN_INCLUDE_ONLY
@@ -64,9 +65,9 @@ namespace mln
inline
bool is_primary_2_face(const mln::def::coord& row,
- const mln::def::coord& col)
+ const mln::def::coord& col)
{
- return row % 4 == 0 && col % 4 == 0;
+ return kn::is_primary_2_face<2>(row, col);
}
diff --git a/milena/mln/world/k2/is_non_primary_2_face.hh
b/milena/mln/world/kn/is_non_primary_2_face.hh
similarity index 65%
copy from milena/mln/world/k2/is_non_primary_2_face.hh
copy to milena/mln/world/kn/is_non_primary_2_face.hh
index d4d7944..3a9d5f7 100644
--- a/milena/mln/world/k2/is_non_primary_2_face.hh
+++ b/milena/mln/world/kn/is_non_primary_2_face.hh
@@ -27,12 +27,12 @@
///
/// \brief Check if site is a non-primary face.
-#ifndef MLN_WORLD_K2_IS_NON_PRIMARY_2_FACE_HH
-# define MLN_WORLD_K2_IS_NON_PRIMARY_2_FACE_HH
+#ifndef MLN_WORLD_KN_IS_NON_PRIMARY_2_FACE_HH
+# define MLN_WORLD_KN_IS_NON_PRIMARY_2_FACE_HH
# include <mln/core/alias/point2d.hh>
# include <mln/world/kn/is_2_face.hh>
-# include <mln/world/k2/is_primary_2_face.hh>
+# include <mln/world/kn/is_primary_2_face.hh>
namespace mln
@@ -41,17 +41,24 @@ namespace mln
namespace world
{
- namespace k2
+ namespace kn
{
/// \brief Check if site is a non-primary face
- bool is_non_primary_2_face(const point2d& p);
+ bool is_non_primary_2_face(const point2d& p, unsigned n);
/// \overload
bool is_non_primary_2_face(const mln::def::coord& row,
- const mln::def::coord& col);
+ const mln::def::coord& col,
+ unsigned n);
+ /// \overload
+ /// Static version. \tparam n is a template parameter which
+ /// allows some computation to be performed at compile time.
+ template <unsigned n>
+ bool is_non_primary_2_face(const mln::def::coord& row,
+ const mln::def::coord& col);
# ifndef MLN_INCLUDE_ONLY
@@ -59,25 +66,34 @@ namespace mln
// Facade
inline
- bool is_non_primary_2_face(const point2d& p)
+ bool is_non_primary_2_face(const point2d& p, unsigned n)
{
- return is_non_primary_2_face(p.row(), p.col());
+ return is_non_primary_2_face(p.row(), p.col(), n);
}
inline
bool is_non_primary_2_face(const mln::def::coord& row,
+ const mln::def::coord& col,
+ unsigned n)
+ {
+ return is_2_face(row, col) && !is_primary_2_face(row, col, n);
+ }
+
+
+ template <unsigned n>
+ bool is_non_primary_2_face(const mln::def::coord& row,
const mln::def::coord& col)
{
- return kn::is_2_face(row, col) && !is_primary_2_face(row, col);
+ return is_2_face(row, col) && !is_primary_2_face<n>(row, col);
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::world::k2
+ } // end of namespace mln::world::kn
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_K2_IS_NON_PRIMARY_2_FACE_HH
+#endif // ! MLN_WORLD_KN_IS_NON_PRIMARY_2_FACE_HH
diff --git a/milena/mln/world/k2/is_primary_2_face.hh
b/milena/mln/world/kn/is_primary_2_face.hh
similarity index 56%
copy from milena/mln/world/k2/is_primary_2_face.hh
copy to milena/mln/world/kn/is_primary_2_face.hh
index 442a8f5..36c0e44 100644
--- a/milena/mln/world/k2/is_primary_2_face.hh
+++ b/milena/mln/world/kn/is_primary_2_face.hh
@@ -25,13 +25,14 @@
/// \file
///
-/// \brief Check if site is a primary face.
+/// \brief Check if site is a primary face in an image immersed in Kn.
-#ifndef MLN_WORLD_K2_IS_PRIMARY_2_FACE_HH
-# define MLN_WORLD_K2_IS_PRIMARY_2_FACE_HH
+#ifndef MLN_WORLD_KN_IS_PRIMARY_2_FACE_HH
+# define MLN_WORLD_KN_IS_PRIMARY_2_FACE_HH
+# include <cmath>
# include <mln/core/alias/point2d.hh>
-
+# include <mln/metal/math/pow.hh>
namespace mln
{
@@ -39,43 +40,61 @@ namespace mln
namespace world
{
- namespace k2
+ namespace kn
{
- /// \brief Check if site is a primary face
- bool is_primary_2_face(const point2d& p);
+ /// \brief Check if site is a primary face in an image immersed
+ /// in K\p n.
+ bool is_primary_2_face(const point2d& p,
+ unsigned n);
/// \overload
bool is_primary_2_face(const mln::def::coord& row,
- const mln::def::coord& col);
+ const mln::def::coord& col,
+ unsigned n);
+ /// \overload
+ /// Static version. \tparam n is a template parameter which
+ /// allows some computation to be performed at compile time.
+ template <unsigned n>
+ bool is_primary_2_face(const mln::def::coord& row,
+ const mln::def::coord& col);
# ifndef MLN_INCLUDE_ONLY
- // Facade
-
inline
- bool is_primary_2_face(const point2d& p)
+ bool is_primary_2_face(const point2d& p, unsigned n)
{
- return is_primary_2_face(p.row(), p.col());
+ return is_primary_2_face(p.row(), p.col(), n);
}
inline
bool is_primary_2_face(const mln::def::coord& row,
- const mln::def::coord& col)
+ const mln::def::coord& col,
+ unsigned n)
+ {
+ long shift = std::pow(2u,n);
+ return (row % shift) == 0
+ && (col % shift) == 0;
+ }
+
+ template <unsigned n>
+ bool is_primary_2_face(const mln::def::coord& row,
+ const mln::def::coord& col)
{
- return row % 4 == 0 && col % 4 == 0;
+ return (row % mlc_pow_int(2, n)) == 0
+ && (col % mlc_pow_int(2, n)) == 0;
}
# endif // ! MLN_INCLUDE_ONLY
- } // end of namespace mln::world::k2
+ } // end of namespace mln::world::kn
} // end of namespace mln::world
} // end of namespace mln
-#endif // ! MLN_WORLD_K2_IS_PRIMARY_2_FACE_HH
+#endif // ! MLN_WORLD_KN_IS_PRIMARY_2_FACE_HH
--
1.7.2.5