Commit 8ccf53ab authored by Guillaume Lazzara's avatar Guillaume Lazzara
Browse files

Various small fixes.

	* mln/accu/count_adjacent_vertices.hh: add missing is_valid().

	* mln/canvas/labeling.hh: cleanup.

	* mln/labeling/relabel.hh,
	* mln/convert/from_to.hh: reorder declarations.

	* mln/linear/gaussian.hh,
	* mln/core/site_set/p_vaccess.hh,
	* mln/core/alias/complex_geometry.hh: add missing includes.

	* mln/registration/registration.hh,
	* mln/pw/cst.hh,
	* mln/pw/value.hh,
	* mln/geom/ninds.hh,
	* mln/fun/p2b/chess.hh,
	* mln/core/image/complex_neighborhood_piter.hh
	* mln/core/dpsites_piter.hh: update comments.

	* mln/win/multiple_size.hh,
	* mln/core/image/complex_window_piter.hh: add center_at_().

	* mln/core/image/image_if.hh: move init_() implementation between
	MLN_INCLUDE_ONLY guards.

	* mln/core/internal/graph_psite_base.hh: be sure to not return a
	temporary object. The psite holds a site.

	* mln/core/routine/duplicate.hh: rename guards.

	* mln/fun/i2v/array.hh
	* mln/fun/internal/array_base.hh
	* mln/fun/l2l/relabel.hh: make array and relabel inherit from the
	proper function concept. The mutable result must be typedef-ed again
	in that classes.

	* mln/morpho/opening_area_on_vertices.hh: fix wrong prototype.

	* mln/registration/get_rot.hh: get rid of warnings.

	* mln/util/ord_pair.hh: add default constructor.

	* mln/util/site_pair.hh: add accessors.

	* tests/unit_test/Makefile.am,
	* tests/unit_test/mln_geom_resize.cc: update unit tests.

	* headers.mk: remove geom/resize.hh from distribution.

git-svn-id: https://svn.lrde.epita.fr/svn/oln/trunk@3116 4aad255d-cdde-0310-9447-f3009e2ae8c0
parent 591ad0a4
2008-12-30 Guillaume Lazzara <z@lrde.epita.fr>
2008-12-31 Guillaume Lazzara <z@lrde.epita.fr>
Various small fixes.
* mln/accu/count_adjacent_vertices.hh: add missing is_valid().
* mln/canvas/labeling.hh: cleanup.
* mln/labeling/relabel.hh,
* mln/convert/from_to.hh: reorder declarations.
* mln/linear/gaussian.hh,
* mln/core/site_set/p_vaccess.hh,
* mln/core/alias/complex_geometry.hh: add missing includes.
* mln/registration/registration.hh,
* mln/pw/cst.hh,
* mln/pw/value.hh,
* mln/geom/ninds.hh,
* mln/fun/p2b/chess.hh,
* mln/core/image/complex_neighborhood_piter.hh
* mln/core/dpsites_piter.hh: update comments.
* mln/win/multiple_size.hh,
* mln/core/image/complex_window_piter.hh: add center_at_().
* mln/core/image/image_if.hh: move init_() implementation between
MLN_INCLUDE_ONLY guards.
* mln/core/internal/graph_psite_base.hh: be sure to not return a
temporary object. The psite holds a site.
* mln/core/routine/duplicate.hh: rename guards.
* mln/fun/i2v/array.hh
* mln/fun/internal/array_base.hh
* mln/fun/l2l/relabel.hh: make array and relabel inherit from the
proper function concept. The mutable result must be typedef-ed again
in that classes.
* mln/morpho/opening_area_on_vertices.hh: fix wrong prototype.
* mln/registration/get_rot.hh: get rid of warnings.
* mln/util/ord_pair.hh: add default constructor.
* mln/util/site_pair.hh: add accessors.
* tests/unit_test/Makefile.am,
* tests/unit_test/mln_geom_resize.cc: update unit tests.
* mln/accu/count_adjacent_vertices.hh: add missing is_valid().
2008-12-31 Guillaume Lazzara <z@lrde.epita.fr>
 
Rename mln_sum_x to mln_sum_product.
 
