Milena (Olena)  User documentation 2.0a Id
 All Classes Namespaces Functions Variables Typedefs Enumerator Groups Pages
face_data.hh
1 // Copyright (C) 2008, 2009, 2010, 2011 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_FACE_DATA_HH
28 # define MLN_TOPO_FACE_DATA_HH
29 
36 
37 # include <vector>
38 
39 # include <mln/topo/algebraic_n_face.hh>
40 
41 
42 namespace mln
43 {
44 
45  namespace topo
46  {
47 
48  // Forward declarations (external).
49  template <unsigned D> class complex;
50  namespace internal
51  {
52  template <unsigned N, unsigned D> struct lower_dim_faces_set_mixin;
53  template <unsigned N, unsigned D> struct higher_dim_faces_set_mixin;
54 
55  template <unsigned N, unsigned D>
56  struct lower_dim_adj_faces_if_dim_matches_;
57  template <unsigned N, unsigned D>
58  struct higher_dim_adj_faces_if_dim_matches_;
59  }
60 
61  // Forward declarations (internal).
62  template <unsigned N, unsigned D> class n_face;
63  namespace internal
64  {
65  template <unsigned N, unsigned D> class lower_dim_faces_data_mixin;
66  template <unsigned N, unsigned D> class higher_dim_faces_data_mixin;
67  }
68 
69 
70  /*------------.
71  | Face data. |
72  `------------*/
73 
75  template <unsigned N, unsigned D> class face_data;
76 
77 
78  // Specialization for the faces of highest dimension (\p D).
79  template <unsigned D>
80  class face_data<D, D> : public internal::lower_dim_faces_data_mixin<D, D>
81  {
82  };
83 
84  // Specialization for the faces of intermediate dimension (greater
85  // than 0, lower than \p D).
86  template <unsigned N, unsigned D>
87  class face_data : public internal::lower_dim_faces_data_mixin<N, D>,
88  public internal::higher_dim_faces_data_mixin<N, D>
89  {
90  };
91 
92  // Specialization for the faces of lowest dimension (0).
93  template <unsigned D>
94  class face_data<0u, D> : public internal::higher_dim_faces_data_mixin<0u, D>
95  {
96  };
97 
98  // Specialization for the case of a 0-complex.
99  template <>
100  class face_data<0u, 0u>
101  {
102  };
103 
104 
105  namespace internal
106  {
107 
110  template <unsigned N, unsigned D>
111  class lower_dim_faces_data_mixin
112  {
113  typedef std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces_type;
114 
115  public:
116  void connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f);
117 
118  private:
119  friend struct mln::topo::internal::lower_dim_faces_set_mixin<N, D>;
120  friend struct mln::topo::internal::lower_dim_adj_faces_if_dim_matches_<N, D>;
121  friend lower_dim_faces_type
123 
124  // FIXME: Rename as lower_dim_adj_faces_ (as well as related members).
125  lower_dim_faces_type lower_dim_faces_;
126  };
127 
128  template <unsigned N, unsigned D>
129  class higher_dim_faces_data_mixin
130  {
131  typedef std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces_type;
132 
133  public:
134  void connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f);
135 
136  private:
137  friend struct mln::topo::internal::higher_dim_faces_set_mixin<N, D>;
138  friend struct mln::topo::internal::higher_dim_adj_faces_if_dim_matches_<N, D>;
139  friend higher_dim_faces_type
141 
142  // FIXME: Rename as higher_dim_adj_faces_ (as well as related members).
143  higher_dim_faces_type higher_dim_faces_;
144  };
146 
147  } // end of namespace mln::topo::internal
148 
149 
150 
151 # ifndef MLN_INCLUDE_ONLY
152 
153  namespace internal
154  {
155  template <unsigned N, unsigned D>
156  inline
157  void
158  lower_dim_faces_data_mixin<N, D>::connect_lower_dim_face(const algebraic_n_face<N - 1, D>& f)
159  {
160  lower_dim_faces_.push_back(f);
161  }
162 
163  template <unsigned N, unsigned D>
164  inline
165  void
166  higher_dim_faces_data_mixin<N, D>::connect_higher_dim_face(const algebraic_n_face<N + 1, D>& f)
167  {
168  higher_dim_faces_.push_back(f);
169  }
170 
171  } // end of namespace mln::topo::internal
172 
173 # endif // ! MLN_INCLUDE_ONLY
174 
175  } // end of namespace mln::topo
176 
177 } // end of namespace mln
178 
179 #endif // ! MLN_TOPO_FACE_DATA_HH