$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
find_several_links.hh
1 // Copyright (C) 2009, 2010, 2011 EPITA Research and Development
2 // Laboratory (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_INTERNAL_FIND_SEVERAL_LINKS_HH
28 # define SCRIBO_PRIMITIVE_INTERNAL_FIND_SEVERAL_LINKS_HH
29 
36 
37 # include <mln/core/concept/image.hh>
38 
39 # include <mln/math/abs.hh>
40 
41 # include <mln/util/array.hh>
42 # include <mln/util/couple.hh>
43 
44 # include <scribo/core/concept/link_functor.hh>
45 # include <scribo/core/tag/anchor.hh>
46 # include <scribo/core/object_links.hh>
47 
48 
49 namespace scribo
50 {
51 
52  namespace primitive
53  {
54 
55  namespace link
56  {
57 
58  namespace internal
59  {
60 
70  template <typename F>
72  mln::util::couple<anchor::Type,
73  mln_site(scribo_support_(F))> >
74  find_several_links(Link_Functor<F>& functor,
75  unsigned current_object);
76 
77 
78 # ifndef MLN_INCLUDE_ONLY
79 
80  template <typename F>
82  mln::util::couple<anchor::Type,
83  mln_site(scribo_support_(F))> >
84  find_several_links(Link_Functor<F>& functor_,
85  unsigned current_object)
86  {
87  F& functor = exact(functor_);
88 
89  typedef mln_site(scribo_support_(F)) P;
90  typedef mln::util::couple<anchor::Type, P> link_t;
91 
92  functor.initialize_link(current_object); // <-- initialize_link
93 
94  for_all_anchors(a, functor.anchors()) // <-- nanchor && anchors
95  {
96  // FIXME:: See fixme at the beginning of this file.
97  anchor::Type anchor = functor.anchors()[a];
98 
99  mln_site(scribo_support_(F))
100  start_point = functor.start_point(current_object, anchor), // <-- start_point
101  p = start_point;
102 
103  mln_postcondition(p == start_point);
104 
105  while (functor.labeled_image().domain().has(p)
106  && ! functor.is_potential_link(current_object,
107  start_point, p) // <-- is_potential_link
108  && functor.verify_link_criterion(current_object,
109  start_point, p, anchor)) // <-- verify_link_criterion
110  functor.compute_next_site(p); // <-- compute_next_site
111 
112  if (functor.valid_link(current_object, start_point, p, anchor)) // <-- valid_link
113  functor.validate_link(current_object, start_point, p, anchor); // <-- validate_link
114  else
115  functor.invalidate_link(current_object, start_point, p, anchor); // <-- invalidate_link
116 
117  }
118 
119  link_t l = functor.finalize_link(current_object);
120 
121  bool b = (functor.link(current_object) != current_object); // <-- link
122  return mln::make::couple(b, l);
123  }
124 
125 # endif // MLN_INCLUDE_ONLY
126 
127 
128  } // end of namespace scribo::primitive::link::internal
129 
130  } // end of namespace scribo::primitive::link
131 
132  } // end of namespace scribo::primitive
133 
134 } // end of namespace scribo
135 
136 
137 #endif // ! SCRIBO_PRIMITIVE_INTERNAL_FIND_SEVERAL_LINKS_HH