$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
component_aligned.hh
1 // Copyright (C) 2010, 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_FILTER_INTERNAL_COMPONENT_ALIGNED_HH
28 # define SCRIBO_FILTER_INTERNAL_COMPONENT_ALIGNED_HH
29 
33 
34 
35 # include <mln/util/array.hh>
36 # include <mln/math/abs.hh>
37 # include <mln/math/pi.hh>
38 
39 # include <scribo/core/macros.hh>
40 # include <scribo/core/tag/anchor.hh>
41 # include <scribo/core/component_set.hh>
42 # include <scribo/filter/internal/alignment_angle.hh>
43 
44 namespace scribo
45 {
46 
47  namespace filter
48  {
49 
50  namespace internal
51  {
52 
53  using namespace mln;
54 
55 
56  template <typename L>
57  bool
58  component_aligned(const component_set<L>& comps,
59  unsigned current_object, unsigned nbh_object,
60  anchor::Type anchor, float max_alpha);
61 
62 
63  template <typename L>
64  bool
65  component_aligned_rad(const component_set<L>& comps,
66  unsigned current_object, unsigned nbh_object,
67  anchor::Type anchor, float max_alpha_rad);
68 
69 
70 # ifndef MLN_INCLUDE_ONLY
71 
72 
73  template <typename L>
74  bool
75  component_aligned(const component_set<L>& comps,
76  unsigned current_object, unsigned /* nbh_object */,
77  anchor::Type anchor, float max_alpha)
78  {
79  float max_alpha_rad = (max_alpha / 180.0f) * math::pi;
80 
81  return component_aligned(comps, current_object, anchor, max_alpha_rad);
82  }
83 
84 
85 
86  template <typename L>
87  bool
88  component_aligned_rad(const component_set<L>& comps,
89  unsigned current_object, unsigned nbh_object,
90  anchor::Type anchor, float max_alpha_rad)
91  {
92  mln_trace("scribo::filter::internal::component_aligned_rad");
93 
94  mln_precondition(comps.is_valid());
95 
96  float angle = alignment_angle(comps, current_object,
97  nbh_object, anchor);
98 
99  bool output = (angle <= max_alpha_rad);
100 
101  return output;
102  }
103 
104 # endif // ! MLN_INCLUDE_ONLY
105 
106  } // end of namespace scribo::filter::internal
107 
108  } // end of namespace scribo::filter
109 
110 } // end of namespace scribo
111 
112 
113 #endif // ! SCRIBO_FILTER_INTERNAL_COMPONENT_ALIGNED_HH