https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Augment initialization mechanism.
New initialization mechanism.
* mln/core/init.hh: New.
* mln/tag/init.hh: New.
* mln/core/clone.hh: Update; now call init.
* mln/core/internal/image_base.hh (init_): Remove; obsolete.
Now in mln/core/init.hh.
* mln/core/internal/image_morpher.hh (init_): Inactivate.
(init_): New version so that priority is lowered and ambiguity
suppressed.
Update.
* mln/core/image_if.hh
(pset, psite, self_, super_, data_): Remove; obsolete.
(init_): Overload method.
(init_): New overload in impl::.
* mln/core/image1d_b.hh,
* mln/core/image2d_b.hh,
* mln/core/image3d_b.hh,
* mln/core/sub_image.hh (init_): New overload in impl::.
(init_with): Rename as...
(init_): ...these.
Renaming in skeleton tags.
* mln/tag/skeleton.hh (<name>): Rename as...
(<name>_): ...these.
* mln/trait/ch_value.hh,
* mln/pw/image.hh,
* mln/core/decorated_image.hh,
* mln/core/image_if.hh,
* mln/core/rle_image.hh,
* mln/core/interpolated.hh,
* mln/core/image2d_b.hh,
* mln/core/cast_image.hh,
* mln/core/safe.hh,
* mln/core/pset_if.hh,
* mln/core/sub_image.hh,
* mln/core/sparse_image.hh,
* mln/core/t_image.hh,
* mln/core/image1d_b.hh,
* mln/core/image3d_b.hh,
* mln/value/props.hh,
* mln/value/stack.hh,
* tests/image2d_b.cc,
* tests/image_if.cc: Update.
Misc.
* mln/core/pset_if.hh (pset_f): New ctor.
(pset_): Unqualify.
(predicate): New.
* mln/metal/vec.hh (super_): Change to protected.
* mln/value/quat.hh (super_): New.
(data_): Make use Explicit.
mln/core/cast_image.hh | 2
mln/core/clone.hh | 3
mln/core/decorated_image.hh | 2
mln/core/image1d_b.hh | 43 ++++++++++-
mln/core/image2d_b.hh | 34 +++------
mln/core/image3d_b.hh | 43 ++++++++++-
mln/core/image_if.hh | 80 +++++++++++++++-------
mln/core/init.hh | 134 +++++++++++++++++++++++++++++++++++++
mln/core/internal/image_base.hh | 15 ----
mln/core/internal/image_morpher.hh | 57 +++++++++++++++
mln/core/interpolated.hh | 2
mln/core/pset_if.hh | 22 +++++-
mln/core/rle_image.hh | 2
mln/core/safe.hh | 2
mln/core/sparse_image.hh | 2
mln/core/sub_image.hh | 11 +--
mln/core/t_image.hh | 2
mln/metal/vec.hh | 2
mln/pw/image.hh | 2
mln/tag/init.hh | 54 ++++++++++++++
mln/tag/skeleton.hh | 12 +--
mln/trait/ch_value.hh | 14 +--
mln/value/props.hh | 1
mln/value/quat.hh | 3
mln/value/stack.hh | 2
tests/image2d_b.cc | 2
tests/image_if.cc | 19 ++++-
27 files changed, 466 insertions(+), 101 deletions(-)
Index: tests/image2d_b.cc
--- tests/image2d_b.cc (revision 1161)
+++ tests/image2d_b.cc (working copy)
@@ -33,6 +33,8 @@
#include <mln/core/image2d_b.hh>
#include <mln/geom/size2d.hh>
+#include <mln/core/init.hh>
+
int main()
{
Index: tests/image_if.cc
--- tests/image_if.cc (revision 1161)
+++ tests/image_if.cc (working copy)
@@ -40,7 +40,24 @@
{
using namespace mln;
- image2d_b<int> ima(8, 8);
+ typedef image2d_b<int> I;
+ I ima(8, 8);
// debug::println(ima | fun::p2b::chess);
mln_assertion((ima | fun::p2b::chess).npoints() = 32);
+
+ {
+ typedef image_if<I, fun::p2b::chess_t> II;
+ II ima_ref = ima | fun::p2b::chess;
+ debug::println(ima_ref);
+ {
+ II ima_ref_;
+ ima_ref_ = ima_ref;
+ debug::println(ima_ref_);
+ }
+ {
+ II ima_;
+ init(ima_, ima_ref);
+ debug::println(ima_);
+ }
+ }
}
Index: mln/trait/ch_value.hh
--- mln/trait/ch_value.hh (revision 1161)
+++ mln/trait/ch_value.hh (working copy)
@@ -59,35 +59,35 @@
template < template <class> class M, typename I,
typename V >
- struct ch_value_< M< tag::image<I> >, V >
+ struct ch_value_< M< tag::image_<I> >, V >
{
typedef M< mln_ch_value(I, V) > ret;
};
template < template <class> class M, typename T,
typename V >
- struct ch_value_< M< tag::value<T> >, V >
+ struct ch_value_< M< tag::value_<T> >, V >
{
typedef M< V > ret;
};
template < template <class, class> class M, typename T, typename I,
typename V >
- struct ch_value_< M< tag::value<T>, tag::image<I> >, V
>
+ struct ch_value_< M< tag::value_<T>, tag::image_<I> >, V
>
{
typedef mln_ch_value(I, V) ret;
};
template < template <class, class> class M, typename P, typename T,
typename V >
- struct ch_value_< M< tag::psite<P>, tag::value<T> >, V
>
+ struct ch_value_< M< tag::psite_<P>, tag::value_<T> >, V
>
{
typedef M< P, V > ret;
};
template < template <unsigned, class> class M, unsigned n, typename I,
typename V >
- struct ch_value_< M< n, tag::image<I> >, V > // For
mln::value::stack_image<n,I> !
+ struct ch_value_< M< n, tag::image_<I> >, V > // For
mln::value::stack_image<n,I> !
{
typedef metal::vec<n, V> value;
typedef mln_ch_value(I, value) ret;
@@ -95,14 +95,14 @@
template < template <class, class> class M, typename I, typename S,
typename V >
- struct ch_value_< M< tag::image<I>, tag::pset<S> >, V >
+ struct ch_value_< M< tag::image_<I>, tag::pset_<S> >, V
>
{
typedef M< mln_ch_value(I, V), S > ret;
};
template < template <class, class> class M, typename F, typename S,
typename V >
- struct ch_value_< M< tag::function<F>, tag::pset<S> >, V
>
+ struct ch_value_< M< tag::function_<F>, tag::pset_<S> >, V
>
{
typedef typename S::mesh mesh;
typedef typename image_from_mesh< mesh, V >::ret ret; // FIXME: from_psite
instead? coord=int!?
Index: mln/pw/image.hh
--- mln/pw/image.hh (revision 1161)
+++ mln/pw/image.hh (working copy)
@@ -81,7 +81,7 @@
struct image : public internal::image_primary_< S, image<F,S> >
{
/// Skeleton.
- typedef image< tag::function<F>, tag::pset<S> > skeleton;
+ typedef image< tag::function_<F>, tag::pset_<S> > skeleton;
/// Value associated type.
Index: mln/core/decorated_image.hh
--- mln/core/decorated_image.hh (revision 1161)
+++ mln/core/decorated_image.hh (working copy)
@@ -97,7 +97,7 @@
typedef mln_vset(I) vset;
/// Skeleton.
- typedef decorated_image< tag::image<I>, tag::data<D> > skeleton;
+ typedef decorated_image< tag::image_<I>, tag::data_<D> > skeleton;
mln_value(I) read_(const mln_psite(I)& p) const;
Index: mln/core/image_if.hh
--- mln/core/image_if.hh (revision 1161)
+++ mln/core/image_if.hh (working copy)
@@ -68,16 +68,8 @@
pset_if<mln_pset(I),F>,
image_if<I,F> >
{
-
-
/// Skeleton.
- typedef image_if< tag::image<I>, tag::function<F> > skeleton;
-
- /// Point_Site associated type.
- typedef pset_if<mln_pset(I), F> pset;
-
- /// Psite type.
- typedef mln_psite(pset) psite;
+ typedef image_if< tag::image_<I>, tag::function_<F> > skeleton;
/// Constructor from an image \p ima and a predicate \p f.
image_if(I& ima, const F& f);
@@ -85,25 +77,20 @@
/// Constructor without argument.
image_if();
+ /// Initialization.
+ void init_(I& ima, const F& f);
+
+ /// Initialization.
+ void init_(I& ima, const pset_if<mln_pset(I), F>& pset);
+
/// Test if a pixel value is accessible at \p p.
bool owns_(const mln_psite(I)& p) const;
/// Give the definition domain.
- const pset& domain() const;
+ const pset_if<mln_pset(I), F>& domain() const;
/// Const promotion via convertion.
operator image_if<const I, F>() const;
-
-
- protected:
-
- /// Self type.
- typedef image_if<I,F> self_;
-
- /// Super type.
- typedef internal::image_base_< pset_if<mln_pset(I), F>, image_if<I,F>
> super_;
-
- using super_::data_;
};
@@ -137,11 +124,39 @@
# ifndef MLN_INCLUDE_ONLY
- namespace internal
+ // impl::init_
+
+ namespace impl
+ {
+
+ template <typename I, typename F>
+ void init_(tag::function_t, F& f, const image_if<I,F>& model)
+ {
+ f = model.domain().predicate();
+ }
+
+ template <typename I, typename F, typename J>
+ void init_(tag::image_t, image_if<I,F>& target, const J& model)
{
+ I ima;
+ init_(tag::image, ima, model);
+ F f;
+ init_(tag::function, f, model);
+ target.init_(ima, f);
+ // Alternative code:
+ // pset_if<mln_pset(I), F> pset;
+ // init_(tag::domain, pset, model);
+ // target.init_(ima, pset);
+ }
+
+ } // end of namespace mln::impl
+
// internal::data_< image_if<I,S> >
+ namespace internal
+ {
+
template <typename I, typename F>
data_< image_if<I,F> >::data_(I& ima, const F& f)
: ima_(ima),
@@ -168,10 +183,26 @@
template <typename I, typename F>
image_if<I,F>::image_if(I& ima, const F& f)
{
+ init_(ima, f);
+ }
+
+ template <typename I, typename F>
+ void
+ image_if<I,F>::init_(I& ima, const F& f)
+ {
+ mln_precondition(! this->has_data());
this->data_ = new internal::data_< image_if<I,F> >(ima, f);
}
template <typename I, typename F>
+ void
+ image_if<I,F>::init_(I& ima, const pset_if<mln_pset(I), F>& pset)
+ {
+ mln_precondition(! this->has_data());
+ this->data_ = new internal::data_< image_if<I,F> >(ima, pset);
+ }
+
+ template <typename I, typename F>
image_if<I,F>::operator image_if<const I, F>() const
{
image_if<const I, F> tmp(this->data_->ima_, this->data_->pset_);
@@ -182,19 +213,18 @@
bool
image_if<I,F>::owns_(const mln_psite(I)& p) const
{
- return data_->pset_.has(p);
+ return this->data_->pset_.has(p);
}
template <typename I, typename F>
const pset_if<mln_pset(I), F>&
image_if<I,F>::domain() const
{
- return data_->pset_;
+ return this->data_->pset_;
}
-
// Operators.
template <typename I, typename F>
Index: mln/core/internal/image_base.hh
--- mln/core/internal/image_base.hh (revision 1161)
+++ mln/core/internal/image_base.hh (working copy)
@@ -55,18 +55,6 @@
} // end of namespace mln::internal
- namespace impl
- {
-
- /// Declaration of the general image initialization routine.
- template <typename I, typename J>
- void init_(Image<I>& target, const Image<J>& model);
-
- // FIXME: Say more about it!
-
- } // end of namespace mln::impl
-
-
namespace internal
{
@@ -265,4 +253,7 @@
} // end of namespace mln
+# include <mln/core/init.hh>
+
+
#endif // ! MLN_CORE_INTERNAL_IMAGE_BASE_HH
Index: mln/core/internal/image_morpher.hh
--- mln/core/internal/image_morpher.hh (revision 1161)
+++ mln/core/internal/image_morpher.hh (working copy)
@@ -76,9 +76,36 @@
image_morpher_();
};
+ } // end of namespace mln::internal
+
+
+
+ namespace impl
+ {
+
+ // Default is delegation for morphers.
+
+// template <typename Subject, typename T,
+// typename I, typename S, typename E>
+// void init_(Subject s, T& target,
+// const internal::image_morpher_<I,S,E>& model);
+
+// FIXME: Lines above have been inactivated because they are either
+// prioritary or ambiguous.
+
+ template <typename Subject, typename T,
+ typename J>
+ void init_(Subject s, T& target, const Image<J>& model);
+
+ } // end of namespace mln::impl
+
+
# ifndef MLN_INCLUDE_ONLY
+ namespace internal
+ {
+
template <typename I, typename S, typename E>
image_morpher_<I,S,E>::image_morpher_()
{
@@ -115,10 +142,36 @@
this->delegatee_()->has_data();
}
-# endif // ! MLN_INCLUDE_ONLY
-
} // end of namespace mln::internal
+ namespace impl
+ {
+
+// template <typename Subject, typename T,
+// typename I, typename S, typename E>
+// void init_(Subject s, T& target,
+// const internal::image_morpher_<I,S,E>& model)
+// {
+// // FIXME: Precondition.
+// init_(s, target, * model.delegatee_());
+// }
+
+ template <typename Subject, typename T,
+ typename J>
+ void init_(Subject s, T& target,
+ const Image<J>& model_)
+ {
+ // FIXME: Precondition.
+ // FIXME: Properly check that J is an internal::image_morpher_.
+ const J& model = exact(model_);
+ init_(s, target, * model.delegatee_());
+ }
+
+ } // end of namespace mln::impl
+
+
+# endif // ! MLN_INCLUDE_ONLY
+
} // end of namespace mln
Index: mln/core/rle_image.hh
--- mln/core/rle_image.hh (revision 1161)
+++ mln/core/rle_image.hh (working copy)
@@ -60,7 +60,7 @@
/// Skeleton.
- typedef rle_image< tag::psite<P>, tag::value<T> > skeleton;
+ typedef rle_image< tag::psite_<P>, tag::value_<T> > skeleton;
rle_image();
Index: mln/core/interpolated.hh
--- mln/core/interpolated.hh (revision 1161)
+++ mln/core/interpolated.hh (working copy)
@@ -65,7 +65,7 @@
/// Skeleton.
- typedef interpolated< tag::image<I> > skeleton;
+ typedef interpolated< tag::image_<I> > skeleton;
/// Constructor.
Index: mln/core/init.hh
--- mln/core/init.hh (revision 0)
+++ mln/core/init.hh (revision 0)
@@ -0,0 +1,134 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_CORE_INIT_HH
+# define MLN_CORE_INIT_HH
+
+/*! \file mln/core/init.hh
+ *
+ * \brief Initialization of an image from another one.
+ */
+
+# include <mln/tag/init.hh>
+
+# include <mln/core/concept/image.hh>
+# include <mln/geom/bbox.hh>
+# include <mln/border/get.hh>
+
+
+
+namespace mln
+{
+
+ /*! Initialize the image \p target with data extracted from image \p model.
+ *
+ * \param[in, out] target The image to be initialized.
+ * \param[in] model The image to provide data for the initialization.
+ *
+ * \pre (not target.has_data) and model.has_data
+ */
+ template <typename I, typename J>
+ void init(Image<I>& target, const Image<J>& model);
+
+
+
+ // Fwd decl.
+
+ namespace impl
+ {
+
+ template <typename Subject, typename T, typename M>
+ void init_(Subject, T& target, const Object<M>& model);
+
+ // Easy and final versions.
+
+ template <typename B, typename I>
+ void init_(tag::bbox_t, B& b, const Image<I>& ima);
+
+ template <typename I>
+ void init_(tag::border_t, unsigned& bdr, const Image<I>& ima);
+
+ template <typename I>
+ void init_(tag::domain_t, mln_pset(I)& pset, const Image<I>& ima);
+
+ } // end of namespace mln::impl
+
+
+
+# ifndef MLN_INCLUDE_ONLY
+
+ namespace impl
+ {
+
+ template <typename Subject, typename T, typename M>
+ void init_(Subject, T&, const Object<M>&)
+ {
+ struct ERROR err_; // FIXME: Explicit msg.
+ }
+
+ // Easy impl.
+
+ template <typename B, typename I>
+ void init_(tag::bbox_t, B& b, const Image<I>& ima)
+ {
+ b = geom::bbox(ima);
+ }
+
+ template <typename I>
+ void init_(tag::border_t, unsigned& bdr, const Image<I>& ima)
+ {
+ bdr = border::get(ima);
+ }
+
+ template <typename I>
+ void init_(tag::domain_t, mln_pset(I)& pset, const Image<I>& ima)
+ {
+ pset = exact(ima).domain();
+ }
+
+ } // end of namespace mln::impl
+
+
+ // Facade.
+
+ template <typename I, typename J>
+ void init(Image<I>& target, const Image<J>& model)
+ {
+ mln_precondition(! exact(target).has_data());
+ mln_precondition(exact(model).has_data());
+
+ impl::init_(tag::image, exact(target), exact(model));
+
+ mln_postcondition(exact(target).has_data());
+ }
+
+# endif // ! MLN_INCLUDE_ONLY
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_INIT_HH
Index: mln/core/image2d_b.hh
--- mln/core/image2d_b.hh (revision 1161)
+++ mln/core/image2d_b.hh (working copy)
@@ -40,9 +40,7 @@
# include <mln/value/set.hh>
# include <mln/fun/i2v/all.hh>
# include <mln/core/line_piter.hh>
-# include <mln/border/get.hh>
-# include <mln/debug/println.hh>
-# include <mln/geom/bbox.hh>
+
// FIXME:
@@ -127,7 +125,7 @@
/// Skeleton.
- typedef image2d_b< tag::value<T> > skeleton;
+ typedef image2d_b< tag::value_<T> > skeleton;
/// Value_Set associated type.
@@ -145,6 +143,7 @@
/// 3).
image2d_b(const box2d& b, unsigned bdr = border::thickness);
+
/// Initialize an empty image.
void init_(const box2d& b, unsigned bdr = border::thickness);
@@ -203,7 +202,7 @@
{
template <typename T, typename J>
- void init_(image2d_b<T>& target, const J& model);
+ void init_(tag::image_t, mln::image2d_b<T>& target, const J& model);
} // end of namespace mln::impl
@@ -217,24 +216,19 @@
namespace impl
{
-// void init(tag::border, unsigned b, const image2d_b<T>& model)
-// {
-// b = model.border();
-// }
+ template <typename T>
+ void init_(tag::border_t, unsigned& b, const image2d_b<T>& model)
+ {
+ b = model.border();
+ }
template <typename T, typename J>
- void init_(image2d_b<T>& target, const J& model)
+ void init_(tag::image_t, image2d_b<T>& target, const J& model)
{
- box2d b = geom::bbox(model);
- unsigned bdr = border::get(model);
-
- // FIXME
-
-// box2d b;
-// init(tag::bbox, b, model);
-// unsigned bdr;
-// init(tag::border, bdr, model);
-
+ box2d b;
+ init_(tag::bbox, b, model);
+ unsigned bdr;
+ init_(tag::border, bdr, model);
target.init_(b, bdr);
}
Index: mln/core/cast_image.hh
--- mln/core/cast_image.hh (revision 1161)
+++ mln/core/cast_image.hh (working copy)
@@ -81,7 +81,7 @@
/// Skeleton.
- typedef cast_image_< tag::value<T>, tag::image<I> > skeleton;
+ typedef cast_image_< tag::value_<T>, tag::image_<I> > skeleton;
/// Constructor.
Index: mln/core/safe.hh
--- mln/core/safe.hh (revision 1161)
+++ mln/core/safe.hh (working copy)
@@ -43,7 +43,7 @@
public:
/// Skeleton.
- typedef safe_image< tag::image<I> > skeleton;
+ typedef safe_image< tag::image_<I> > skeleton;
safe_image(I& ima, const mln_value(I)& default_value);
Index: mln/core/pset_if.hh
--- mln/core/pset_if.hh (revision 1161)
+++ mln/core/pset_if.hh (working copy)
@@ -80,9 +80,12 @@
typedef internal::fixme bkd_piter;
- /// Constructor without argument.
+ /// Constructor with a point set \p pset and a predicate \p f.
pset_if(const S& pset, const F& f);
+ /// Constructor without argument.
+ pset_if();
+
/// Test if \p p belongs to the subset.
bool has(const psite& p) const;
@@ -99,9 +102,12 @@
/// Test predicate on point site \p p.
bool pred(const psite& p) const;
+ /// Give the predicate function.
+ const F& predicate() const;
+
protected:
- const S& pset_;
+ S pset_;
F f_;
};
@@ -156,6 +162,18 @@
{
}
+ template <typename S, typename F>
+ pset_if<S,F>::pset_if()
+ {
+ }
+
+ template <typename S, typename F>
+ const F&
+ pset_if<S,F>::predicate() const
+ {
+ return f_;
+ }
+
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln
Index: mln/core/sub_image.hh
--- mln/core/sub_image.hh (revision 1161)
+++ mln/core/sub_image.hh (working copy)
@@ -62,7 +62,7 @@
struct sub_image : public internal::image_domain_morpher_< I, S,
sub_image<I,S> >
{
/// Skeleton.
- typedef sub_image< tag::image<I>, tag::pset<S> > skeleton;
+ typedef sub_image< tag::image_<I>, tag::pset_<S> > skeleton;
/// Constructor without argument.
sub_image();
@@ -95,7 +95,7 @@
{
template <typename I, typename S, typename J>
- void init_(sub_image<I,S>& target, const J& model);
+ void init_(tag::image_t, sub_image<I,S>& target, const J& model);
} // end of namespace mln::impl
@@ -109,11 +109,12 @@
{
template <typename I, typename S, typename J>
- void init_(sub_image<I,S>& target, const J& model)
+ void init_(tag::image_t, sub_image<I,S>& target, const J& model)
{
I ima;
- init_(ima, model); // rec
- S pset = model.domain();
+ init_(tag::image, ima, model);
+ S pset;
+ init_(tag::domain, pset, model);
target.init_(ima, pset);
}
Index: mln/core/sparse_image.hh
--- mln/core/sparse_image.hh (revision 1161)
+++ mln/core/sparse_image.hh (working copy)
@@ -60,7 +60,7 @@
/// Skeleton.
- typedef sparse_image< tag::psite<P>, tag::value<T> > skeleton;
+ typedef sparse_image< tag::psite_<P>, tag::value_<T> > skeleton;
sparse_image();
Index: mln/core/clone.hh
--- mln/core/clone.hh (revision 1161)
+++ mln/core/clone.hh (working copy)
@@ -34,6 +34,7 @@
*/
# include <mln/core/concept/image.hh>
+# include <mln/core/init.hh>
# include <mln/level/fill.hh>
@@ -58,7 +59,7 @@
{
// FIXME: Add a static check that mln_concrete(I) actually *is* concrete...
mln_concrete(I) tmp;
- impl::init_(tmp, exact(model));
+ init(tmp, model);
level::fill(tmp, model);
return tmp;
}
Index: mln/core/t_image.hh
--- mln/core/t_image.hh (revision 1161)
+++ mln/core/t_image.hh (working copy)
@@ -50,7 +50,7 @@
struct t_image : public internal::image_adaptor_< I, t_image<I> >
{
/// Skeleton.
- typedef t_image< tag::image<I> > skeleton;
+ typedef t_image< tag::image_<I> > skeleton;
/// Test if a pixel value is accessible at \p p.
bool owns_(const mln_point(I)& p) const;
Index: mln/core/image1d_b.hh
--- mln/core/image1d_b.hh (revision 1161)
+++ mln/core/image1d_b.hh (working copy)
@@ -125,7 +125,7 @@
/// Skeleton.
- typedef image1d_b< tag::value<T> > skeleton;
+ typedef image1d_b< tag::value_<T> > skeleton;
/// Value_Set associated type.
@@ -144,7 +144,7 @@
/// Initialize an empty image.
- void init_with(const box1d& b, unsigned bdr = border::thickness);
+ void init_(const box1d& b, unsigned bdr = border::thickness);
/// Test if \p p is valid.
@@ -197,9 +197,42 @@
};
+ namespace impl
+ {
+
+ template <typename T, typename J>
+ void init_(tag::image_t, mln::image1d_b<T>& target, const J& model);
+
+ } // end of namespace mln::impl
+
+
# ifndef MLN_INCLUDE_ONLY
+ // impl::init_
+
+ namespace impl
+ {
+
+ template <typename T>
+ void init_(tag::border_t, unsigned& b, const image1d_b<T>& model)
+ {
+ b = model.border();
+ }
+
+ template <typename T, typename J>
+ void init_(tag::image_t, image1d_b<T>& target, const J& model)
+ {
+ box1d b;
+ init_(tag::bbox, b, model);
+ unsigned bdr;
+ init_(tag::border, bdr, model);
+ target.init_(b, bdr);
+ }
+
+ } // end of namespace mln::impl
+
+
// internal::data_< image1d_b<T> >
namespace internal
@@ -265,19 +298,19 @@
template <typename T>
image1d_b<T>::image1d_b(const box1d& b, unsigned bdr)
{
- init_with(b, bdr);
+ init_(b, bdr);
}
template <typename T>
image1d_b<T>::image1d_b(unsigned ninds, unsigned bdr)
{
mln_precondition(ninds != 0);
- init_with(make::box1d(ninds), bdr);
+ init_(make::box1d(ninds), bdr);
}
template <typename T>
void
- image1d_b<T>::init_with(const box1d& b, unsigned bdr)
+ image1d_b<T>::init_(const box1d& b, unsigned bdr)
{
mln_precondition(! this->has_data());
this->data_ = new internal::data_< image1d_b<T> >(b, bdr);
Index: mln/core/image3d_b.hh
--- mln/core/image3d_b.hh (revision 1161)
+++ mln/core/image3d_b.hh (working copy)
@@ -127,7 +127,7 @@
/// Skeleton.
- typedef image3d_b< tag::value<T> > skeleton;
+ typedef image3d_b< tag::value_<T> > skeleton;
/// Value_Set associated type.
@@ -147,7 +147,7 @@
/// Initialize an empty image.
- void init_with(const box3d& b, unsigned bdr = border::thickness);
+ void init_(const box3d& b, unsigned bdr = border::thickness);
/// Test if \p p is valid.
@@ -203,9 +203,42 @@
};
+ namespace impl
+ {
+
+ template <typename T, typename J>
+ void init_(tag::image_t, mln::image3d_b<T>& target, const J& model);
+
+ } // end of namespace mln::impl
+
+
# ifndef MLN_INCLUDE_ONLY
+ // impl::init_
+
+ namespace impl
+ {
+
+ template <typename T>
+ void init_(tag::border_t, unsigned& b, const image3d_b<T>& model)
+ {
+ b = model.border();
+ }
+
+ template <typename T, typename J>
+ void init_(tag::image_t, image3d_b<T>& target, const J& model)
+ {
+ box3d b;
+ init_(tag::bbox, b, model);
+ unsigned bdr;
+ init_(tag::border, bdr, model);
+ target.init_(b, bdr);
+ }
+
+ } // end of namespace mln::impl
+
+
// internal::data_< image3d_b<T> >
namespace internal
@@ -300,18 +333,18 @@
template <typename T>
image3d_b<T>::image3d_b(const box3d& b, unsigned bdr)
{
- init_with(b, bdr);
+ init_(b, bdr);
}
template <typename T>
image3d_b<T>::image3d_b(int nslis, int nrows, int ncols, unsigned bdr)
{
- init_with(make::box3d(nslis, nrows, ncols), bdr);
+ init_(make::box3d(nslis, nrows, ncols), bdr);
}
template <typename T>
void
- image3d_b<T>::init_with(const box3d& b, unsigned bdr)
+ image3d_b<T>::init_(const box3d& b, unsigned bdr)
{
mln_precondition(! this->has_data());
this->data_ = new internal::data_< image3d_b<T> >(b, bdr);
Index: mln/metal/vec.hh
--- mln/metal/vec.hh (revision 1161)
+++ mln/metal/vec.hh (working copy)
@@ -116,6 +116,8 @@
class vec : public internal::vec_base_<n, T>
{
typedef internal::vec_base_<n, T> super;
+
+ protected:
using super::data_;
public:
Index: mln/tag/init.hh
--- mln/tag/init.hh (revision 0)
+++ mln/tag/init.hh (revision 0)
@@ -0,0 +1,54 @@
+// Copyright (C) 2007 EPITA Research and Development Laboratory
+//
+// This file is part of the Olena Library. This library is free
+// software; you can redistribute it and/or modify it under the terms
+// of the GNU General Public License version 2 as published by the
+// Free Software Foundation.
+//
+// This library 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 this library; see the file COPYING. If not, write to
+// the Free Software Foundation, 51 Franklin Street, Fifth Floor,
+// Boston, MA 02111-1307, USA.
+//
+// As a special exception, you may use this file as part of a free
+// software library 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_CORE_TAG_INIT_HH
+# define MLN_CORE_TAG_INIT_HH
+
+/*! \file mln/core/tag/init.hh
+ *
+ * \brief Definition of tags used in the mln::init mechanism.
+ */
+
+
+namespace mln
+{
+
+ namespace tag
+ {
+
+ struct image_t {} image;
+ struct domain_t {} domain;
+ struct bbox_t {} bbox;
+ struct border_t {} border;
+ struct function_t {} function;
+
+ } // end of namespace mln::tag
+
+} // end of namespace mln
+
+
+#endif // ! MLN_CORE_TAG_INIT_HH
Index: mln/tag/skeleton.hh
--- mln/tag/skeleton.hh (revision 1161)
+++ mln/tag/skeleton.hh (working copy)
@@ -42,12 +42,12 @@
{
// With param.
- template <typename I> struct image { typedef I param; };
- template <typename V> struct value { typedef V param; };
- template <typename P> struct psite { typedef P param; };
- template <typename S> struct pset { typedef S param; };
- template <typename D> struct data { typedef D param; };
- template <typename F> struct function { typedef F param; };
+ template <typename I> struct image_ { typedef I param; };
+ template <typename V> struct value_ { typedef V param; };
+ template <typename P> struct psite_ { typedef P param; };
+ template <typename S> struct pset_ { typedef S param; };
+ template <typename D> struct data_ { typedef D param; };
+ template <typename F> struct function_ { typedef F param; };
// With value.
template <unsigned u> struct unsigned_ { enum { value = u }; };
Index: mln/value/props.hh
--- mln/value/props.hh (revision 1161)
+++ mln/value/props.hh (working copy)
@@ -229,7 +229,6 @@
// records
- template <>
template <unsigned n, typename T>
struct props<metal::vec<n,T> >
{
Index: mln/value/stack.hh
--- mln/value/stack.hh (revision 1161)
+++ mln/value/stack.hh (working copy)
@@ -121,7 +121,7 @@
/// Skeleton.
- typedef stack_image< n, tag::image<I> > skeleton;
+ typedef stack_image< n, tag::image_<I> > skeleton;
/// Constructor.
Index: mln/value/quat.hh
--- mln/value/quat.hh (revision 1161)
+++ mln/value/quat.hh (working copy)
@@ -42,6 +42,9 @@
class quat : public metal::vec<4, float>
{
+ typedef metal::vec<4, float> super_;
+ using super_::data_;
+
public:
// ctors