27 #ifndef SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH
28 # define SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH
35 # include <mln/core/concept/graph.hh>
36 # include <mln/core/concept/image.hh>
37 # include <mln/core/site_set/box.hh>
39 # include <mln/canvas/browsing/depth_first_search.hh>
41 # include <mln/accu/shape/bbox.hh>
43 # include <mln/pw/all.hh>
45 # include <mln/fun/i2v/array.hh>
47 # include <mln/util/array.hh>
48 # include <mln/util/graph_ids.hh>
50 # include <scribo/core/object_links.hh>
51 # include <scribo/core/object_groups.hh>
52 # include <scribo/core/macros.hh>
73 template <
typename L,
typename G>
79 # ifndef MLN_INCLUDE_ONLY
88 struct map_vertex_to_representative_id_functor
91 map_vertex_to_representative_id_functor(
const component_set<L>& comps)
100 vertextorep.resize(
exact(g).v_nmax(), mln_max(mln_value(L)));
108 void next_component()
116 vertextorep(
id) = id;
127 vertextorep(
id) = current_;
132 {
return vertextorep(
id) == mln_max(mln_value(L)); }
136 {
return to_be_treated(
id); }
142 object_links<L> vertextorep;
149 template <
typename L,
typename G>
155 mln_trace(
"scribo::primitive::group::from_graph");
157 const G& g =
exact(g_);
159 mln_assertion(g.is_valid());
161 internal::map_vertex_to_representative_id_functor<L> f(comps);
162 canvas::browsing::depth_first_search(g, f);
164 object_groups<L> groups(comps);
165 groups.init_(f.vertextorep);
171 # endif // ! MLN_INCLUDE_ONLY
179 #endif // ! SCRIBO_PRIMITIVE_GROUP_FROM_GRAPH_HH