$extrastylesheet
Olena  User documentation 2.1
An Image Processing Platform
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
make.hh
1 // Copyright (C) 2009, 2010 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 APPS_GRAPH_MORPHO_MAKE_HH
27 # define APPS_GRAPH_MORPHO_MAKE_HH
28 
31 
32 # include <mln/core/alias/complex_image.hh>
33 # include <mln/core/alias/box2d.hh>
34 
35 namespace make
36 {
37 
40  template <typename V>
41  inline
43  complex1d_image(const mln::box2d& support)
44  {
45  using namespace mln;
46 
47  unsigned nrows = support.pmax().row() - support.pmin().row() + 1;
48  unsigned ncols = support.pmax().col() - support.pmin().col() + 1;
49 
50  const unsigned dim = 1;
51  typedef topo::n_face<0, dim> vertex_t;
52 
53  typedef topo::complex<dim> complex_t;
54  complex_t c;
56  geom_t geom;
57 
58  // Vertices.
59  for (unsigned row = 0; row < nrows; ++row)
60  for (unsigned col = 0; col < ncols; ++col)
61  {
62  c.add_face();
63  geom.add_location(point2d(row,col));
64  }
65 
66  // Edges.
67  for (unsigned row = 0; row < nrows; ++row)
68  {
69  // Horizontal edges.
70  for (unsigned col = 1; col < ncols; ++col)
71  {
72  // First vertex.
73  vertex_t v1(c, row * ncols + col - 1);
74  // Second vertex.
75  vertex_t v2(c, row * ncols + col);
76  // Edge between V1 and V2.
77  c.add_face(v1 + v2);
78  }
79 
80  // Vertical edges.
81  if (row != 0)
82  for (unsigned col = 0; col < ncols; ++col)
83  {
84  // First vertex.
85  vertex_t v1(c, (row - 1) * ncols + col);
86  // Second vertex.
87  vertex_t v2(c, row * ncols + col);
88  // Edge between V1 and V2.
89  c.add_face(v1 + v2);
90  }
91  }
92 
93  // Site set (domain) of the image.
94  p_complex<dim, geom_t> pc(c, geom);
95 
96  // Image based on this site set.
97  typedef complex_image<dim, geom_t, V> ima_t;
98  ima_t ima(pc);
99  return ima;
100  }
101 
102 } // end of namespace make
103 
104 
105 #endif // ! APPS_GRAPH_MORPHO_MAKE_HH