26 #ifndef MLN_TOPO_ADJ_M_FACE_ITER_HH
27 # define MLN_TOPO_ADJ_M_FACE_ITER_HH
38 # include <mln/topo/internal/complex_relative_iterator_base.hh>
39 # include <mln/topo/face.hh>
49 template <
unsigned D>
class complex;
52 template <
unsigned D>
class adj_m_face_iterator;
71 :
public internal::forward_complex_relative_iterator_base< topo::face<D>,
73 adj_m_face_fwd_iter<D> >,
74 public internal::adj_m_face_iterator<D>
79 typedef internal::forward_complex_relative_iterator_base< topo::face<D>,
82 typedef internal::adj_m_face_iterator<D> impl_;
92 template <
typename Fref>
100 void update_adj_faces_();
117 template <
unsigned D>
119 :
public internal::backward_complex_relative_iterator_base< topo::face<D>,
121 adj_m_face_bkd_iter<D> >,
122 public internal::adj_m_face_iterator<D>
127 typedef internal::backward_complex_relative_iterator_base< topo::face<D>,
130 typedef internal::adj_m_face_iterator<D> impl_;
140 template <
typename Fref>
148 void update_adj_faces_();
159 template <
unsigned D>
160 class adj_m_face_iterator
163 adj_m_face_iterator();
164 adj_m_face_iterator(
unsigned m);
170 void set_m(
unsigned m);
186 # ifndef MLN_INCLUDE_ONLY
192 template <
unsigned D>
198 template <
unsigned D>
199 template <
typename Fref>
202 : super_(f_ref), impl_(m)
206 template <
unsigned D>
211 mln_precondition(this->c_);
213 this->update_adj_faces__(*this->c_, this->adj_faces_);
221 template <
unsigned D>
227 template <
unsigned D>
228 template <
typename Fref>
231 : super_(f_ref), impl_(m)
235 template <
unsigned D>
240 mln_precondition(this->c_);
242 this->update_adj_faces__(*this->c_, this->adj_faces_);
253 template <
unsigned D>
255 adj_m_face_iterator<D>::adj_m_face_iterator()
260 template <
unsigned D>
262 adj_m_face_iterator<D>::adj_m_face_iterator(
unsigned m)
265 mln_precondition(m <= D);
268 template <
unsigned D>
270 adj_m_face_iterator<D>::m()
const
275 template <
unsigned D>
277 adj_m_face_iterator<D>::set_m(
unsigned m)
282 template <
unsigned D>
285 adj_m_face_iterator<D>::update_adj_faces__(
const topo::face<D>& center,
286 std::vector< algebraic_face<D> >& adj_faces)
290 if (center.n() == m_)
293 typedef std::vector < topo::algebraic_face<D> > faces_t;
294 typedef std::set < topo::algebraic_face<D> > faces_set_t;
310 faces_set_t work_faces_set;
313 for (
unsigned p = center.n(); p != m_; (p < m_ ? ++p : --p) )
315 mln_invariant (p != m_);
316 for (
typename faces_t::const_iterator g = p_faces.begin();
317 g != p_faces.end(); ++g)
319 mln_invariant (g->n() != m_);
320 faces_t q_faces = g->n() < m_ ?
321 g->higher_dim_adj_faces() :
322 g->lower_dim_adj_faces();
331 for (
typename faces_t::const_iterator h = q_faces.begin();
332 h != q_faces.end(); ++h)
334 if (work_faces_set.find(*h) == work_faces_set.end())
336 work_faces.push_back(*h);
337 work_faces_set.insert(*h);
342 for (
typename faces_t::const_reverse_iterator h =
347 h != (
typename faces_t::const_reverse_iterator) q_faces.rend();
350 if (work_faces_set.find(*h) == work_faces_set.end())
352 work_faces.push_back(*h);
353 work_faces_set.insert(*h);
357 work_faces.swap(p_faces);
359 work_faces_set.clear();
367 # endif // ! MLN_INCLUDE_ONLY
373 #endif // ! MLN_TOPO_ADJ_M_FACE_ITER_HH