* mln/core/image/dmorph/mutable_extension_ima.hh: New.
* headers.mk: Regen.
---
milena/ChangeLog | 7 ++
milena/headers.mk | 1 +
.../{extension_ima.hh => mutable_extension_ima.hh} | 92 +++++++++-----------
3 files changed, 51 insertions(+), 49 deletions(-)
copy milena/mln/core/image/dmorph/{extension_ima.hh => mutable_extension_ima.hh}
(68%)
diff --git a/milena/ChangeLog b/milena/ChangeLog
index 373d9fa..c6f99c1 100644
--- a/milena/ChangeLog
+++ b/milena/ChangeLog
@@ -1,3 +1,10 @@
+2010-09-09 Roland Levillain <roland(a)lrde.epita.fr>
+
+ Introduce an extension-by-mutable-image morpher.
+
+ * mln/core/image/dmorph/mutable_extension_ima.hh: New.
+ * headers.mk: Regen.
+
2010-09-20 Roland Levillain <roland(a)lrde.epita.fr>
Get the `detach' argument of thinning algorithms by reference.
diff --git a/milena/headers.mk b/milena/headers.mk
index 90dd918..a08fbfa 100644
--- a/milena/headers.mk
+++ b/milena/headers.mk
@@ -277,6 +277,7 @@ mln/core/image/dmorph/hexa.hh \
mln/core/image/dmorph/hexa_piter.hh \
mln/core/image/dmorph/image2d_h.hh \
mln/core/image/dmorph/image_if.hh \
+mln/core/image/dmorph/mutable_extension_ima.hh \
mln/core/image/dmorph/p2p_image.hh \
mln/core/image/dmorph/slice_image.hh \
mln/core/image/dmorph/sub_image.hh \
diff --git a/milena/mln/core/image/dmorph/extension_ima.hh
b/milena/mln/core/image/dmorph/mutable_extension_ima.hh
similarity index 68%
copy from milena/mln/core/image/dmorph/extension_ima.hh
copy to milena/mln/core/image/dmorph/mutable_extension_ima.hh
index a0bc9ca..f208581 100644
--- a/milena/mln/core/image/dmorph/extension_ima.hh
+++ b/milena/mln/core/image/dmorph/mutable_extension_ima.hh
@@ -1,4 +1,4 @@
-// Copyright (C) 2008, 2009 EPITA Research and Development Laboratory
+// Copyright (C) 2008, 2009, 2010 EPITA Research and Development Laboratory
// (LRDE)
//
// This file is part of Olena.
@@ -24,13 +24,13 @@
// exception does not however invalidate any other reasons why the
// executable file might be covered by the GNU General Public License.
-#ifndef MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH
-# define MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH
+#ifndef MLN_CORE_IMAGE_DMORPH_MUTABLE_EXTENSION_IMA_HH
+# define MLN_CORE_IMAGE_DMORPH_MUTABLE_EXTENSION_IMA_HH
/// \file
///
/// Definition of a morpher that extends the domain of an image
-/// with an image.
+/// with a readable and writable (rw) image.
# include <mln/core/internal/image_identity.hh>
@@ -40,17 +40,17 @@ namespace mln
{
// Forward declaration.
- template <typename I, typename J> struct extension_ima;
+ template <typename I, typename J> struct mutable_extension_ima;
namespace internal
{
- /// Data structure for \c mln::extension_ima<I, J>.
+ /// Data structure for \c mln::mutable_extension_ima<I, J>.
template <typename I, typename J>
- struct data< extension_ima<I, J> >
+ struct data< mutable_extension_ima<I, J> >
{
- data(I& ima, const J& ext);
+ data(I& ima, J& ext);
I ima_;
J ext_;
@@ -63,7 +63,7 @@ namespace mln
{
template <typename I, typename J>
- struct image_< extension_ima<I, J> > : image_< I > // Same as I
except...
+ struct image_< mutable_extension_ima<I, J> > : image_< I > // Same
as I except...
{
// ...these changes.
typedef trait::image::category::identity_morpher category;
@@ -77,11 +77,11 @@ namespace mln
};
template <typename I, typename J, typename V>
- struct ch_value< extension_ima<I, J>, V >
+ struct ch_value< mutable_extension_ima<I, J>, V >
{
typedef mlc_converts_to(mln_value(J), V) keep_ext;
typedef mln_ch_value(I, V) Iv;
- typedef extension_ima<Iv, J> Iv_ext;
+ typedef mutable_extension_ima<Iv, J> Iv_ext;
typedef mlc_if(keep_ext, Iv_ext, Iv) ret;
};
@@ -94,15 +94,15 @@ namespace mln
/// \ingroup modimagedomainmorpher
//
template <typename I, typename J>
- class extension_ima
+ class mutable_extension_ima
- : public internal::image_identity< I, mln_domain(I), extension_ima<I, J>
>,
+ : public internal::image_identity< I, mln_domain(I), mutable_extension_ima<I,
J> >,
private mlc_converts_to(mln_value(J), mln_value(I))::check_t
{
public:
/// Skeleton.
- typedef extension_ima< tag::image_<I>, tag::ext_<J> > skeleton;
+ typedef mutable_extension_ima< tag::image_<I>, tag::ext_<J> >
skeleton;
/// Image value type.
typedef mln_value(I) value;
@@ -111,14 +111,14 @@ namespace mln
typedef mln_value(I) rvalue;
/// Constructor without argument.
- extension_ima();
+ mutable_extension_ima();
/// Constructor from an image \p ima and a function \p ext.
- extension_ima(I& ima, const J& ext);
+ mutable_extension_ima(I& ima, J& ext);
/// Deferred initialization from an image \p ima and a function \p
/// ext.
- void init_(I& ima, const J& ext);
+ void init_(I& ima, J& ext);
/// Test if \p p is valid.
@@ -131,52 +131,52 @@ namespace mln
mln_value(I) operator()(const mln_psite(I)& p) const;
/// Read-write access to the image value located at site \p p.
- mln_morpher_lvalue(I) operator()(const mln_psite(I)& p);
+ mln_lvalue(I) operator()(const mln_psite(I)& p);
- /// Read-only access to the extension domain (image).
- const J& extension() const;
+ /// Access to the extension domain (image).
+ J& extension() ;
};
// init_
template <typename I, typename J, typename M>
- void init_(tag::image_t, extension_ima<I,J>& target, const M& model);
+ void init_(tag::image_t, mutable_extension_ima<I,J>& target, const M&
model);
template <typename J, typename I>
- void init_(tag::extension_t, J& target, const extension_ima<I,J>&
model);
+ void init_(tag::extension_t, J& target, const mutable_extension_ima<I,J>&
model);
# ifndef MLN_INCLUDE_ONLY
- // internal::data< extension_ima<I,S> >
+ // internal::data< mutable_extension_ima<I,S> >
namespace internal
{
template <typename I, typename J>
inline
- data< extension_ima<I, J> >::data(I& ima, const J& ext)
+ data< mutable_extension_ima<I, J> >::data(I& ima, J& ext)
: ima_(ima),
- ext_(const_cast<J&>(ext))
+ ext_(ext)
{
}
} // end of namespace mln::internal
- // extension_ima<I, J>
+ // mutable_extension_ima<I, J>
template <typename I, typename J>
inline
- extension_ima<I, J>::extension_ima()
+ mutable_extension_ima<I, J>::mutable_extension_ima()
{
}
template <typename I, typename J>
inline
- extension_ima<I, J>::extension_ima(I& ima, const J& ext)
+ mutable_extension_ima<I, J>::mutable_extension_ima(I& ima, J& ext)
{
init_(ima, ext);
}
@@ -184,16 +184,16 @@ namespace mln
template <typename I, typename J>
inline
void
- extension_ima<I, J>::init_(I& ima, const J& ext)
+ mutable_extension_ima<I, J>::init_(I& ima, J& ext)
{
- this->data_ = new internal::data< extension_ima<I, J> >(ima, ext);
+ this->data_ = new internal::data< mutable_extension_ima<I, J> >(ima,
ext);
}
template <typename I, typename J>
template <typename P>
inline
bool
- extension_ima<I, J>::has(const P& p) const
+ mutable_extension_ima<I, J>::has(const P& p) const
{
mln_precondition(this->is_valid());
mln_precondition(this->data_->ext_.is_valid());
@@ -205,7 +205,7 @@ namespace mln
template <typename I, typename J>
inline
mln_value(I)
- extension_ima<I, J>::operator()(const mln_psite(I)& p) const
+ mutable_extension_ima<I, J>::operator()(const mln_psite(I)& p) const
{
mln_precondition(this->is_valid());
mln_precondition(has(p));
@@ -219,29 +219,23 @@ namespace mln
template <typename I, typename J>
inline
- mln_morpher_lvalue(I)
- extension_ima<I, J>::operator()(const mln_psite(I)& p)
+ mln_lvalue(I)
+ mutable_extension_ima<I, J>::operator()(const mln_psite(I)& p)
{
- static mln_value(I) cpy;
mln_precondition(this->is_valid());
mln_precondition(has(p));
- // See the above comment about if-else v. ternary.
+ // if-else is preferred to the ternary op to allow for the
+ // function result to convert towards the expected return type.
if (this->data_->ima_.domain().has(p))
return this->data_->ima_(p);
else
- {
- // This hack makes this signature valid both in the image
- // domain and in its extension. It works even if
- // mln_morpher_lvalue(I) is a mutable reference.
- cpy = this->data_->ext_(p);
- return cpy;
- }
+ return this->data_->ext_(p);
}
template <typename I, typename J>
inline
- const J&
- extension_ima<I, J>::extension() const
+ J&
+ mutable_extension_ima<I, J>::extension()
{
mln_precondition(this->is_valid());
return this->data_->ext_;
@@ -251,7 +245,7 @@ namespace mln
template <typename I, typename J, typename M>
inline
- void init_(tag::image_t, extension_ima<I,J>& target, const M& model)
+ void init_(tag::image_t, mutable_extension_ima<I,J>& target, const M&
model)
{
I ima;
init_(tag::image, ima, model);
@@ -262,10 +256,10 @@ namespace mln
template <typename J, typename I>
inline
- void init_(tag::extension_t, J& target, const extension_ima<I,J>& model)
+ void init_(tag::extension_t, J& target, const mutable_extension_ima<I,J>&
model)
{
typedef mlc_unconst(J) J_;
- J_& ext_ = const_cast<J_&>(model.extension());
+ J_& ext_ = const_cast< mutable_extension_ima<I,J>&
>(model).extension();
J_& target_ = const_cast<J_&>(target);
target_ = ext_;
}
@@ -275,4 +269,4 @@ namespace mln
} // end of namespace mln
-#endif // ! MLN_CORE_IMAGE_DMORPH_EXTENSION_IMA_HH
+#endif // ! MLN_CORE_IMAGE_DMORPH_MUTABLE_EXTENSION_IMA_HH
--
1.5.6.5