$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
is_facet.hh
1 // Copyright (C) 2009, 2011 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 MLN_TOPO_IS_FACET_HH
27 # define MLN_TOPO_IS_FACET_HH
28 
31 
32 # include <mln/metal/equal.hh>
33 
34 # include <mln/core/site_set/complex_psite.hh>
35 # include <mln/core/image/complex_neighborhoods.hh>
36 # include <mln/core/image/complex_neighborhood_piter.hh>
37 
38 
39 namespace mln
40 {
41 
42  namespace topo
43  {
44 
45  /* FIXME: Make this routine a method of mln::complex_psite? Or
46  better, a method of mln::topo::face? */
47 
48  /* FIXME: Use a pix<I> object as input of is_facet instead of a
49  (psite, image) pair? */
50 
63  template <typename I, typename NH>
64  bool
65  is_facet(const Image<I>& ima, const mln_psite(I)& f,
66  const Neighborhood<NH>& higher_adj_nbh);
67 
68 
69 
70 # ifndef MLN_INCLUDE_ONLY
71 
72  template <typename I, typename NH>
73  inline
74  bool
75  is_facet(const Image<I>& ima_, const mln_psite(I)& f,
76  const Neighborhood<NH>& higher_adj_nbh_)
77  {
78  // Ensure I is a binary image type.
79  /* FIXME: Not compatible with proxy/morphers on values. */
80  mlc_equal(mln_value(I), bool)::check();
81 
82  const I& ima = exact(ima_);
83  const NH& higher_adj_nbh = exact(higher_adj_nbh_);
84 
85  // F cannot be a facet if it does not belong to the complex.
86  if (!ima(f))
87  return false;
88 
89  // This routine considers that looking for faces of dimension
90  // n+1 is enough (which is the case if the image is a complex).
91  mln_niter(NH) n(higher_adj_nbh, f);
92  for_all(n)
93  // If the neighborhood is not empty, then F is included in a face
94  // of higher dimension.
95  if (ima.has(n) && ima(n))
96  return false;
97  // Otherwise, F is a facet.
98  return true;
99  }
100 
101 # endif // MLN_INCLUDE_ONLY
102 
103  } // end of namespace mln::topo
104 
105 } // end of namespace mln
106 
107 #endif // ! MLN_TOPO_IS_FACET_HH