Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Iterators.hh
1 /*===========================================================================*\
2  * *
3  * OpenVolumeMesh *
4  * Copyright (C) 2011 by Computer Graphics Group, RWTH Aachen *
5  * www.openvolumemesh.org *
6  * *
7  *---------------------------------------------------------------------------*
8  * This file is part of OpenVolumeMesh. *
9  * *
10  * OpenVolumeMesh is free software: you can redistribute it and/or modify *
11  * it under the terms of the GNU Lesser General Public License as *
12  * published by the Free Software Foundation, either version 3 of *
13  * the License, or (at your option) any later version with the *
14  * following exceptions: *
15  * *
16  * If other files instantiate templates or use macros *
17  * or inline functions from this file, or you compile this file and *
18  * link it with other files to produce an executable, this file does *
19  * not by itself cause the resulting executable to be covered by the *
20  * GNU Lesser General Public License. This exception does not however *
21  * invalidate any other reasons why the executable file might be *
22  * covered by the GNU Lesser General Public License. *
23  * *
24  * OpenVolumeMesh is distributed in the hope that it will be useful, *
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
27  * GNU Lesser General Public License for more details. *
28  * *
29  * You should have received a copy of the GNU LesserGeneral Public *
30  * License along with OpenVolumeMesh. If not, *
31  * see <http://www.gnu.org/licenses/>. *
32  * *
33 \*===========================================================================*/
34 
35 /*===========================================================================*\
36  * *
37  * $Revision$ *
38  * $Date$ *
39  * $LastChangedBy$ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef ITERATORS_HH_
44 #define ITERATORS_HH_
45 
46 #include <iterator>
47 #include <set>
48 #include <vector>
49 
50 #include "OpenVolumeMeshHandle.hh"
51 
52 namespace OpenVolumeMesh {
53 
54 class TopologyKernel;
55 
56 template <
57 class OH /* Output handle type */>
58 class BaseIterator {
59 public:
60 
61  // STL compliance
62  typedef std::bidirectional_iterator_tag iterator_category;
63  typedef int difference_type;
64  typedef const OH value_type;
65  typedef const OH* pointer;
66  typedef const OH& reference;
67 
68 
69  BaseIterator(const TopologyKernel* _mesh, const OH& _ch) :
70  valid_(true), cur_handle_(_ch), mesh_(_mesh) {}
71 
72  BaseIterator(const TopologyKernel* _mesh) :
73  valid_(true), mesh_(_mesh) {}
74 
75  // STL compliance (needs to have default constructor)
76  BaseIterator() : valid_(false), mesh_(0) {}
77  virtual ~BaseIterator() {}
78  bool operator== (const BaseIterator& _c) const {
79  return (this->cur_handle_ == _c.cur_handle() &&
80  this->valid_ == _c.valid() &&
81  this->mesh_ == _c.mesh());
82  }
83  bool operator!= (const BaseIterator& _c) const {
84  return !this->operator==(_c);
85  }
86 
87  pointer operator->() const {
88  return &cur_handle_;
89  }
90 
91  reference operator*() const {
92  return cur_handle_;
93  }
94 
95  bool operator< (const BaseIterator& _c) const {
96  return cur_handle_.idx() < _c.cur_handle_.idx();
97  }
98 
99  BaseIterator& operator=(const BaseIterator& _c) {
100  this->valid_ = _c.valid();
101  this->cur_handle_ = _c.cur_handle();
102  this->mesh_ = _c.mesh();
103  return *this;
104  }
105 
106  operator bool() const {
107  return valid_;
108  }
109 
110  void valid(bool _valid) {
111  valid_ = _valid;
112  }
113  bool valid() const {
114  return valid_;
115  }
116  void cur_handle(const OH& _h) {
117  cur_handle_ = _h;
118  }
119  reference cur_handle() const {
120  return cur_handle_;
121  }
122  const TopologyKernel* mesh() const {
123  return mesh_;
124  }
125 
126 private:
127 
128  bool valid_;
129  OH cur_handle_;
130  const TopologyKernel* mesh_;
131 };
132 
133 
134 #if __cplusplus >= 201103L
135 
136 #include <type_traits>
137 
138 template<class I>
139 using is_ovm_iterator = std::is_base_of<BaseIterator<typename std::remove_const<typename I::value_type>::type>, I>;
140 
141 // provide begin() and end() for the iterator pairs provided in TopologyKernel,
142 // so we can use range-for, e.g. for(const auto &vh: mesh.vertices()) works.
143 template<class I>
144 typename std::enable_if<is_ovm_iterator<I>::value, I>::type
145 begin(const std::pair<I, I>& iterpair)
146 {
147  return iterpair.first;
148 }
149 
150 template<class I>
151 typename std::enable_if<is_ovm_iterator<I>::value, I>::type
152 end(const std::pair<I, I>& iterpair)
153 {
154  return iterpair.second;
155 }
156 
157 #endif // C++11
158 
159 template <
160 class IH /* Input handle type */,
161 class OH /* Output handle type */>
162 class BaseCirculator : public BaseIterator<OH> {
163 public:
164 
165  typedef BaseIterator<OH> BaseIter;
166 
167  BaseCirculator(const TopologyKernel* _mesh, const IH& _ih, const OH& _oh, int _max_laps = 1) :
168  BaseIter(_mesh, _oh),
169  lap_(0),
170  max_laps_(_max_laps),
171  ref_handle_(_ih)
172  {}
173 
174  BaseCirculator(const TopologyKernel* _mesh, const IH& _ih, int _max_laps = 1) :
175  BaseIter(_mesh, OH()),
176  lap_(0),
177  max_laps_(_max_laps),
178  ref_handle_(_ih)
179  {}
180 
181  // STL compliance (needs to have default constructor)
182  BaseCirculator() :
183  BaseIter(),
184  lap_(0),
185  max_laps_(1)
186  {}
187 
188  virtual ~BaseCirculator() {}
189 
190  bool operator== (const BaseCirculator& _c) const {
191  return (BaseIter::operator==(_c) &&
192  this->lap() == _c.lap() &&
193  this->ref_handle() == _c.ref_handle());
194  }
195  bool operator!= (const BaseCirculator& _c) const {
196  return !this->operator==(_c);
197  }
198 
199  bool operator< (const BaseCirculator& _c) const {
200  if (lap_ == _c.lap_)
201  return BaseIter::operator<(_c);
202  else
203  return lap_ < _c.lap_;
204  }
205 
206  BaseCirculator& operator=(const BaseCirculator& _c) {
207  BaseIter::operator=(_c);
208  this->ref_handle_ = _c.ref_handle();
209  this->lap_ = _c.lap_;
210  this->max_laps_ = _c.max_laps_;
211  return *this;
212  }
213 
214  const IH& ref_handle() const {
215  return ref_handle_;
216  }
217 
218  void lap(int _lap) {
219  lap_ = _lap;
220  }
221  int lap() const {
222  return lap_;
223  }
224 
225  void max_laps(int _max_laps) {
226  max_laps_ = _max_laps;
227  }
228  int max_laps() const {
229  return max_laps_;
230  }
231 
232 protected:
233  int lap_;
234  int max_laps_;
235  IH ref_handle_;
236 
237 };
238 
239 //===========================================================================
240 
242  public BaseCirculator<
243  VertexHandle,
244  HalfEdgeHandle> {
245 public:
246  typedef BaseCirculator<
247  VertexHandle,
249 
250 
251  VertexOHalfEdgeIter(const VertexHandle& _vIdx,
252  const TopologyKernel* _mesh, int _max_laps = 1);
253 
254  // Post increment/decrement operator
255  VertexOHalfEdgeIter operator++(int) {
256  VertexOHalfEdgeIter cpy = *this;
257  ++(*this);
258  return cpy;
259  }
260  VertexOHalfEdgeIter operator--(int) {
261  VertexOHalfEdgeIter cpy = *this;
262  --(*this);
263  return cpy;
264  }
265  VertexOHalfEdgeIter operator+(int _n) {
266  VertexOHalfEdgeIter cpy = *this;
267  for(int i = 0; i < _n; ++i) {
268  ++cpy;
269  }
270  return cpy;
271  }
272  VertexOHalfEdgeIter operator-(int _n) {
273  VertexOHalfEdgeIter cpy = *this;
274  for(int i = 0; i < _n; ++i) {
275  --cpy;
276  }
277  return cpy;
278  }
279  VertexOHalfEdgeIter& operator+=(int _n) {
280  for(int i = 0; i < _n; ++i) {
281  ++(*this);
282  }
283  return *this;
284  }
285  VertexOHalfEdgeIter& operator-=(int _n) {
286  for(int i = 0; i < _n; ++i) {
287  --(*this);
288  }
289  return *this;
290  }
291 
292  VertexOHalfEdgeIter& operator++();
293  VertexOHalfEdgeIter& operator--();
294 
295 private:
296 
297  size_t cur_index_;
298 };
299 
300 
301 
302 //===========================================================================
303 
305  public BaseCirculator<
306  VertexHandle,
307  VertexHandle> {
308 public:
309  typedef BaseCirculator<
310  VertexHandle,
311  VertexHandle> BaseIter;
312 
313 
314  VertexVertexIter(const VertexHandle& _vIdx,
315  const TopologyKernel* _mesh, int _max_laps = 1);
316 
317  // Post increment/decrement operator
318  VertexVertexIter operator++(int) {
319  VertexVertexIter cpy = *this;
320  ++(*this);
321  return cpy;
322  }
323  VertexVertexIter operator--(int) {
324  VertexVertexIter cpy = *this;
325  --(*this);
326  return cpy;
327  }
328  VertexVertexIter operator+(int _n) {
329  VertexVertexIter cpy = *this;
330  for(int i = 0; i < _n; ++i) {
331  ++cpy;
332  }
333  return cpy;
334  }
335  VertexVertexIter operator-(int _n) {
336  VertexVertexIter cpy = *this;
337  for(int i = 0; i < _n; ++i) {
338  --cpy;
339  }
340  return cpy;
341  }
342  VertexVertexIter& operator+=(int _n) {
343  for(int i = 0; i < _n; ++i) {
344  ++(*this);
345  }
346  return *this;
347  }
348  VertexVertexIter& operator-=(int _n) {
349  for(int i = 0; i < _n; ++i) {
350  --(*this);
351  }
352  return *this;
353  }
354 
355  VertexVertexIter& operator++();
356  VertexVertexIter& operator--();
357 
358 private:
359 
360  size_t cur_index_;
361 };
362 
363 //===========================================================================
364 
366  HalfEdgeHandle,
367  HalfFaceHandle> {
368 public:
369  typedef BaseCirculator<
372 
373 
374  HalfEdgeHalfFaceIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh, int _max_laps);
375 
376  // Post increment/decrement operator
377  HalfEdgeHalfFaceIter operator++(int) {
378  HalfEdgeHalfFaceIter cpy = *this;
379  ++(*this);
380  return cpy;
381  }
382  HalfEdgeHalfFaceIter operator--(int) {
383  HalfEdgeHalfFaceIter cpy = *this;
384  --(*this);
385  return cpy;
386  }
387  HalfEdgeHalfFaceIter operator+(int _n) {
388  HalfEdgeHalfFaceIter cpy = *this;
389  for(int i = 0; i < _n; ++i) {
390  ++cpy;
391  }
392  return cpy;
393  }
394  HalfEdgeHalfFaceIter operator-(int _n) {
395  HalfEdgeHalfFaceIter cpy = *this;
396  for(int i = 0; i < _n; ++i) {
397  --cpy;
398  }
399  return cpy;
400  }
401  HalfEdgeHalfFaceIter& operator+=(int _n) {
402  for(int i = 0; i < _n; ++i) {
403  ++(*this);
404  }
405  return *this;
406  }
407  HalfEdgeHalfFaceIter& operator-=(int _n) {
408  for(int i = 0; i < _n; ++i) {
409  --(*this);
410  }
411  return *this;
412  }
413 
414  HalfEdgeHalfFaceIter& operator++();
415  HalfEdgeHalfFaceIter& operator--();
416 
417 private:
418  size_t cur_index_;
419 };
420 
421 //===========================================================================
422 
424  VertexHandle,
425  FaceHandle> {
426 public:
427  typedef BaseCirculator<
428  VertexHandle,
430 
431  VertexFaceIter(const VertexHandle& _vIdx, const TopologyKernel* _mesh, int _max_laps = 1);
432 
433  // Post increment/decrement operator
434  VertexFaceIter operator++(int) {
435  VertexFaceIter cpy = *this;
436  ++(*this);
437  return cpy;
438  }
439  VertexFaceIter operator--(int) {
440  VertexFaceIter cpy = *this;
441  --(*this);
442  return cpy;
443  }
444  VertexFaceIter operator+(int _n) {
445  VertexFaceIter cpy = *this;
446  for(int i = 0; i < _n; ++i) {
447  ++cpy;
448  }
449  return cpy;
450  }
451  VertexFaceIter operator-(int _n) {
452  VertexFaceIter cpy = *this;
453  for(int i = 0; i < _n; ++i) {
454  --cpy;
455  }
456  return cpy;
457  }
458  VertexFaceIter& operator+=(int _n) {
459  for(int i = 0; i < _n; ++i) {
460  ++(*this);
461  }
462  return *this;
463  }
464  VertexFaceIter& operator-=(int _n) {
465  for(int i = 0; i < _n; ++i) {
466  --(*this);
467  }
468  return *this;
469  }
470 
471  VertexFaceIter& operator++();
472  VertexFaceIter& operator--();
473 
474 private:
475  std::vector<FaceHandle> faces_;
476  size_t cur_index_;
477 };
478 
479 //===========================================================================
480 
482  VertexHandle,
483  CellHandle> {
484 public:
485  typedef BaseCirculator<
486  VertexHandle,
488 
489  VertexCellIter(const VertexHandle& _vIdx, const TopologyKernel* _mesh, int _max_laps = 1);
490 
491  // Post increment/decrement operator
492  VertexCellIter operator++(int) {
493  VertexCellIter cpy = *this;
494  ++(*this);
495  return cpy;
496  }
497  VertexCellIter operator--(int) {
498  VertexCellIter cpy = *this;
499  --(*this);
500  return cpy;
501  }
502  VertexCellIter operator+(int _n) {
503  VertexCellIter cpy = *this;
504  for(int i = 0; i < _n; ++i) {
505  ++cpy;
506  }
507  return cpy;
508  }
509  VertexCellIter operator-(int _n) {
510  VertexCellIter cpy = *this;
511  for(int i = 0; i < _n; ++i) {
512  --cpy;
513  }
514  return cpy;
515  }
516  VertexCellIter& operator+=(int _n) {
517  for(int i = 0; i < _n; ++i) {
518  ++(*this);
519  }
520  return *this;
521  }
522  VertexCellIter& operator-=(int _n) {
523  for(int i = 0; i < _n; ++i) {
524  --(*this);
525  }
526  return *this;
527  }
528 
529  VertexCellIter& operator++();
530  VertexCellIter& operator--();
531 
532 private:
533  std::vector<CellHandle> cells_;
534  size_t cur_index_;
535 };
536 
538  HalfEdgeHandle,
539  CellHandle> {
540 public:
541  typedef BaseCirculator<
544 
545 
546  HalfEdgeCellIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh, int _max_laps = 1);
547 
548  // Post increment/decrement operator
549  HalfEdgeCellIter operator++(int) {
550  HalfEdgeCellIter cpy = *this;
551  ++(*this);
552  return cpy;
553  }
554  HalfEdgeCellIter operator--(int) {
555  HalfEdgeCellIter cpy = *this;
556  --(*this);
557  return cpy;
558  }
559  HalfEdgeCellIter operator+(int _n) {
560  HalfEdgeCellIter cpy = *this;
561  for(int i = 0; i < _n; ++i) {
562  ++cpy;
563  }
564  return cpy;
565  }
566  HalfEdgeCellIter operator-(int _n) {
567  HalfEdgeCellIter cpy = *this;
568  for(int i = 0; i < _n; ++i) {
569  --cpy;
570  }
571  return cpy;
572  }
573  HalfEdgeCellIter& operator+=(int _n) {
574  for(int i = 0; i < _n; ++i) {
575  ++(*this);
576  }
577  return *this;
578  }
579  HalfEdgeCellIter& operator-=(int _n) {
580  for(int i = 0; i < _n; ++i) {
581  --(*this);
582  }
583  return *this;
584  }
585 
586  HalfEdgeCellIter& operator++();
587  HalfEdgeCellIter& operator--();
588 
589 private:
590  CellHandle getCellHandle(int _cur_index) const;
591 
592 private:
593  std::vector<CellHandle> cells_;
594  size_t cur_index_;
595 };
596 
597 //===========================================================================
598 
600  CellHandle,
601  VertexHandle> {
602 public:
603  typedef BaseCirculator<
604  CellHandle,
606 
607  CellVertexIter(const CellHandle& _cIdx, const TopologyKernel* _mesh, int _max_laps = 1);
608 
609  // Post increment/decrement operator
610  CellVertexIter operator++(int) {
611  CellVertexIter cpy = *this;
612  ++(*this);
613  return cpy;
614  }
615  CellVertexIter operator--(int) {
616  CellVertexIter cpy = *this;
617  --(*this);
618  return cpy;
619  }
620  CellVertexIter operator+(int _n) {
621  CellVertexIter cpy = *this;
622  for(int i = 0; i < _n; ++i) {
623  ++cpy;
624  }
625  return cpy;
626  }
627  CellVertexIter operator-(int _n) {
628  CellVertexIter cpy = *this;
629  for(int i = 0; i < _n; ++i) {
630  --cpy;
631  }
632  return cpy;
633  }
634  CellVertexIter& operator+=(int _n) {
635  for(int i = 0; i < _n; ++i) {
636  ++(*this);
637  }
638  return *this;
639  }
640  CellVertexIter& operator-=(int _n) {
641  for(int i = 0; i < _n; ++i) {
642  --(*this);
643  }
644  return *this;
645  }
646 
647  CellVertexIter& operator++();
648  CellVertexIter& operator--();
649 
650 private:
651  std::vector<VertexHandle> incident_vertices_;
652  size_t cur_index_;
653 };
654 
655 //===========================================================================
656 
658  CellHandle,
659  CellHandle> {
660 public:
661  typedef BaseCirculator<
662  CellHandle,
663  CellHandle> BaseIter;
664 
665  CellCellIter(const CellHandle& _cIdx, const TopologyKernel* _mesh, int _max_laps = 1);
666 
667  // Post increment/decrement operator
668  CellCellIter operator++(int) {
669  CellCellIter cpy = *this;
670  ++(*this);
671  return cpy;
672  }
673  CellCellIter operator--(int) {
674  CellCellIter cpy = *this;
675  --(*this);
676  return cpy;
677  }
678  CellCellIter operator+(int _n) {
679  CellCellIter cpy = *this;
680  for(int i = 0; i < _n; ++i) {
681  ++cpy;
682  }
683  return cpy;
684  }
685  CellCellIter operator-(int _n) {
686  CellCellIter cpy = *this;
687  for(int i = 0; i < _n; ++i) {
688  --cpy;
689  }
690  return cpy;
691  }
692  CellCellIter& operator+=(int _n) {
693  for(int i = 0; i < _n; ++i) {
694  ++(*this);
695  }
696  return *this;
697  }
698  CellCellIter& operator-=(int _n) {
699  for(int i = 0; i < _n; ++i) {
700  --(*this);
701  }
702  return *this;
703  }
704 
705  CellCellIter& operator++();
706  CellCellIter& operator--();
707 
708 private:
709  std::vector<CellHandle> adjacent_cells_;
710  size_t cur_index_;
711 };
712 
713 //===========================================================================
714 
716  HalfFaceHandle,
717  VertexHandle> {
718 public:
719  typedef BaseCirculator<
722 
723  HalfFaceVertexIter(const HalfFaceHandle& _hIdx, const TopologyKernel* _mesh, int _max_laps = 1);
724 
725  // Post increment/decrement operator
726  HalfFaceVertexIter operator++(int) {
727  HalfFaceVertexIter cpy = *this;
728  ++(*this);
729  return cpy;
730  }
731  HalfFaceVertexIter operator--(int) {
732  HalfFaceVertexIter cpy = *this;
733  --(*this);
734  return cpy;
735  }
736  HalfFaceVertexIter operator+(int _n) {
737  HalfFaceVertexIter cpy = *this;
738  for(int i = 0; i < _n; ++i) {
739  ++cpy;
740  }
741  return cpy;
742  }
743  HalfFaceVertexIter operator-(int _n) {
744  HalfFaceVertexIter cpy = *this;
745  for(int i = 0; i < _n; ++i) {
746  --cpy;
747  }
748  return cpy;
749  }
750  HalfFaceVertexIter& operator+=(int _n) {
751  for(int i = 0; i < _n; ++i) {
752  ++(*this);
753  }
754  return *this;
755  }
756  HalfFaceVertexIter& operator-=(int _n) {
757  for(int i = 0; i < _n; ++i) {
758  --(*this);
759  }
760  return *this;
761  }
762 
763  HalfFaceVertexIter& operator++();
764  HalfFaceVertexIter& operator--();
765 
766 private:
767  std::vector<VertexHandle> vertices_;
768  size_t cur_index_;
769 };
770 
771 //===========================================================================
772 
773 class BoundaryHalfFaceHalfFaceIter : public BaseCirculator<HalfFaceHandle,
774  HalfFaceHandle> {
775 private:
777  HalfFaceHandle> BaseIter;
778 public:
779  BoundaryHalfFaceHalfFaceIter(const HalfFaceHandle& _ref_h,
780  const TopologyKernel* _mesh, int _max_laps = 1);
781 
782  // Post increment/decrement operator
783  BoundaryHalfFaceHalfFaceIter operator++(int) {
784  BoundaryHalfFaceHalfFaceIter cpy = *this;
785  ++(*this);
786  return cpy;
787  }
788  BoundaryHalfFaceHalfFaceIter operator--(int) {
789  BoundaryHalfFaceHalfFaceIter cpy = *this;
790  --(*this);
791  return cpy;
792  }
793  BoundaryHalfFaceHalfFaceIter operator+(int _n) {
794  BoundaryHalfFaceHalfFaceIter cpy = *this;
795  for(int i = 0; i < _n; ++i) {
796  ++cpy;
797  }
798  return cpy;
799  }
800  BoundaryHalfFaceHalfFaceIter operator-(int _n) {
801  BoundaryHalfFaceHalfFaceIter cpy = *this;
802  for(int i = 0; i < _n; ++i) {
803  --cpy;
804  }
805  return cpy;
806  }
807  BoundaryHalfFaceHalfFaceIter& operator+=(int _n) {
808  for(int i = 0; i < _n; ++i) {
809  ++(*this);
810  }
811  return *this;
812  }
813  BoundaryHalfFaceHalfFaceIter& operator-=(int _n) {
814  for(int i = 0; i < _n; ++i) {
815  --(*this);
816  }
817  return *this;
818  }
819 
820  const EdgeHandle& common_edge() const { return common_edges_[cur_index_]; }
821 
822  BoundaryHalfFaceHalfFaceIter& operator++();
823  BoundaryHalfFaceHalfFaceIter& operator--();
824 
825 private:
826  std::vector<HalfFaceHandle> neighbor_halffaces_;
827  std::vector<EdgeHandle> common_edges_;
828  size_t cur_index_;
829 };
830 
831 //===========================================================================
832 
833 class VertexIter : public BaseIterator<VertexHandle> {
834 public:
836 
837 
838  VertexIter(const TopologyKernel* _mesh, const VertexHandle& _vh = VertexHandle(0));
839 
840  // Post increment/decrement operator
841  VertexIter operator++(int) {
842  VertexIter cpy = *this;
843  ++(*this);
844  return cpy;
845  }
846  VertexIter operator--(int) {
847  VertexIter cpy = *this;
848  --(*this);
849  return cpy;
850  }
851  VertexIter operator+(int _n) {
852  VertexIter cpy = *this;
853  for(int i = 0; i < _n; ++i) {
854  ++cpy;
855  }
856  return cpy;
857  }
858  VertexIter operator-(int _n) {
859  VertexIter cpy = *this;
860  for(int i = 0; i < _n; ++i) {
861  --cpy;
862  }
863  return cpy;
864  }
865  VertexIter& operator+=(int _n) {
866  for(int i = 0; i < _n; ++i) {
867  ++(*this);
868  }
869  return *this;
870  }
871  VertexIter& operator-=(int _n) {
872  for(int i = 0; i < _n; ++i) {
873  --(*this);
874  }
875  return *this;
876  }
877 
878  VertexIter& operator++();
879  VertexIter& operator--();
880 
881 private:
882  int cur_index_;
883 };
884 
885 //===========================================================================
886 
887 class EdgeIter : public BaseIterator<EdgeHandle> {
888 public:
890 
891 
892  EdgeIter(const TopologyKernel* _mesh, const EdgeHandle& _eh = EdgeHandle(0));
893 
894  // Post increment/decrement operator
895  EdgeIter operator++(int) {
896  EdgeIter cpy = *this;
897  ++(*this);
898  return cpy;
899  }
900  EdgeIter operator--(int) {
901  EdgeIter cpy = *this;
902  --(*this);
903  return cpy;
904  }
905  EdgeIter operator+(int _n) {
906  EdgeIter cpy = *this;
907  for(int i = 0; i < _n; ++i) {
908  ++cpy;
909  }
910  return cpy;
911  }
912  EdgeIter operator-(int _n) {
913  EdgeIter cpy = *this;
914  for(int i = 0; i < _n; ++i) {
915  --cpy;
916  }
917  return cpy;
918  }
919  EdgeIter& operator+=(int _n) {
920  for(int i = 0; i < _n; ++i) {
921  ++(*this);
922  }
923  return *this;
924  }
925  EdgeIter& operator-=(int _n) {
926  for(int i = 0; i < _n; ++i) {
927  --(*this);
928  }
929  return *this;
930  }
931 
932  EdgeIter& operator++();
933  EdgeIter& operator--();
934 
935 private:
936  int cur_index_;
937 };
938 
939 //===========================================================================
940 
941 class HalfEdgeIter : public BaseIterator<HalfEdgeHandle> {
942 public:
944 
945 
946  HalfEdgeIter(const TopologyKernel* _mesh, const HalfEdgeHandle& _heh = HalfEdgeHandle(0));
947 
948  // Post increment/decrement operator
949  HalfEdgeIter operator++(int) {
950  HalfEdgeIter cpy = *this;
951  ++(*this);
952  return cpy;
953  }
954  HalfEdgeIter operator--(int) {
955  HalfEdgeIter cpy = *this;
956  --(*this);
957  return cpy;
958  }
959  HalfEdgeIter operator+(int _n) {
960  HalfEdgeIter cpy = *this;
961  for(int i = 0; i < _n; ++i) {
962  ++cpy;
963  }
964  return cpy;
965  }
966  HalfEdgeIter operator-(int _n) {
967  HalfEdgeIter cpy = *this;
968  for(int i = 0; i < _n; ++i) {
969  --cpy;
970  }
971  return cpy;
972  }
973  HalfEdgeIter& operator+=(int _n) {
974  for(int i = 0; i < _n; ++i) {
975  ++(*this);
976  }
977  return *this;
978  }
979  HalfEdgeIter& operator-=(int _n) {
980  for(int i = 0; i < _n; ++i) {
981  --(*this);
982  }
983  return *this;
984  }
985 
986  HalfEdgeIter& operator++();
987  HalfEdgeIter& operator--();
988 
989 private:
990  int cur_index_;
991 };
992 
993 //===========================================================================
994 
995 class FaceIter : public BaseIterator<FaceHandle> {
996 public:
998 
999 
1000  FaceIter(const TopologyKernel* _mesh, const FaceHandle& _fh = FaceHandle(0));
1001 
1002  // Post increment/decrement operator
1003  FaceIter operator++(int) {
1004  FaceIter cpy = *this;
1005  ++(*this);
1006  return cpy;
1007  }
1008  FaceIter operator--(int) {
1009  FaceIter cpy = *this;
1010  --(*this);
1011  return cpy;
1012  }
1013  FaceIter operator+(int _n) {
1014  FaceIter cpy = *this;
1015  for(int i = 0; i < _n; ++i) {
1016  ++cpy;
1017  }
1018  return cpy;
1019  }
1020  FaceIter operator-(int _n) {
1021  FaceIter cpy = *this;
1022  for(int i = 0; i < _n; ++i) {
1023  --cpy;
1024  }
1025  return cpy;
1026  }
1027  FaceIter& operator+=(int _n) {
1028  for(int i = 0; i < _n; ++i) {
1029  ++(*this);
1030  }
1031  return *this;
1032  }
1033  FaceIter& operator-=(int _n) {
1034  for(int i = 0; i < _n; ++i) {
1035  --(*this);
1036  }
1037  return *this;
1038  }
1039 
1040  FaceIter& operator++();
1041  FaceIter& operator--();
1042 
1043 private:
1044  int cur_index_;
1045 };
1046 
1047 //===========================================================================
1048 
1049 class HalfFaceIter : public BaseIterator<HalfFaceHandle> {
1050 public:
1052 
1053 
1054  HalfFaceIter(const TopologyKernel* _mesh, const HalfFaceHandle& _hfh = HalfFaceHandle(0));
1055 
1056  // Post increment/decrement operator
1057  HalfFaceIter operator++(int) {
1058  HalfFaceIter cpy = *this;
1059  ++(*this);
1060  return cpy;
1061  }
1062  HalfFaceIter operator--(int) {
1063  HalfFaceIter cpy = *this;
1064  --(*this);
1065  return cpy;
1066  }
1067  HalfFaceIter operator+(int _n) {
1068  HalfFaceIter cpy = *this;
1069  for(int i = 0; i < _n; ++i) {
1070  ++cpy;
1071  }
1072  return cpy;
1073  }
1074  HalfFaceIter operator-(int _n) {
1075  HalfFaceIter cpy = *this;
1076  for(int i = 0; i < _n; ++i) {
1077  --cpy;
1078  }
1079  return cpy;
1080  }
1081  HalfFaceIter& operator+=(int _n) {
1082  for(int i = 0; i < _n; ++i) {
1083  ++(*this);
1084  }
1085  return *this;
1086  }
1087  HalfFaceIter& operator-=(int _n) {
1088  for(int i = 0; i < _n; ++i) {
1089  --(*this);
1090  }
1091  return *this;
1092  }
1093 
1094  HalfFaceIter& operator++();
1095  HalfFaceIter& operator--();
1096 
1097 private:
1098  int cur_index_;
1099 };
1100 
1101 //===========================================================================
1102 
1103 class CellIter : public BaseIterator<CellHandle> {
1104 public:
1106 
1107 
1108  CellIter(const TopologyKernel* _mesh, const CellHandle& _ch = CellHandle(0));
1109 
1110  // Post increment/decrement operator
1111  CellIter operator++(int) {
1112  CellIter cpy = *this;
1113  ++(*this);
1114  return cpy;
1115  }
1116  CellIter operator--(int) {
1117  CellIter cpy = *this;
1118  --(*this);
1119  return cpy;
1120  }
1121  CellIter operator+(int _n) {
1122  CellIter cpy = *this;
1123  for(int i = 0; i < _n; ++i) {
1124  ++cpy;
1125  }
1126  return cpy;
1127  }
1128  CellIter operator-(int _n) {
1129  CellIter cpy = *this;
1130  for(int i = 0; i < _n; ++i) {
1131  --cpy;
1132  }
1133  return cpy;
1134  }
1135  CellIter& operator+=(int _n) {
1136  for(int i = 0; i < _n; ++i) {
1137  ++(*this);
1138  }
1139  return *this;
1140  }
1141  CellIter& operator-=(int _n) {
1142  for(int i = 0; i < _n; ++i) {
1143  --(*this);
1144  }
1145  return *this;
1146  }
1147 
1148  CellIter& operator++();
1149  CellIter& operator--();
1150 
1151 private:
1152  int cur_index_;
1153 };
1154 
1155 //===========================================================================
1156 
1157 class BoundaryFaceIter : public BaseIterator<FaceHandle> {
1158 public:
1160 
1161 
1162  BoundaryFaceIter(const TopologyKernel* _mesh);
1163 
1164  // Post increment/decrement operator
1165  BoundaryFaceIter operator++(int) {
1166  BoundaryFaceIter cpy = *this;
1167  ++(*this);
1168  return cpy;
1169  }
1170  BoundaryFaceIter operator--(int) {
1171  BoundaryFaceIter cpy = *this;
1172  --(*this);
1173  return cpy;
1174  }
1175  BoundaryFaceIter operator+(int _n) {
1176  BoundaryFaceIter cpy = *this;
1177  for(int i = 0; i < _n; ++i) {
1178  ++cpy;
1179  }
1180  return cpy;
1181  }
1182  BoundaryFaceIter operator-(int _n) {
1183  BoundaryFaceIter cpy = *this;
1184  for(int i = 0; i < _n; ++i) {
1185  --cpy;
1186  }
1187  return cpy;
1188  }
1189  BoundaryFaceIter& operator+=(int _n) {
1190  for(int i = 0; i < _n; ++i) {
1191  ++(*this);
1192  }
1193  return *this;
1194  }
1195  BoundaryFaceIter& operator-=(int _n) {
1196  for(int i = 0; i < _n; ++i) {
1197  --(*this);
1198  }
1199  return *this;
1200  }
1201 
1202  BoundaryFaceIter& operator++();
1203  BoundaryFaceIter& operator--();
1204 
1205 private:
1206  FaceIter bf_it_;
1207 };
1208 
1209 //===========================================================================
1210 
1211 } // Namespace OpenVolumeMesh
1212 
1213 #endif /* ITERATORS_HH_ */