https://svn.lrde.epita.fr/svn/oln/trunk/milena
Index: ChangeLog
from Thierry Geraud <thierry.geraud(a)lrde.epita.fr>
Cleanup extension with image, forcing it to be const.
* mln/core/image/extension_ima.hh (todo): Remove; obsolete.
(ctor): Add const for extension.
(change_extension): Remove.
(extension): Remove the mutable version.
(init_): Remove the mutable version.
(init_): Make it robust to constness.
* mln/core/routine/extend.hh: Upgrade file doc style.
(extend): Remove overload for mutable extension.
Misc.
* mln/core/site_set/p_priority.hh: Upgrade file doc style.
(insert): New overload for a priority queue.
* mln/make/double_neighb2d.hh: Upgrade file doc style.
* mln/make/box2d.hh (todo): New.
* mln/labeling/compute.hh: Fix commentary.
core/image/extension_ima.hh | 71 ++++++++++----------------------------------
core/routine/extend.hh | 31 ++++---------------
core/site_set/p_priority.hh | 32 ++++++++++++++++---
labeling/compute.hh | 2 -
make/box2d.hh | 3 +
make/double_neighb2d.hh | 13 +++-----
6 files changed, 61 insertions(+), 91 deletions(-)
Index: mln/core/site_set/p_priority.hh
--- mln/core/site_set/p_priority.hh (revision 3163)
+++ mln/core/site_set/p_priority.hh (working copy)
@@ -1,4 +1,5 @@
// Copyright (C) 2007, 2008 EPITA Research and Development Laboratory
+// (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +29,9 @@
#ifndef MLN_CORE_P_PRIORITY_HH
# define MLN_CORE_P_PRIORITY_HH
-/*! \file mln/core/site_set/p_priority.hh
- *
- * \brief Definition of a priority queue of sites.
- *
- * \todo Rename file as p_priority.hh
- */
+/// \file mln/core/site_set/p_priority.hh
+///
+/// Definition of a priority queue of sites.
# include <map>
# include <mln/core/site_set/p_double.hh>
@@ -126,6 +124,9 @@
/// Insert a pair \p p_e (priority p, element e).
void insert(const i_element& p_e);
+ /// Insert elements from another priority queue.
+ void insert(const p_priority<P,Q>& other);
+
/// Pop (remove) from the queue an element with highest priority.
/// If several elements have this priority, the least recently
@@ -175,6 +176,7 @@
/// Return the size of this site set in memory.
std::size_t memory_size() const;
+
protected:
typedef std::map<P, Q, util::ord<P> > q_type_;
@@ -255,6 +257,24 @@
template <typename P, typename Q>
inline
void
+ p_priority<P,Q>::insert(const p_priority<P,Q>& other)
+ {
+ mln_invariant(run_());
+ typename q_type_::const_iterator i;
+ for (i = other.q_.begin(); i != other.q_.end(); ++i)
+ {
+ P priority = i->first;
+ p_.insert(priority);
+ const Q& q_p = i->second;
+ q_[priority] += q_p;
+ }
+ n_ += other.n_;
+ mln_invariant(run_());
+ }
+
+ template <typename P, typename Q>
+ inline
+ void
p_priority<P,Q>::pop()
{
mln_precondition(! this->is_empty()); // Also test invariants.
Index: mln/core/image/extension_ima.hh
--- mln/core/image/extension_ima.hh (revision 3163)
+++ mln/core/image/extension_ima.hh (working copy)
@@ -31,15 +31,9 @@
/// \file mln/core/image/extension_ima.hh
///
/// Definition of a morpher that extends the domain of an image
-/// with a function.
-///
-/// \todo Use an envelop as lvalue to test extension writing.
-///
-/// \todo Handle the couple of cases: either J is value_io::read_write
-/// or value_io::read_only; then ext_io can be read_write...
+/// with an image.
# include <mln/core/internal/image_identity.hh>
-# include <mln/data/fill_with_value.hh>
@@ -57,7 +51,7 @@
template <typename I, typename J>
struct data< extension_ima<I, J> >
{
- data(I& ima, J& ext);
+ data(I& ima, const J& ext);
I ima_;
J ext_;
@@ -80,7 +74,7 @@
// extended domain
typedef trait::image::ext_domain::extendable ext_domain;
typedef trait::image::ext_value::multiple ext_value;
- typedef trait::image::ext_io::read_only ext_io; // FIXME: Too restrictive?
+ typedef trait::image::ext_io::read_only ext_io;
};
template <typename I, typename J, typename V>
@@ -118,11 +112,11 @@
extension_ima();
/// Constructor from an image \p ima and a function \p ext.
- extension_ima(I& ima, J& ext);
+ extension_ima(I& ima, const J& ext);
/// Deferred initialization from an image \p ima and a function \p
/// ext.
- void init_(I& ima, J& ext);
+ void init_(I& ima, const J& ext);
/// Test if \p p is valid.
@@ -139,14 +133,7 @@
/// Read-only access to the extension domain (image).
- mlc_const(J)& extension() const;
-
- /// Mutable access to the extension domain (image). This domain
- /// can be modified if J a read-write image type.
- J& extension();
-
- /// Change the value in the extension domain (image).
- void change_extension(const mln_value(I)& v);
+ const J& extension() const;
};
@@ -158,10 +145,6 @@
template <typename J, typename I>
void init_(tag::extension_t, J& target, const extension_ima<I,J>&
model);
- template <typename J, typename I>
- void init_(tag::extension_t, J& target, const extension_ima<I,const J>&
model);
-
-
# ifndef MLN_INCLUDE_ONLY
@@ -173,9 +156,9 @@
template <typename I, typename J>
inline
- data< extension_ima<I, J> >::data(I& ima, J& ext)
+ data< extension_ima<I, J> >::data(I& ima, const J& ext)
: ima_(ima),
- ext_(ext)
+ ext_(const_cast<J&>(ext))
{
}
@@ -191,7 +174,7 @@
template <typename I, typename J>
inline
- extension_ima<I, J>::extension_ima(I& ima, J& ext)
+ extension_ima<I, J>::extension_ima(I& ima, const J& ext)
{
init_(ima, ext);
}
@@ -199,7 +182,7 @@
template <typename I, typename J>
inline
void
- extension_ima<I, J>::init_(I& ima, J& ext)
+ extension_ima<I, J>::init_(I& ima, const J& ext)
{
this->data_ = new internal::data< extension_ima<I, J> >(ima, ext);
}
@@ -255,35 +238,17 @@
template <typename I, typename J>
inline
- mlc_const(J)&
+ const J&
extension_ima<I, J>::extension() const
{
mln_precondition(this->is_valid());
return this->data_->ext_;
}
- template <typename I, typename J>
- inline
- J&
- extension_ima<I, J>::extension()
- {
- mln_precondition(this->is_valid());
- return this->data_->ext_;
- }
-
- template <typename I, typename J>
- inline
- void
- extension_ima<I, J>::change_extension(const mln_value(I)& v)
- {
- mlc_equal(mln_trait_image_value_io(J),
- trait::image::value_io::read_write)::check();
- data::fill_with_value(v);
- }
-
// init_
template <typename I, typename J, typename M>
+ inline
void init_(tag::image_t, extension_ima<I,J>& target, const M& model)
{
I ima;
@@ -294,15 +259,13 @@
}
template <typename J, typename I>
+ inline
void init_(tag::extension_t, J& target, const extension_ima<I,J>& model)
{
- target = model.extension();
- }
-
- template <typename J, typename I>
- void init_(tag::extension_t, J& target, const extension_ima<I,const J>&
model)
- {
- target = model.extension();
+ typedef mlc_unconst(J) J_;
+ J_& ext_ = const_cast<J_&>(model.extension());
+ J_& target_ = const_cast<J_&>(target);
+ target_ = ext_;
}
# endif // ! MLN_INCLUDE_ONLY
Index: mln/core/routine/extend.hh
--- mln/core/routine/extend.hh (revision 3163)
+++ mln/core/routine/extend.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,15 +28,13 @@
#ifndef MLN_CORE_ROUTINE_EXTEND_HH
# define MLN_CORE_ROUTINE_EXTEND_HH
-/*!
- * \file mln/core/routine/extend.hh
- *
- * \brief Definition of a morpher that extends the extended domain of an image.
- *
- * \todo Use the 'instant' mechanism.
- * \todo Deal with ambiguities.
- * \todo Check that there is no extension yet (except "extendable").
- */
+/// \file mln/core/routine/extend.hh
+///
+/// Definition of a morpher that extends the extended domain of an image.
+///
+/// \todo Use the 'instant' mechanism.
+/// \todo Deal with ambiguities.
+/// \todo Check that there is no extension yet (except "extendable").
# include <mln/core/image/extension_ima.hh>
# include <mln/core/image/extension_fun.hh>
@@ -65,10 +63,6 @@
extension_ima<const I, const J>
extend(const Image<I>& ima, const Image<J>& ext);
- template <typename I, typename J>
- extension_ima<I, J>
- extend(Image<I>& ima, Image<J>& ext);
-
/// Routines for domain extension with a value.
@@ -119,15 +113,6 @@
return tmp;
}
- template <typename I, typename J>
- extension_ima<I, J>
- extend(Image<I>& ima, Image<J>& ext)
- {
- mlc_converts_to(mln_value(J), mln_value(I))::check();
- extension_ima<I, J> tmp(exact(ima), exact(ext));
- return tmp;
- }
-
// With a value.
Index: mln/make/double_neighb2d.hh
--- mln/make/double_neighb2d.hh (revision 3163)
+++ mln/make/double_neighb2d.hh (working copy)
@@ -1,4 +1,4 @@
-// Copyright (C) 2008 EPITA Research and Development Laboratory
+// Copyright (C) 2008 EPITA Research and Development Laboratory (LRDE)
//
// This file is part of the Olena Library. This library is free
// software; you can redistribute it and/or modify it under the terms
@@ -28,12 +28,11 @@
#ifndef MLN_MAKE_DOUBLE_NEIGHB2D_HH
# define MLN_MAKE_DOUBLE_NEIGHB2D_HH
-/*! \file mln/make/double_neighb2d.hh
- *
- * \brief Routine to create a double neighborhood.
- *
- * \todo Add overload with 'when_*' being Neighborhood<N>...
- */
+/// \file mln/make/double_neighb2d.hh
+///
+/// Routine to create a double neighborhood.
+///
+/// \todo Add overload with 'when_*' being Neighborhood<N>...
# include <mln/convert/to.hh>
# include <mln/core/alias/window2d.hh>
Index: mln/make/box2d.hh
--- mln/make/box2d.hh (revision 3163)
+++ mln/make/box2d.hh (working copy)
@@ -32,6 +32,9 @@
/// \file mln/make/box2d.hh
///
/// Routines to construct an mln::box2d.
+///
+/// \todo Accept long int as args and test overflow (out of def::coord
+/// bounds).
# include <mln/core/alias/box2d.hh>
Index: mln/labeling/compute.hh
--- mln/labeling/compute.hh (revision 3163)
+++ mln/labeling/compute.hh (working copy)
@@ -210,7 +210,7 @@
return convert::to< util::array<mln_result(A)> >(accus);
}
- } // end of namespace mln::labeling::impl::internal
+ } // end of namespace mln::labeling::impl::generic
} // end of namespace mln::labeling::impl