URL:
https://svn.lrde.epita.fr/svn/oln/trunk/milena
ChangeLog:
2007-11-23 Simon Nivault <simon.nivault(a)lrde.epita.fr>
Add documentation and make some better tests.
* mln/core/h_mat.hh,
* mln/core/h_vec.hh,
* mln/core/image_if.hh,
* mln/core/image_if_interval.hh,
* mln/core/image_if_value.hh,
* mln/core/tr_image.hh,
* mln/core/tr_mesh.hh,
* mln/fun/x2x/composed.hh,
* mln/fun/x2x/rotation.hh,
* mln/fun/x2x/translation.hh: Add Documentation.
* tests/image_if_interval.cc,
* tests/image_if_value.cc,
* tests/line_piter.cc: Better tests.
---
mln/core/h_mat.hh | 30 +++++++++++++++++++-----------
mln/core/h_vec.hh | 11 +++++++----
mln/core/image_if.hh | 6 +++++-
mln/core/image_if_interval.hh | 7 ++++++-
mln/core/image_if_value.hh | 7 +++++--
mln/core/tr_image.hh | 3 ++-
mln/core/tr_mesh.hh | 1 +
mln/fun/x2x/composed.hh | 15 ++++++++++++++-
mln/fun/x2x/rotation.hh | 7 +++++++
mln/fun/x2x/translation.hh | 6 ++++++
tests/image_if_interval.cc | 7 +++++++
tests/image_if_value.cc | 7 +++++++
tests/line_piter.cc | 4 ++++
13 files changed, 90 insertions(+), 21 deletions(-)
Index: trunk/milena/tests/image_if_value.cc
===================================================================
--- trunk/milena/tests/image_if_value.cc (revision 1523)
+++ trunk/milena/tests/image_if_value.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | 5);
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) == 5) ==
+ ((ima | 5).has(p)));
+ }
}
Index: trunk/milena/tests/image_if_interval.cc
===================================================================
--- trunk/milena/tests/image_if_interval.cc (revision 1523)
+++ trunk/milena/tests/image_if_interval.cc (revision 1524)
@@ -45,4 +45,11 @@
debug::iota(ima);
debug::println(ima);
debug::println(ima | value::interval(4, 7) );
+
+ I::fwd_piter p(ima.domain());
+ for_all(p)
+ {
+ mln_assertion((ima(p) >= 4 && ima(p) <= 7) ==
+ ((ima | value::interval(4, 7)).has(p)));
+ }
}
Index: trunk/milena/tests/line_piter.cc
===================================================================
--- trunk/milena/tests/line_piter.cc (revision 1523)
+++ trunk/milena/tests/line_piter.cc (revision 1524)
@@ -42,6 +42,10 @@
image2d<int> f(b, border);
image2d<int>::line_piter p(f.domain());
+ unsigned i = 1;
for_all(p)
+ {
+ mln_assertion(p[1] == 0 && p[0] == i++);
std::cout << p <<std::endl;
}
+}
Index: trunk/milena/mln/core/image_if.hh
===================================================================
--- trunk/milena/mln/core/image_if.hh (revision 1523)
+++ trunk/milena/mln/core/image_if.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a function.
*
*/
template <typename I, typename F>
@@ -118,6 +118,9 @@
// Image | Function_p2b.
+ /// ima | f creates an image_if with the image ima and the function
+ /// f.
+ /// {{{
template <typename I, typename F>
image_if<I,F>
operator | (Image<I>& ima, const Function_p2b<F>& f);
@@ -125,6 +128,7 @@
template <typename I, typename F>
image_if<const I,F>
operator | (const Image<I>& ima, const Function_p2b<F>& f);
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/h_vec.hh
===================================================================
--- trunk/milena/mln/core/h_vec.hh (revision 1523)
+++ trunk/milena/mln/core/h_vec.hh (revision 1524)
@@ -34,7 +34,7 @@
*/
# include <mln/metal/vec.hh>
-
+# include <mln/literal/one.hh>
namespace mln
{
@@ -82,7 +82,9 @@
} // end of namespace mln::trait
-
+ /*! \brief N-Dimensional vector with homogeneous coordinates.
+ *
+ */
template <unsigned d, typename C>
struct h_vec : public metal::vec<d + 1, C>
{
@@ -91,8 +93,9 @@
/// Constructor without argument.
h_vec();
-
+ /// Constructor with the underlying vector.
h_vec(const metal::vec<d+1, C>& other);
+
h_vec& operator=(const metal::vec<d+1, C>& rhs);
/// Back to the natural (non-homogeneous) space.
@@ -133,7 +136,7 @@
h_vec<n, T> tmp;
for (unsigned i = 0; i < n; ++i)
tmp[i] = this->data_[i];
- tmp[n] = 1; // FIXME: literal::one
+ tmp[n] = literal::one;
return tmp;
}
Index: trunk/milena/mln/core/tr_image.hh
===================================================================
--- trunk/milena/mln/core/tr_image.hh (revision 1523)
+++ trunk/milena/mln/core/tr_image.hh (revision 1524)
@@ -61,7 +61,8 @@
} // end of namespace mln::internal
- /*! \brief FIXME
+ /*! \brief Morpher that makes an image become transformed by a given
+ * transformation.
*
*/
template <typename T, typename I>
Index: trunk/milena/mln/core/image_if_value.hh
===================================================================
--- trunk/milena/mln/core/image_if_value.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_value.hh (revision 1524)
@@ -75,7 +75,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by a single value.
*
*/
template <typename I>
@@ -124,6 +124,9 @@
// Image | value.
+ /// ima | v creates an image_if_value with the image ima and the
+ /// value v.
+ /// {{{
template <typename I>
image_if_value<I>
operator | (Image<I>& ima, const mln_value(I)& v);
@@ -131,7 +134,7 @@
template <typename I>
image_if_value<const I>
operator | (const Image<I>& ima, const mln_value(I)& v);
-
+ /// }}}
# ifndef MLN_INCLUDE_ONLY
Index: trunk/milena/mln/core/image_if_interval.hh
===================================================================
--- trunk/milena/mln/core/image_if_interval.hh (revision 1523)
+++ trunk/milena/mln/core/image_if_interval.hh (revision 1524)
@@ -83,7 +83,7 @@
- /*! \brief An image class FIXME.
+ /*! \brief Image which domain is restricted by an interval.
*
*/
template <typename I>
@@ -109,6 +109,9 @@
// Image | [from, to].
+ /// ima | vv creates an image_if_interval with the image ima and the
+ /// interval vv.
+ /// {{{
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>&
vv);
@@ -116,6 +119,7 @@
template <typename I>
image_if_interval<const I>
operator | (const Image<I>& ima, const
value::interval_<mln_value(I)>& vv);
+ /// }}}
@@ -163,6 +167,7 @@
// Operators.
+
template <typename I>
image_if_interval<I>
operator | (Image<I>& ima, const value::interval_<mln_value(I)>&
vv)
Index: trunk/milena/mln/core/h_mat.hh
===================================================================
--- trunk/milena/mln/core/h_mat.hh (revision 1523)
+++ trunk/milena/mln/core/h_mat.hh (revision 1524)
@@ -39,27 +39,35 @@
namespace mln
{
-
- template <unsigned dim, typename T>
- struct h_mat : public metal::mat<dim+1, dim+1, T>
+ /*! \brief N-Dimensional matrix with homogeneous coordinates.
+ *
+ */
+ template <unsigned d, typename T>
+ struct h_mat : public metal::mat<d+1, d+1, T>
{
- h_mat();
+ /// Dimension is the 'natural' one (3 for 3D), not the one of the vector (dim
+ 1)
+ enum { N = d,
+ M = d,
+ dim = d * d };
- h_mat(const metal::mat<dim+1, dim+1, T>& x);
+ /// Constructor without argument.
+ h_mat();
+ /// Constructor with the underlying matrix.
+ h_mat(const metal::mat<d+1, d+1, T>& x);
};
# ifndef MLN_INCLUDE_ONLY
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat()
- : metal::mat<dim+1, dim+1, T>(metal::mat<dim+1, dim+1, T>::Id)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat()
+ : metal::mat<d+1, d+1, T>(metal::mat<d+1, d+1, T>::Id)
{
}
- template <unsigned dim, typename T>
- h_mat<dim,T>::h_mat(const metal::mat<dim+1, dim+1, T>& x)
- : metal::mat<dim+1, dim+1, T>(x)
+ template <unsigned d, typename T>
+ h_mat<d,T>::h_mat(const metal::mat<d+1, d+1, T>& x)
+ : metal::mat<d+1, d+1, T>(x)
{
}
Index: trunk/milena/mln/core/tr_mesh.hh
===================================================================
--- trunk/milena/mln/core/tr_mesh.hh (revision 1523)
+++ trunk/milena/mln/core/tr_mesh.hh (revision 1524)
@@ -47,6 +47,7 @@
{
typedef metal::false_ regular;
+ /// Constructor with the transformation.
tr_mesh(const T& tr)
: t_(tr)
{
Index: trunk/milena/mln/fun/x2x/composed.hh
===================================================================
--- trunk/milena/mln/fun/x2x/composed.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/composed.hh (revision 1524)
@@ -60,6 +60,7 @@
struct helper_composed_;
+ /// Helper for describing a bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, true>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -69,16 +70,21 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
+ /// Type of the inverse function.
typedef composed<mln_invert(G),mln_invert(F)> invert;
-
+ /// Return the inverse function.
invert inv() const;
protected:
@@ -87,6 +93,7 @@
G g_;
};
+ /// Helper for describing a non bijective composition.
template <typename F, typename G, typename E>
struct helper_composed_< F, G, E, false>
: public fun::internal::x2x_linear_impl_<mln_result(F), E >,
@@ -96,12 +103,16 @@
using super_::dim;
+ /// Constructor without argument.
helper_composed_();
+ /// Constructor with the two transformation to be composed.
helper_composed_(const F& f, const G& g);
using super_::operator();
+ /// Set the new first transformation.
void set_first(const F& f);
+ /// Set the new second transformation.
void set_second(const G& g);
protected:
@@ -126,8 +137,10 @@
metal::is<mln_argument(F), mln_result(G)>
::check_t
{
+ /// Constructor without argument.
composed() {}
+ /// Constructor with the two transformation to be composed.
composed(const F& f, const G& g)
: internal::helper_composed_<F, G, composed<F,G>,
mlc_is(F, Bijection_x2x<F>)::value &&
Index: trunk/milena/mln/fun/x2x/translation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/translation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/translation.hh (revision 1524)
@@ -60,15 +60,21 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>,
translation<n,C> > super_;
+ /// Type of the inverse function.
typedef translation<n,C> invert;
+ /// Return the inverse function.
invert inv() const;
+ /// Constructor without argument.
translation();
+ /// Constructor with the translation vector.
translation(const metal::vec<n,C>& t);
using super_::operator();
+ /// Perform the translation of the given vector
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a net translation vector.
void set_t(const metal::vec<n,C>& t);
protected:
Index: trunk/milena/mln/fun/x2x/rotation.hh
===================================================================
--- trunk/milena/mln/fun/x2x/rotation.hh (revision 1523)
+++ trunk/milena/mln/fun/x2x/rotation.hh (revision 1524)
@@ -58,16 +58,23 @@
{
typedef fun::internal::x2x_linear_impl_< metal::vec<n,C>, rotation<n,C>
> super_;
+ /// Type of the inverse function.
typedef rotation<n,C> invert;
+ /// Return the invere function.
invert inv() const;
+ /// Constructor without argument.
rotation();
+ /// Constructor with grade alpha and a facultative direction (rotation axis).
rotation(float alpha, unsigned dir = 2);
using super_::operator();
+ /// Perform the rotation of the given vector.
metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
+ /// Set a new grade alpha.
void set_alpha(float alpha);
+ /// Set a new rotation axis.
void set_dir(unsigned dir);
protected: