$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
is_simple_point2d.hh
1 // Copyright (C) 2010, 2011, 2013, 2014 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 MLN_TOPO_IS_SIMPLE_POINT2D_HH
28 # define MLN_TOPO_IS_SIMPLE_POINT2D_HH
29 
32 
33 # include <mln/core/concept/function.hh>
34 # include <mln/core/concept/image.hh>
35 # include <mln/core/concept/neighborhood.hh>
36 
37 # include <mln/topo/is_simple_2d.hh>
38 
39 
40 namespace mln
41 {
42 
43  namespace topo
44  {
45 
54  template <typename I, typename N>
55  class is_simple_point2d : public Function_v2b< is_simple_point2d<I, N> >
56  {
57  public:
59  typedef bool result;
60 
65  is_simple_point2d(const Neighborhood<N>& nbh_fg,
66  const Neighborhood<N>& nbh_bg);
67 
73  is_simple_point2d(const Neighborhood<N>& nbh_fg,
74  const Neighborhood<N>& nbh_bg,
75  const Image<I>& ima);
76 
78  void set_image(const Image<I>& ima);
79 
83  bool operator()(const mln_psite(I)& p) const;
84 
85  private:
87  const N& nbh_fg_;
89  const N& nbh_bg_;
91  const I* ima_;
92  };
93 
94 
95 
96 # ifndef MLN_INCLUDE_ONLY
97 
98  template <typename I, typename N>
99  inline
101  const Neighborhood<N>& nbh_bg)
102  : nbh_fg_(exact(nbh_fg)), nbh_bg_(exact(nbh_bg)),
103  ima_(0)
104  {
105  }
106 
107  template <typename I, typename N>
108  inline
110  const Neighborhood<N>& nbh_bg,
111  const Image<I>& ima)
112  : nbh_fg_(exact(nbh_fg)), nbh_bg_(exact(nbh_bg)),
113  ima_(exact(&ima))
114  {
115  }
116 
117  template <typename I, typename N>
118  inline
119  void
120  is_simple_point2d<I, N>::set_image(const Image<I>& ima)
121  {
122  ima_ = exact(&ima);
123  }
124 
125  template <typename I, typename N>
126  inline
127  bool
128  is_simple_point2d<I, N>::operator()(const mln_psite(I)& p) const
129  {
130  mln_precondition(ima_);
131  return
132  connectivity_number_2d(*ima_, nbh_fg_, p, true ) == 1 &&
133  connectivity_number_2d(*ima_, nbh_bg_, p, false) == 1;
134  }
135 
136 # endif // MLN_INCLUDE_ONLY
137 
138  } // end of namespace mln::topo
139 
140 } // end of namespace mln
141 
142 #endif // ! MLN_TOPO_IS_SIMPLE_POINT2D_HH