$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
with_single_right_link.hh
1 // Copyright (C) 2009, 2011, 2013 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_RIGHT_LINK_HH
28 # define SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_HH
29 
33 
34 
35 # include <mln/core/concept/image.hh>
36 # include <mln/core/concept/neighborhood.hh>
37 
38 # include <mln/accu/center.hh>
39 # include <mln/labeling/compute.hh>
40 # include <mln/math/abs.hh>
41 # include <mln/util/array.hh>
42 
43 # include <scribo/core/macros.hh>
44 # include <scribo/core/tag/anchor.hh>
45 # include <scribo/core/component_set.hh>
46 # include <scribo/core/object_links.hh>
47 
48 # include <scribo/primitive/link/internal/find_link.hh>
49 # include <scribo/primitive/link/internal/link_single_dmax_base.hh>
50 
51 # include <scribo/primitive/link/compute.hh>
52 
53 
54 namespace scribo
55 {
56 
57  namespace primitive
58  {
59 
60  namespace link
61  {
62 
73  //
74  template <typename L>
75  inline
76  object_links<L>
77  with_single_right_link(const component_set<L>& components,
78  unsigned neighb_max_distance,
79  anchor::Type anchor = anchor::MassCenter);
80 
81 
84  //
85  template <typename L>
86  inline
87  object_links<L>
88  with_single_right_link(const component_set<L>& components);
89 
90 
91 
92 # ifndef MLN_INCLUDE_ONLY
93 
94 
95  namespace internal
96  {
97 
98  // Functor
99 
100  template <typename L>
101  class single_right_functor
102  : public internal::link_single_dmax_base<L, single_right_functor<L> >
103  {
104  typedef
105  internal::link_single_dmax_base<L, single_right_functor<L> > super_;
106 
107  public:
108  typedef mln_site(L) P;
109 
110  single_right_functor(const component_set<L>& components, unsigned dmax)
111  : super_(components, dmax, anchor::Horizontal)
112  {
113  }
114 
115  void compute_next_site_(P& p)
116  {
117  ++p.col();
118  }
119 
120  };
121 
122  } // end of namespace scribo::primitive::link::internal
123 
124 
125 
126  // Facades
127 
128  template <typename L>
129  inline
130  object_links<L>
131  with_single_right_link(const component_set<L>& components,
132  unsigned neighb_max_distance,
133  anchor::Type anchor)
134  {
135  mln_trace("scribo::primitive::link::with_single_right_link");
136 
137  mln_precondition(components.is_valid());
138 
139  internal::single_right_functor<L>
140  functor(components, neighb_max_distance);
141 
142  object_links<L> output = compute(functor, anchor);
143 
144  return output;
145  }
146 
147 
148  template <typename L>
149  inline
150  object_links<L>
151  with_single_right_link(const component_set<L>& components)
152  {
153  return with_single_right_link(components, mln_max(unsigned),
154  anchor::MassCenter);
155  }
156 
157 
158 # endif // ! MLN_INCLUDE_ONLY
159 
160  } // end of namespace scribo::primitive::link
161 
162  } // end of namespace scribo::primitive
163 
164 } // end of namespace scribo
165 
166 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SINGLE_RIGHT_LINK_HH