$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
with_single_down_link.hh
1 // Copyright (C) 2009, 2010 EPITA Research and Development Laboratory
2 // (LRDE)
3 //
4 // This file is part of Olena.
5 //
6 // Olena is free software: you can redistribute it and/or modify it under
7 // the terms of the GNU General Public License as published by the Free
8 // Software Foundation, version 2 of the License.
9 //
10 // Olena is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
17 //
18 // As a special exception, you may use this file as part of a free
19 // software project without restriction. Specifically, if other files
20 // instantiate templates or use macros or inline functions from this
21 // file, or you compile this file and link it with other files to produce
22 // an executable, this file does not by itself cause the resulting
23 // executable to be covered by the GNU General Public License. This
24 // exception does not however invalidate any other reasons why the
25 // executable file might be covered by the GNU General Public License.
26 
27 #ifndef SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_DOWN_LINK_HH
28 # define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_DOWN_LINK_HH
29 
33 
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 
37 # include <mln/accu/center.hh>
38 
39 # include <mln/labeling/compute.hh>
40 
41 # include <mln/math/abs.hh>
42 
43 # include <mln/util/array.hh>
44 
45 
46 # include <scribo/core/macros.hh>
47 # include <scribo/core/object_links.hh>
48 
49 # include <scribo/primitive/link/internal/find_link.hh>
50 # include <scribo/primitive/link/internal/link_single_dmax_base.hh>
51 
52 # include <scribo/primitive/link/compute.hh>
53 
54 
55 namespace scribo
56 {
57 
58  namespace primitive
59  {
60 
61  namespace link
62  {
63 
72  //
73  template <typename L>
74  inline
75  object_links<L>
76  with_single_down_link(const component_set<L>& comps,
77  unsigned neighb_max_distance,
78  anchor::Type anchor);
79 
82  //
83  template <typename L>
84  inline
85  object_links<L>
86  with_single_down_link(const component_set<L>& comps,
87  unsigned neighb_max_distance);
88 
89 
92  template <typename L>
93  inline
94  object_links<L>
95  with_single_down_link(const component_set<L>& comps);
96 
97 
98 # ifndef MLN_INCLUDE_ONLY
99 
100 
101  namespace internal
102  {
103 
104  // Functor
105 
106  template <typename L>
107  class single_down_functor
108  : public internal::link_single_dmax_base<L, single_down_functor<L> >
109  {
110  typedef
111  internal::link_single_dmax_base<L, single_down_functor<L> > sdowner_;
112 
113  public:
114  typedef mln_site(L) P;
115 
116  single_down_functor(const component_set<L>& comps, unsigned dmax)
117  : sdowner_(comps, dmax, anchor::Vertical)
118  {
119  }
120 
121  void compute_next_site_(P& p)
122  {
123  ++p.row();
124  }
125 
126  };
127 
128  } // end of namespace scribo::primitive::link::internal
129 
130 
131 
132  // Facades
133 
134  template <typename L>
135  inline
136  object_links<L>
137  with_single_down_link(const component_set<L>& comps,
138  unsigned neighb_max_distance,
139  anchor::Type anchor)
140  {
141  mln_trace("scribo::primitive::link::with_single_down_link");
142 
143  internal::single_down_functor<L>
144  functor(comps, neighb_max_distance);
145 
146  object_links<L> output = compute(functor, anchor);
147 
148  return output;
149  }
150 
151 
152  template <typename L>
153  inline
154  object_links<L>
155  with_single_down_link(const component_set<L>& comps,
156  unsigned neighb_max_distance)
157  {
158  return with_single_down_link(comps, neighb_max_distance,
159  anchor::MassCenter);
160  }
161 
162 
163  template <typename L>
164  inline
165  object_links<L>
166  with_single_down_link(const component_set<L>& comps)
167  {
168  return with_single_down_link(comps, mln_max(unsigned));
169  }
170 
171 
172 # endif // ! MLN_INCLUDE_ONLY
173 
174  } // end of namespace scribo::primitive::link
175 
176  } // end of namespace scribo::primitive
177 
178 } // end of namespace scribo
179 
180 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_DOWN_LINK_HH