......@@ -21,7 +21,6 @@ mln/geom/size3d.hh \
mln/geom/ninds.hh \
mln/geom/nslis.hh \
mln/geom/delta.hh \
mln/geom/resize.hh \
mln/geom/nsites.hh \
mln/geom/min_col.hh \
mln/geom/complex_geometry.hh \
......
......@@ -76,6 +76,9 @@ namespace mln
/// Get the value of the accumulator.
unsigned to_result() const;
/// Return whether this accu can return a result.
bool is_valid() const;
protected:
/// Update the value of the counter.
void update_ ();
......@@ -168,6 +171,14 @@ namespace mln
count__ = vertices_.size();
}
template <typename F, typename S>
inline
bool
count_adjacent_vertices<F,S>::is_valid() const
{
return true;
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace mln::accu
......
......@@ -196,7 +196,7 @@ namespace mln
trace::exiting("canvas::impl::generic::labeling");
return output;
}
} // end of namespace mln::canvas::impl::generic
} // end of namespace mln::canvas::impl
......@@ -385,12 +385,12 @@ namespace mln
F& functor, L& nlabels)
{
trace::entering("canvas::labeling");
internal::labeling_tests(input, nbh, functor, nlabels);
mln_ch_value(I, L) output;
output = internal::labeling_dispatch(input, nbh, functor, nlabels);
trace::exiting("canvas::labeling");
return output;
}
......
......@@ -67,22 +67,6 @@ namespace mln
namespace internal
{
// Default dispatch if the two arguments are objects.
// Object -> Object
template <typename F, typename T>
inline
void
from_to_dispatch(const Object<F>& from, Object<T>& to)
{
typedef mlc_converts_to(F, T) F_converts_to_T;
internal::from_to_dispatch(F_converts_to_T(),
exact(from), exact(to));
}
// Dispatch to specific implementation.
// Image -> Site_Set.
......@@ -133,6 +117,21 @@ namespace mln
// Default dispatch if the two arguments are objects.
// Object -> Object
template <typename F, typename T>
inline
void
from_to_dispatch(const Object<F>& from, Object<T>& to)
{
typedef mlc_converts_to(F, T) F_converts_to_T;
internal::from_to_dispatch(F_converts_to_T(),
exact(from), exact(to));
}
// Dispatch entry points.
// Check whether arguments are an object or not.
......
......@@ -33,6 +33,7 @@
/// Definition of mln::geom::complex_geometry aliases.
# include <mln/geom/complex_geometry.hh>
# include <mln/core/alias/point2d.hh>
# include <mln/core/alias/point3df.hh>
......
......@@ -120,7 +120,7 @@ namespace mln
/// Go to the next point.
void do_next_();
/// Set the reference psite.
/// Do some work while setting the reference site.
template <typename Pref>
void center_at_(const Pref&);
......
......@@ -153,7 +153,7 @@ namespace mln
/// Go to the next site.
void do_next_();
/// Set the reference psite.
/// Do some work while setting the reference site.
template <typename Pref>
void center_at_(const Pref&);
......
......@@ -86,12 +86,10 @@ namespace mln
/// Go to the next site.
void do_next_();
/// Set the reference psite.
/* FIXME: Careful, this method overrides the (non virtual) method
internal::site_relative_iterator_base<S, E>::center_at. See
FIXME above. */
/// Do some work while setting the reference site.
template <typename Pref>
void center_at(const Pref& c);
void center_at_(const Pref& c);
/// Compute the current psite.
psite compute_p_() const;
/// \}
......@@ -154,12 +152,10 @@ namespace mln
/// Go to the next site.
void do_next_();
/// Set the reference psite.
/* FIXME: Careful, this method overrides the (non virtual) method
internal::site_relative_iterator_base<S, E>::center_at. See
FIXME above. */
/// Do some work while setting the reference site.
template <typename Pref>
void center_at(const Pref& c);
void center_at_(const Pref& c);
/// Compute the current psite.
psite compute_p_() const;
/// \}
......@@ -243,9 +239,8 @@ namespace mln
template <typename Pref>
inline
void
complex_window_fwd_piter<I, G, W>::center_at(const Pref& c)
complex_window_fwd_piter<I, G, W>::center_at_(const Pref&)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
......@@ -341,9 +336,8 @@ namespace mln
template <typename Pref>
inline
void
complex_window_bkd_piter<I, G, W>::center_at(const Pref& c)
complex_window_bkd_piter<I, G, W>::center_at_(const Pref& c)
{
super_::center_at(c);
iter_.center_at(this->center().face());
}
......
......@@ -115,26 +115,6 @@ namespace mln
operator image_if<const I, F>() const;
};
// init_.
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, exact(model));
F f;
init_(tag::function, f, exact(model));
target.init_(ima, f);
}
// Operators.
// Image | Function_p2b.
......@@ -165,6 +145,24 @@ namespace mln
# ifndef MLN_INCLUDE_ONLY
// init_.
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, exact(model));
F f;
init_(tag::function, f, exact(model));
target.init_(ima, f);
}
// internal::data< image_if<I,F> >
namespace internal
......
......@@ -100,7 +100,7 @@ namespace mln
const typename S::graph_element& element() const;
/// Return the underlying element.
const typename S::graph_element& hook_elt_() const;
const typename S::graph_element& p_hook_() const;
protected:
......@@ -118,6 +118,7 @@ namespace mln
/// \}
const S* s_;
mln_site(S) site_;
typename S::graph_element elt_;
};
......@@ -155,6 +156,39 @@ namespace mln
/// \}
/// \{
/// subject_impl specialization (Proxy)
template <typename S, typename P, typename E>
struct subject_impl< const graph_psite_base<S,P>&, E >
{
const S* target_() const;
const S& site_set() const;
const typename S::graph_t& graph() const;
unsigned id() const;
bool is_valid() const;
operator unsigned() const;
operator const typename S::graph_element&() const;
const typename S::graph_element& element() const;
const typename S::graph_element& p_hook_() const;
private:
const E& exact_() const;
};
template <typename S, typename P, typename E>
struct subject_impl< graph_psite_base<S,P>&, E > :
subject_impl< const graph_psite_base<S,P>&, E >
{
void change_target(const S& new_target);
void update_id(unsigned elt_id);
void invalidate();
private:
E& exact_();
};
/// \}
# ifndef MLN_INCLUDE_ONLY
......@@ -195,7 +229,9 @@ namespace mln
void
graph_psite_base<S,E>::update_id(unsigned id)
{
mln_precondition(s_ != 0);
elt_.update_id(id);
site_ = s_->function()(elt_.id());
}
template <typename S, typename E>
......@@ -254,8 +290,12 @@ namespace mln
const mln_site(S)&
graph_psite_base<S,E>::subj_()
{
mln_precondition(s_ != 0);
return s_->function()(elt_.id());
/*FIXME: we may like to enable the following precondition, however, we
** can't do that since neighb_*_niters update the psite target after having
** taken the adress of the subject.
*/
// mln_precondition(is_valid());
return site_;
}
template <typename S, typename E>
......@@ -270,7 +310,7 @@ namespace mln
inline
graph_psite_base<S,E>::operator const typename S::graph_element&() const
{
mln_precondition(is_valid());
//mln_precondition(is_valid());
return elt_;
}
......@@ -279,20 +319,23 @@ namespace mln
const typename S::graph_element&
graph_psite_base<S,E>::element() const
{
mln_precondition(is_valid());
/*FIXME: we may like to enable the following precondition, however, we
** can't do that since neighb_*_niters update the psite target after having
** taken the adress of the subject.
*/
// mln_precondition(is_valid());
return elt_;
}
template <typename S, typename E>
inline
const typename S::graph_element&
graph_psite_base<S,E>::hook_elt_() const
graph_psite_base<S,E>::p_hook_() const
{
return elt_;
}
/*--------------.
/*--------------.
| Comparisons. |
`--------------*/
......@@ -320,6 +363,105 @@ namespace mln
return lhs.id() < rhs.id();
}
template <typename S, typename P, typename E>
inline
const E&
subject_impl< const graph_psite_base<S,P>&, E >::exact_() const
{
return internal::force_exact<const E>(*this);
}
template <typename S, typename P, typename E>
inline
const S*
subject_impl< const graph_psite_base<S,P>&, E >::target_() const
{
return exact_().get_subject().target();
}
template <typename S, typename P, typename E>
inline
const S&
subject_impl< const graph_psite_base<S,P>&, E >::site_set() const
{
return exact_().get_subject().site_set();
}
template <typename S, typename P, typename E>
inline
const typename S::graph_t&
subject_impl< const graph_psite_base<S,P>&, E >::graph() const
{
return exact_().get_subject().graph();
}
template <typename S, typename P, typename E>
inline
unsigned
subject_impl< const graph_psite_base<S,P>&, E >::id() const
{
return exact_().get_subject().id();
};
template <typename S, typename P, typename E>
inline
bool
subject_impl< const graph_psite_base<S,P>&, E >::is_valid() const
{
return exact_().get_subject().is_valid();
}
template <typename S, typename P, typename E>
inline
const typename S::graph_element&
subject_impl< const graph_psite_base<S,P>&, E >::element() const
{
return exact_().get_subject().element();
}
template <typename S, typename P, typename E>
inline
const typename S::graph_element&
subject_impl< const graph_psite_base<S,P>&, E >::p_hook_() const
{
return exact_().get_subject().p_hook_();
}
template <typename S, typename P, typename E>
inline
E&
subject_impl< graph_psite_base<S,P>&, E >::exact_()
{
return internal::force_exact<E>(*this);
}
template <typename S, typename P, typename E>
inline
void
subject_impl< graph_psite_base<S,P>&, E >::change_target(const S& new_target)
{
exact_().get_subject().change_target(new_target);
}
template <typename S, typename P, typename E>
inline
void
subject_impl< graph_psite_base<S,P>&, E >::update_id(unsigned id)
{
exact_().get_subject().update_id(id);
};
template <typename S, typename P, typename E>
inline
void
subject_impl< graph_psite_base<S,P>&, E >::invalidate()
{
exact_().get_subject().invalidate();
}
# endif // ! MLN_INCLUDE_ONLY
} // end of namespace internal
......
// Copyright (C) 2007 EPITA Research and Development Laboratory
// 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
......@@ -25,13 +26,12 @@
// reasons why the executable file might be covered by the GNU General
// Public License.
#ifndef MLN_CORE_ROUTINE_CLONE_HH
# define MLN_CORE_ROUTINE_CLONE_HH
#ifndef MLN_CORE_ROUTINE_DUPLICATE_HH
# define MLN_CORE_ROUTINE_DUPLICATE_HH
/*! \file mln/core/routine/duplicate.hh
*
* \brief Clone an image, that is, get an effective copy.
*/
/// \file mln/core/routine/duplicate.hh
///
/// Clone an image, that is, get an effective copy.
# include <mln/core/concept/image.hh>
# include <mln/core/routine/init.hh>
......@@ -41,14 +41,13 @@
namespace mln
{
/*! \brief Clone the image \p model with the values of the image \p
* data.
*
* \param[in] model The image to be duplicateed.
* \result The duplicate.
*
* \pre model.has_data
*/
/// Duplicate the image \p model with the values of the image \p
/// data.
///
/// \param[in] model The image to be duplicated.
/// \result The duplicate.
///
/// \pre model.has_data
template <typename I>
mln_concrete(I) duplicate(const Image<I>& model);
......@@ -75,4 +74,4 @@ namespace mln
} // end of namespace mln
#endif // ! MLN_CORE_ROUTINE_CLONE_HH
#endif // ! MLN_CORE_ROUTINE_DUPLICATE_HH
......@@ -34,6 +34,7 @@
/// \todo Fix the FIXMEs.
# include <utility>
# include <mln/core/concept/site_set.hh>
# include <mln/core/site_set/p_double.hh>
# include <mln/core/internal/site_set_base.hh>
# include <mln/core/internal/pseudo_site_base.hh>
......@@ -41,7 +42,6 @@
# include <mln/value/set.hh>
namespace mln
{
......@@ -66,8 +66,7 @@ namespace mln
/*! \brief FIXME
*/
/// FIXME
template <typename V, typename S>
class p_vaccess : public internal::site_set_base_< mln_site(S),
p_vaccess<V,S> >,
......@@ -111,14 +110,14 @@ namespace mln
/// site set.
bool has(const V& v, const mln_psite(S)& p) const;
/// Test if this site set is valid.
/// Test if this site set is valid.
bool is_valid() const;
/// Element associated type.
typedef mln_element(S) element;
/// Insertion element associated type.
/// Insertion element associated type.
typedef std::pair<V, element> i_element;
/// Insert a pair \p v_e (value v, element e).
......@@ -145,7 +144,7 @@ namespace mln
// Required by p_double-related classes.
const mln::value::set<V>& set_1_() const;
const S& set_2_(const V& v) const;
protected:
mln::value::set<V> vs_;
......