$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
with_several_right_links_overlap.hh
1 // Copyright (C) 2009 EPITA Research and Development Laboratory (LRDE)
2 //
3 // This file is part of Olena.
4 //
5 // Olena is free software: you can redistribute it and/or modify it under
6 // the terms of the GNU General Public License as published by the Free
7 // Software Foundation, version 2 of the License.
8 //
9 // Olena is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with Olena. If not, see <http://www.gnu.org/licenses/>.
16 //
17 // As a special exception, you may use this file as part of a free
18 // software project without restriction. Specifically, if other files
19 // instantiate templates or use macros or inline functions from this
20 // file, or you compile this file and link it with other files to produce
21 // an executable, this file does not by itself cause the resulting
22 // executable to be covered by the GNU General Public License. This
23 // exception does not however invalidate any other reasons why the
24 // executable file might be covered by the GNU General Public License.
25 
26 #ifndef SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_OVERLAP_HH
27 # define SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_OVERLAP_HH
28 
32 
33 # include <mln/core/concept/image.hh>
34 # include <mln/core/concept/neighborhood.hh>
35 
36 # include <mln/util/array.hh>
37 
38 # include <scribo/core/object_links.hh>
39 # include <scribo/core/object_image.hh>
40 # include <scribo/core/macros.hh>
41 # include <scribo/primitive/internal/init_link_array.hh>
42 # include <scribo/primitive/link/internal/find_several_links.hh>
43 # include <scribo/primitive/link/internal/link_several_dmax_base.hh>
44 # include <scribo/util/text.hh>
45 
46 
47 namespace scribo
48 {
49 
50  namespace primitive
51  {
52 
53  namespace link
54  {
55 
56  using namespace mln;
57 
63  template <typename L>
64  inline
65  object_links<L>
66  with_several_right_links_overlap(const object_image(L)& objects,
67  unsigned neighb_max_distance);
68 
70  template <typename L>
71  inline
72  object_links<L>
73  with_several_right_links_overlap(const object_image(L)& objects);
74 
75 
76 # ifndef MLN_INCLUDE_ONLY
77 
78  namespace internal
79  {
80 
81  template <typename L>
82  class several_right_overlap_functor
83  : public link_several_dmax_base<L, several_right_overlap_functor<L> >
84  {
85  typedef
86  link_several_dmax_base<L, several_right_overlap_functor<L> >
87  super_;
88 
89  public:
90  typedef mln_site(L) P;
91 
92  several_right_overlap_functor(const object_image(L)& objects,
93  unsigned dmax)
94  : super_(objects, dmax, 3)
95  {
96  }
97 
98  mln_site(L)
99  start_point_(unsigned current_object, unsigned anchor)
100  {
101  return anchors_3(this->objects_, this->mass_centers_,
102  current_object, anchor);
103  }
104 
105 
106  void compute_next_site_(P& p)
107  {
108  ++p.col();
109  }
110 
111  };
112 
113  } // end of namespace scribo::primitive::link::internal
114 
115 
116  template <typename L>
117  inline
118  object_links<L>
119  with_several_right_links_overlap(const object_image(L)& objects,
120  unsigned neighb_max_distance)
121  {
122  mln_trace("scribo::primitive::link::with_several_right_links_overlap");
123 
124  mln_precondition(objects.is_valid());
125 
126  internal::several_right_overlap_functor<L>
127  functor(objects, neighb_max_distance);
128 
129  for_all_ncomponents(current_object, objects.nlabels())
130  internal::find_several_links(functor, current_object);
131 
132  return functor.links();
133  }
134 
135 
136  template <typename L>
137  inline
138  object_links<L>
139  with_several_right_links_overlap(const object_image(L)& objects)
140  {
141  return with_several_right_links_overlap(objects, mln_max(unsigned));
142  }
143 
144 
145 # endif // ! MLN_INCLUDE_ONLY
146 
147  } // end of namespace scribo::primitive::link
148 
149  } // end of namespace scribo::primitive
150 
151 } // end of namespace scribo
152 
153 #endif // ! SCRIBO_PRIMITIVE_LINK_WITH_SEVERAL_RIGHT_LINKS_OVERLAP_HH