$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
merge_double_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_MERGE_DOUBLE_LINK_HH
28 # define SCRIBO_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_HH
29 
30 
35 
36 
37 # include <mln/core/concept/image.hh>
38 # include <mln/core/site_set/box.hh>
39 
40 # include <mln/accu/shape/bbox.hh>
41 
42 # include <mln/data/compare.hh>
43 
44 # include <mln/util/array.hh>
45 
46 # include <scribo/core/macros.hh>
47 
48 # include <scribo/core/object_links.hh>
49 # include <scribo/core/component_set.hh>
50 # include <scribo/primitive/internal/find_root.hh>
51 # include <scribo/primitive/internal/is_link_valid.hh>
52 
53 
54 namespace scribo
55 {
56 
57  namespace primitive
58  {
59 
60  namespace link
61  {
62 
72  template <typename L>
73  object_links<L>
74  merge_double_link(const object_links<L>& left_link,
75  const object_links<L>& right_link);
76 
77 
78 
79 # ifndef MLN_INCLUDE_ONLY
80 
81 
82  template <typename L>
83  inline
84  object_links<L>
85  merge_double_link(const object_links<L>& left_link,
86  const object_links<L>& right_link)
87  {
88  mln_trace("scribo::primitive::link::merge_double_link");
89 
90  mln_precondition(left_link.is_valid());
91  mln_precondition(right_link.is_valid());
92  mln_precondition(left_link.components() == right_link.components());
93 
94  const component_set<L>& components = left_link.components();
95 
96  object_links<L> merge(components);
97  merge.init();
98 
99  for_all_comps(i, components)
100  {
101  if (components(i).tag() == component::Ignored)
102  merge.disable_linking(i);
103  else
104  {
106  right_link, i))
107  merge.update(i, left_link(i));
108  else
109  merge.clear(i);
110  }
111  }
112 
113  return merge;
114  }
115 
116 
117 # endif // ! MLN_INCLUDE_ONLY
118 
119 
120  } // end of namespace scribo::primitive::link
121 
122  } // end of namespace scribo::primitive
123 
124 } // end of namespace scribo
125 
126 #endif // ! SCRIBO_PRIMITIVE_LINK_MERGE_DOUBLE_LINK_HH