27 #ifndef MLN_TOPO_ALGEBRAIC_FACE_HH
28 # define MLN_TOPO_ALGEBRAIC_FACE_HH
34 #include <mln/topo/face.hh>
35 #include <mln/topo/algebraic_n_face.hh>
45 template <
unsigned D>
class complex;
46 template <
unsigned N,
unsigned D>
class n_face;
47 template <
unsigned N,
unsigned D>
class face_data;
102 template <
unsigned D>
106 template <
unsigned D>
119 template <
unsigned D>
127 template <
unsigned D>
139 template <
unsigned D>
140 bool operator< (const algebraic_face<D>& lhs,
147 template <
unsigned D>
149 operator<<(std::ostream& ostr, const algebraic_face<D>& f);
153 # ifndef MLN_INCLUDE_ONLY
155 template <
unsigned D>
158 : super_(), sign_(true)
162 template <
unsigned D>
165 unsigned face_id,
bool sign)
166 : super_(c, n, face_id), sign_(sign)
169 mln_precondition(n <= D);
172 template <
unsigned D>
175 : super_(f), sign_(sign)
178 mln_precondition(f.n() <= D);
181 template <
unsigned D>
182 template <
unsigned N>
185 : super_(f), sign_(f.sign())
188 metal::bool_< N <= D >::check();
192 template <
unsigned D>
200 template <
unsigned D>
209 template <
unsigned D>
217 template <
unsigned D>
224 template <
unsigned D>
229 f2.set_sign(!f.sign());
234 template <
unsigned D>
240 mln_precondition(lhs.cplx() == rhs.cplx());
242 lhs.n() == rhs.n() &&
243 lhs.face_id() == rhs.face_id() &&
244 lhs.sign() == rhs.sign();
247 template <
unsigned D>
253 mln_precondition(lhs.cplx() == rhs.cplx());
254 return !(lhs ==
rhs);
257 template <
unsigned D>
263 mln_precondition(lhs.cplx() == rhs.cplx());
265 mln_precondition(lhs.n() == rhs.n());
266 return lhs.face_id() < rhs.face_id();
270 template <
unsigned D>
273 operator<<(std::ostream& ostr, const algebraic_face<D>& f)
276 ostr <<
"(cplx = " << f.cplx().addr() <<
", dim = " << f.n()
277 <<
", id = " << f.face_id() <<
", sign = " << f.sign()<<
')';
293 template <
unsigned N,
unsigned D>
294 std::vector< algebraic_face<D> >
295 lower_dim_adj_faces_if_dim_matches_<N, D>::operator()(
const face<D>& face)
297 metal::bool_< (N <= D) >::check();
298 metal::bool_< (N > 1) >::check();
303 std::vector< algebraic_n_face<N - 1, D> > lower_dim_faces =
304 data.lower_dim_faces_;
305 std::vector< topo::algebraic_face<D> > result;
306 for (
typename std::vector< algebraic_n_face<N - 1, D> >::const_iterator f =
307 lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
308 result.push_back(*f);
312 return internal::lower_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
315 template <
unsigned D>
316 std::vector< algebraic_face<D> >
317 lower_dim_adj_faces_if_dim_matches_<1, D>::operator()(
const face<D>& face)
321 mln_precondition(face.n() == 1);
322 face_data<1, D>& data = face.template
data<1>();
323 std::vector< algebraic_n_face<0, D> > lower_dim_faces =
324 data.lower_dim_faces_;
325 std::vector< topo::algebraic_face<D> > result;
326 for (
typename std::vector< algebraic_n_face<0, D> >::const_iterator f =
327 lower_dim_faces.begin(); f != lower_dim_faces.end(); ++f)
328 result.push_back(*f);
332 template <
unsigned N,
unsigned D>
333 std::vector< algebraic_face<D> >
334 higher_dim_adj_faces_if_dim_matches_<N, D>::operator()(
const face<D>& face)
336 metal::bool_< (N < D) >::check();
341 std::vector< algebraic_n_face<N + 1, D> > higher_dim_faces =
342 data.higher_dim_faces_;
343 std::vector< topo::algebraic_face<D> > result;
344 for (
typename std::vector< algebraic_n_face<N + 1, D> >::const_iterator f =
345 higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
346 result.push_back(*f);
351 internal::higher_dim_adj_faces_if_dim_matches_<N - 1, D>()(face);
354 template <
unsigned D>
355 std::vector< algebraic_face<D> >
356 higher_dim_adj_faces_if_dim_matches_<0, D>::operator()(
const face<D>& face)
360 mln_precondition(face.n() == 0);
361 face_data<0, D>& data = face.template
data<0>();
362 std::vector< algebraic_n_face<1, D> > higher_dim_faces =
363 data.higher_dim_faces_;
364 std::vector< topo::algebraic_face<D> > result;
365 for (
typename std::vector< algebraic_n_face<1, D> >::const_iterator f =
366 higher_dim_faces.begin(); f != higher_dim_faces.end(); ++f)
367 result.push_back(*f);
374 # endif // ! MLN_INCLUDE_ONLY
380 #endif // ! MLN_TOPO_ALGEBRAIC_FACE_HH