26 #ifndef MLN_MORPHO_TREE_UTILS_HH
27 # define MLN_MORPHO_TREE_UTILS_HH
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/site_set/p_array.hh>
48 template <
typename T,
typename I>
50 is_root(
const Image<T>& parent,
const mln_psite(
T)&
p,
54 template <
typename T,
typename I>
56 is_a_node(
const Image<T>& parent,
const mln_psite(
T)&
p,
61 template <
typename T,
typename I,
typename S>
63 nodes(
const Image<T>& parent,
const Image<I>& f,
const Site_Set<S>& s);
66 # ifndef MLN_INCLUDE_ONLY
69 template <
typename T,
typename I>
72 is_root(
const Image<T>& parent_,
const mln_psite(
T)&
p,
75 mlc_equal(mln_value(
T), mln_psite(
T))::check();
77 const T& parent =
exact(parent_);
78 const I& f =
exact(f_);
80 mln_precondition(parent.is_valid());
81 mln_precondition(f.is_valid());
82 mln_precondition(parent.domain() == f.domain());
84 return parent(p) ==
p;
88 template <
typename T,
typename I>
91 is_a_node(
const Image<T>& parent_,
const mln_psite(
T)& p,
94 mlc_equal(mln_value(
T), mln_psite(
T))::check();
96 const T& parent =
exact(parent_);
97 const I& f =
exact(f_);
99 mln_precondition(parent.is_valid());
100 mln_precondition(f.is_valid());
101 mln_precondition(parent.domain() == f.domain());
103 return parent(p) == p || f(parent(p)) != f(p);
107 template <
typename T,
typename I,
typename S>
109 p_array<mln_psite(T)>
110 nodes(
const Image<T>& parent_,
const Image<I>& f_,
const Site_Set<S>& s_)
112 mlc_equal(mln_value(
T), mln_psite(
T))::check();
114 const T& parent =
exact(parent_);
115 const I& f =
exact(f_);
116 const S& s =
exact(s_);
118 mln_precondition(parent.is_valid());
119 mln_precondition(f.is_valid());
120 mln_precondition(f.domain() == parent.domain());
121 mln_precondition(s == f.domain());
123 p_array<mln_psite(T)> arr;
124 mln_bkd_piter(S) p(
exact(s));
132 # endif // ! MLN_INCLUDE_ONLY
141 #endif // ! MLN_MORPHO_TREE_UTILS_HH