https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Points and dpoints can be easily constructed.
* mln/core/point.hh,
* mln/core/dpoint.hh: New ctor overload with args being
coordinates.
* tests/point1d.cc,
* tests/point3d.cc,
* tests/point2d.cc: Update.
* mln/core/hexa_piter.hh: Fix ctor.
* mln/fun/x2x/translation_alt.hh: Fix.
mln/core/dpoint.hh | 31 +++++++++++++++++++++++++++++++
mln/core/hexa_piter.hh | 17 ++++-------------
mln/core/point.hh | 31 +++++++++++++++++++++++++++----
mln/fun/x2x/translation_alt.hh | 9 +++++----
tests/point1d.cc | 2 +-
tests/point2d.cc | 9 +++++++++
tests/point3d.cc | 2 +-
7 files changed, 78 insertions(+), 23 deletions(-)
Index: tests/point1d.cc
--- tests/point1d.cc (revision 1296)
+++ tests/point1d.cc (working copy)
@@ -47,7 +47,7 @@
mln_assertion(p.ind() = 5 && p[0] = 5);
// construction
- q = make::point1d(5);
+ q = 5;
mln_assertion(p = q);
q.set_all(0);
Index: tests/point3d.cc
--- tests/point3d.cc (revision 1296)
+++ tests/point3d.cc (working copy)
@@ -53,7 +53,7 @@
mln_assertion(p.col() = 3 && p[2] = 3);
// construction
- q = make::point3d(5, 9, 3);
+ q = point3d(5, 9, 3);
mln_assertion(p = q);
q.set_all(0);
Index: tests/point2d.cc
--- tests/point2d.cc (revision 1296)
+++ tests/point2d.cc (working copy)
@@ -53,6 +53,15 @@
// construction
q = make::point2d(5, 1);
mln_assertion(p = q);
+ {
+ point2d q_;
+ q_ = point2d(5, 1);
+ mln_assertion(q_ = q);
+ }
+ {
+ point2d q_(5, 1);
+ mln_assertion(q_ = q);
+ }
q.set_all(0);
for (unsigned i = 0; i < p.dim; ++i)
Index: mln/core/point.hh
--- mln/core/point.hh (revision 1296)
+++ mln/core/point.hh (working copy)
@@ -37,6 +37,7 @@
# include <mln/core/internal/coord_impl.hh>
# include <mln/fun/i2v/all.hh>
+# include <mln/metal/bool.hh>
# include <mln/metal/vec.hh>
# include <mln/core/h_vec.hh>
@@ -101,8 +102,12 @@
/// Constructor without argument.
point_();
- /// Constructor with filling.
- point_(C c);
+ /// \{ Constructors with different numbers of argument w.r.t. the
+ /// dimension.
+ point_(C ind);
+ point_(C row, C col);
+ point_(C sli, C row, C col);
+ /// \}
/// Constructor; coordinates are set by function \p f.
template <typename F>
@@ -157,9 +162,27 @@
}
template <typename M, typename C>
- point_<M,C>::point_(C c)
+ point_<M,C>::point_(C ind)
{
- set_all(c);
+ metal::bool_<(dim = 1)>::check();
+ coord_[0] = ind;
+ }
+
+ template <typename M, typename C>
+ point_<M,C>::point_(C row, C col)
+ {
+ metal::bool_<(dim = 2)>::check();
+ coord_[0] = row;
+ coord_[1] = col;
+ }
+
+ template <typename M, typename C>
+ point_<M,C>::point_(C sli, C row, C col)
+ {
+ metal::bool_<(dim = 3)>::check();
+ coord_[0] = sli;
+ coord_[1] = row;
+ coord_[2] = col;
}
template <typename M, typename C>
Index: mln/core/hexa_piter.hh
--- mln/core/hexa_piter.hh (revision 1296)
+++ mln/core/hexa_piter.hh (working copy)
@@ -60,7 +60,6 @@
public:
/// Constructor from a subset of points.
- hexa_fwd_piter_(const box2d& subset);
hexa_fwd_piter_(const box2d_h& subset);
/// Start an iteration.
@@ -94,22 +93,14 @@
// hexa_fwd_piter_<I>
template <typename S>
- hexa_fwd_piter_<S>::hexa_fwd_piter_(const box2d& b)
- : super_(adaptee_(b))
- {
- }
-
- template <typename S>
hexa_fwd_piter_<S>::hexa_fwd_piter_(const box2d_h& b)
:
- box_adaptee_(make::box2d(b.pmin()[0] / 2,
- b.pmin()[1] / 2,
-
- b.pmax()[0] / 2 + b.pmax()[0] % 2,
- b.pmax()[1] / 2)),
super_(adaptee_(box_adaptee_))
-
{
+ box_adaptee_ = make::box2d(b.pmin()[0] / 2,
+ b.pmin()[1] / 2,
+ b.pmax()[0] / 2 + b.pmax()[0] % 2,
+ b.pmax()[1] / 2);
}
template <typename S>
Index: mln/core/dpoint.hh
--- mln/core/dpoint.hh (revision 1296)
+++ mln/core/dpoint.hh (working copy)
@@ -84,6 +84,13 @@
/// Constructor without argument.
dpoint_();
+ /// \{ Constructors with different numbers of argument w.r.t. the
+ /// dimension.
+ dpoint_(C ind);
+ dpoint_(C row, C col);
+ dpoint_(C sli, C row, C col);
+ /// \}
+
/// Constructor; coordinates are set by function \p f.
template <typename F>
dpoint_(const Function_i2v<F>& f);
@@ -129,6 +136,30 @@
}
template <typename M, typename C>
+ dpoint_<M,C>::dpoint_(C ind)
+ {
+ metal::bool_<(dim = 1)>::check();
+ coord_[0] = ind;
+ }
+
+ template <typename M, typename C>
+ dpoint_<M,C>::dpoint_(C row, C col)
+ {
+ metal::bool_<(dim = 2)>::check();
+ coord_[0] = row;
+ coord_[1] = col;
+ }
+
+ template <typename M, typename C>
+ dpoint_<M,C>::dpoint_(C sli, C row, C col)
+ {
+ metal::bool_<(dim = 3)>::check();
+ coord_[0] = sli;
+ coord_[1] = row;
+ coord_[2] = col;
+ }
+
+ template <typename M, typename C>
template <typename F>
dpoint_<M,C>::dpoint_(const Function_i2v<F>& f_)
{
Index: mln/fun/x2x/translation_alt.hh
--- mln/fun/x2x/translation_alt.hh (revision 1296)
+++ mln/fun/x2x/translation_alt.hh (working copy)
@@ -34,7 +34,7 @@
*/
# include <mln/fun/x2x/bijective_tr.hh>
-# include <mln/fun/internal/x2x_base.hh>
+# include <mln/fun/internal/x2x_impl.hh>
namespace mln
@@ -52,13 +52,14 @@
struct translation_alt
:
- fun::internal::x2x_base_< metal::vec<n,C>, translation_alt<n,C> >
+ fun::internal::x2x_impl_< metal::vec<n,C>, translation_alt<n,C> >
,
- Function_x2x< translation_alt<n,C> >
+ Bijection_x2x< translation_alt<n,C> >
// FIXME: Activate public bijective_tr< translation_alt<n,C> >
{
typedef fun::internal::x2x_base_< metal::vec<n,C>, translation_alt<n,C>
> super_;
+
// typedef translation_alt<n,C> invert;
// invert inv() const;
@@ -66,7 +67,7 @@
translation_alt(const metal::vec<n,C>& t);
using super_::operator();
- result operator()(const metal::vec<n,C>& v) const;
+ metal::vec<n,C> operator()(const metal::vec<n,C>& v) const;
void set_t(const metal::vec<n,C>& t);