OpenVolumeMesh
 All Classes Functions Variables Typedefs 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: 216 $ *
38  * $Date: 2012-07-18 10:27:26 +0200 (Wed, 18 Jul 2012) $ *
39  * $LastChangedBy: kremer $ *
40  * *
41 \*===========================================================================*/
42 
43 #ifndef ITERATORS_HH_
44 #define ITERATORS_HH_
45 
46 #include <set>
47 #include <vector>
48 #include <iterator>
49 
50 #include "OpenVolumeMeshHandle.hh"
51 
52 namespace OpenVolumeMesh {
53 
54 class TopologyKernel;
55 
56 template <
57 class IH /* Input handle type */,
58 class OH /* Output handle type */>
59 class BaseIterator {
60 public:
61 
62  // STL compliance
63  typedef std::bidirectional_iterator_tag iterator_category;
64  typedef int difference_type;
65  typedef OH value_type;
66  typedef OH* pointer;
67  typedef OH& reference;
68 
69  BaseIterator(const TopologyKernel* _mesh, const IH& _ih, const OH& _ch) :
70  valid_(true), cur_handle_(_ch), ref_handle_(_ih), mesh_(_mesh) {}
71 
72  BaseIterator(const TopologyKernel* _mesh, const IH& _ih) :
73  valid_(true), ref_handle_(_ih), mesh_(_mesh) {}
74 
75  BaseIterator(const TopologyKernel* _mesh) :
76  valid_(true), mesh_(_mesh) {}
77 
78  // STL compliance (needs to have default constructor)
79  BaseIterator() : valid_(false), mesh_(0) {}
80  virtual ~BaseIterator() {}
81  bool operator== (const BaseIterator& _c) const {
82  return (this->cur_handle_ == _c.cur_handle() &&
83  this->ref_handle_ == _c.ref_handle() &&
84  this->mesh_ == _c.mesh());
85  }
86  bool operator!= (const BaseIterator& _c) const {
87  return !this->operator==(_c);
88  }
89 
90  const OH* operator->() const {
91  return &cur_handle_;
92  }
93 
94  const OH& operator*() const {
95  return cur_handle_;
96  }
97 
98  bool operator< (const BaseIterator& _c) const {
99  return cur_handle_.idx() < _c.cur_handle_.idx();
100  }
101 
102  BaseIterator& operator=(const BaseIterator& _c) {
103  this->valid_ = _c.valid();
104  this->cur_handle_ = _c.cur_handle();
105  this->ref_handle_ = _c.ref_handle();
106  this->mesh_ = _c.mesh();
107  return *this;
108  }
109 
110  operator bool() const {
111  return valid_;
112  }
113 
114  void valid(bool _valid) {
115  valid_ = _valid;
116  }
117  bool valid() const {
118  return valid_;
119  }
120  void cur_handle(const OH& _h) {
121  cur_handle_ = _h;
122  }
123  const OH& cur_handle() const {
124  return cur_handle_;
125  }
126  const IH& ref_handle() const {
127  return ref_handle_;
128  }
129  const TopologyKernel* mesh() const {
130  return mesh_;
131  }
132 
133 private:
134 
135  bool valid_;
136  OH cur_handle_;
137  IH ref_handle_;
138  const TopologyKernel* mesh_;
139 };
140 
141 //===========================================================================
142 
144  public BaseIterator<
145  VertexHandle,
146  HalfEdgeHandle> {
147 public:
148  typedef BaseIterator<
149  VertexHandle,
151 
152 
153  VertexOHalfEdgeIter(const VertexHandle& _vIdx,
154  const TopologyKernel* _mesh);
155 
156  // Post increment/decrement operator
157  VertexOHalfEdgeIter operator++(int) {
158  VertexOHalfEdgeIter cpy = *this;
159  ++(*this);
160  return cpy;
161  }
162  VertexOHalfEdgeIter operator--(int) {
163  VertexOHalfEdgeIter cpy = *this;
164  --(*this);
165  return cpy;
166  }
167  VertexOHalfEdgeIter operator+(int _n) {
168  VertexOHalfEdgeIter cpy = *this;
169  for(int i = 0; i < _n; ++i) {
170  ++cpy;
171  }
172  return cpy;
173  }
174  VertexOHalfEdgeIter operator-(int _n) {
175  VertexOHalfEdgeIter cpy = *this;
176  for(int i = 0; i < _n; ++i) {
177  --cpy;
178  }
179  return cpy;
180  }
181  VertexOHalfEdgeIter& operator+=(int _n) {
182  for(int i = 0; i < _n; ++i) {
183  ++(*this);
184  }
185  return *this;
186  }
187  VertexOHalfEdgeIter& operator-=(int _n) {
188  for(int i = 0; i < _n; ++i) {
189  --(*this);
190  }
191  return *this;
192  }
193 
194  VertexOHalfEdgeIter& operator++();
195  VertexOHalfEdgeIter& operator--();
196 
197 private:
198 
199  int cur_index_;
200 };
201 
202 //===========================================================================
203 
205  HalfEdgeHandle,
206  HalfFaceHandle> {
207 public:
208  typedef BaseIterator<
211 
212 
213  HalfEdgeHalfFaceIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh);
214 
215  // Post increment/decrement operator
216  HalfEdgeHalfFaceIter operator++(int) {
217  HalfEdgeHalfFaceIter cpy = *this;
218  ++(*this);
219  return cpy;
220  }
221  HalfEdgeHalfFaceIter operator--(int) {
222  HalfEdgeHalfFaceIter cpy = *this;
223  --(*this);
224  return cpy;
225  }
226  HalfEdgeHalfFaceIter operator+(int _n) {
227  HalfEdgeHalfFaceIter cpy = *this;
228  for(int i = 0; i < _n; ++i) {
229  ++cpy;
230  }
231  return cpy;
232  }
233  HalfEdgeHalfFaceIter operator-(int _n) {
234  HalfEdgeHalfFaceIter cpy = *this;
235  for(int i = 0; i < _n; ++i) {
236  --cpy;
237  }
238  return cpy;
239  }
240  HalfEdgeHalfFaceIter& operator+=(int _n) {
241  for(int i = 0; i < _n; ++i) {
242  ++(*this);
243  }
244  return *this;
245  }
246  HalfEdgeHalfFaceIter& operator-=(int _n) {
247  for(int i = 0; i < _n; ++i) {
248  --(*this);
249  }
250  return *this;
251  }
252 
253  HalfEdgeHalfFaceIter& operator++();
254  HalfEdgeHalfFaceIter& operator--();
255 
256 private:
257  int cur_index_;
258 };
259 
260 //===========================================================================
261 
263  VertexHandle,
264  CellHandle> {
265 public:
266  typedef BaseIterator<
267  VertexHandle,
269 
270  VertexCellIter(const VertexHandle& _vIdx, const TopologyKernel* _mesh);
271  VertexCellIter& operator=(const VertexCellIter& _c) {
272  BaseIter::operator=(_c);
273  cells_ = cells_;
274  cell_iter_ = cells_.begin();
275  return *this;
276  }
277 
278  // Post increment/decrement operator
279  VertexCellIter operator++(int) {
280  VertexCellIter cpy = *this;
281  ++(*this);
282  return cpy;
283  }
284  VertexCellIter operator--(int) {
285  VertexCellIter cpy = *this;
286  --(*this);
287  return cpy;
288  }
289  VertexCellIter operator+(int _n) {
290  VertexCellIter cpy = *this;
291  for(int i = 0; i < _n; ++i) {
292  ++cpy;
293  }
294  return cpy;
295  }
296  VertexCellIter operator-(int _n) {
297  VertexCellIter cpy = *this;
298  for(int i = 0; i < _n; ++i) {
299  --cpy;
300  }
301  return cpy;
302  }
303  VertexCellIter& operator+=(int _n) {
304  for(int i = 0; i < _n; ++i) {
305  ++(*this);
306  }
307  return *this;
308  }
309  VertexCellIter& operator-=(int _n) {
310  for(int i = 0; i < _n; ++i) {
311  --(*this);
312  }
313  return *this;
314  }
315 
316  VertexCellIter& operator++();
317  VertexCellIter& operator--();
318 
319 private:
320  std::set<CellHandle> cells_;
321  std::set<CellHandle>::const_iterator cell_iter_;
322 };
323 
325  HalfEdgeHandle,
326  CellHandle> {
327 public:
328  typedef BaseIterator<
331 
332 
333  HalfEdgeCellIter(const HalfEdgeHandle& _heIdx, const TopologyKernel* _mesh);
334 
335  // Post increment/decrement operator
336  HalfEdgeCellIter operator++(int) {
337  HalfEdgeCellIter cpy = *this;
338  ++(*this);
339  return cpy;
340  }
341  HalfEdgeCellIter operator--(int) {
342  HalfEdgeCellIter cpy = *this;
343  --(*this);
344  return cpy;
345  }
346  HalfEdgeCellIter operator+(int _n) {
347  HalfEdgeCellIter cpy = *this;
348  for(int i = 0; i < _n; ++i) {
349  ++cpy;
350  }
351  return cpy;
352  }
353  HalfEdgeCellIter operator-(int _n) {
354  HalfEdgeCellIter cpy = *this;
355  for(int i = 0; i < _n; ++i) {
356  --cpy;
357  }
358  return cpy;
359  }
360  HalfEdgeCellIter& operator+=(int _n) {
361  for(int i = 0; i < _n; ++i) {
362  ++(*this);
363  }
364  return *this;
365  }
366  HalfEdgeCellIter& operator-=(int _n) {
367  for(int i = 0; i < _n; ++i) {
368  --(*this);
369  }
370  return *this;
371  }
372 
373  HalfEdgeCellIter& operator++();
374  HalfEdgeCellIter& operator--();
375 
376 private:
377  int cur_index_;
378 };
379 
380 //===========================================================================
381 
383  CellHandle,
384  VertexHandle> {
385 public:
386  typedef BaseIterator<
387  CellHandle,
389 
390  CellVertexIter(const CellHandle& _cIdx, const TopologyKernel* _mesh);
391  CellVertexIter& operator=(const CellVertexIter& _c) {
392  BaseIter::operator=(_c);
393  incident_vertices_ = _c.incident_vertices_;
394  v_iter_ = incident_vertices_.begin();
395  return *this;
396  }
397 
398  // Post increment/decrement operator
399  CellVertexIter operator++(int) {
400  CellVertexIter cpy = *this;
401  ++(*this);
402  return cpy;
403  }
404  CellVertexIter operator--(int) {
405  CellVertexIter cpy = *this;
406  --(*this);
407  return cpy;
408  }
409  CellVertexIter operator+(int _n) {
410  CellVertexIter cpy = *this;
411  for(int i = 0; i < _n; ++i) {
412  ++cpy;
413  }
414  return cpy;
415  }
416  CellVertexIter operator-(int _n) {
417  CellVertexIter cpy = *this;
418  for(int i = 0; i < _n; ++i) {
419  --cpy;
420  }
421  return cpy;
422  }
423  CellVertexIter& operator+=(int _n) {
424  for(int i = 0; i < _n; ++i) {
425  ++(*this);
426  }
427  return *this;
428  }
429  CellVertexIter& operator-=(int _n) {
430  for(int i = 0; i < _n; ++i) {
431  --(*this);
432  }
433  return *this;
434  }
435 
436  CellVertexIter& operator++();
437  CellVertexIter& operator--();
438 
439 private:
440  std::vector<VertexHandle> incident_vertices_;
441  std::vector<VertexHandle>::const_iterator v_iter_;
442 };
443 
444 //===========================================================================
445 
446 class CellCellIter : public BaseIterator<
447  CellHandle,
448  CellHandle> {
449 public:
450  typedef BaseIterator<
451  CellHandle,
453 
454  CellCellIter(const CellHandle& _cIdx, const TopologyKernel* _mesh);
455  CellCellIter& operator=(const CellCellIter& _c) {
456  BaseIter::operator=(_c);
457  adjacent_cells_ = _c.adjacent_cells_;
458  c_iter_ = adjacent_cells_.begin();
459  return *this;
460  }
461 
462  // Post increment/decrement operator
463  CellCellIter operator++(int) {
464  CellCellIter cpy = *this;
465  ++(*this);
466  return cpy;
467  }
468  CellCellIter operator--(int) {
469  CellCellIter cpy = *this;
470  --(*this);
471  return cpy;
472  }
473  CellCellIter operator+(int _n) {
474  CellCellIter cpy = *this;
475  for(int i = 0; i < _n; ++i) {
476  ++cpy;
477  }
478  return cpy;
479  }
480  CellCellIter operator-(int _n) {
481  CellCellIter cpy = *this;
482  for(int i = 0; i < _n; ++i) {
483  --cpy;
484  }
485  return cpy;
486  }
487  CellCellIter& operator+=(int _n) {
488  for(int i = 0; i < _n; ++i) {
489  ++(*this);
490  }
491  return *this;
492  }
493  CellCellIter& operator-=(int _n) {
494  for(int i = 0; i < _n; ++i) {
495  --(*this);
496  }
497  return *this;
498  }
499 
500  CellCellIter& operator++();
501  CellCellIter& operator--();
502 
503 private:
504  std::set<CellHandle> adjacent_cells_;
505  std::set<CellHandle>::const_iterator c_iter_;
506 };
507 
508 //===========================================================================
509 
511  HalfFaceHandle,
512  VertexHandle> {
513 public:
514  typedef BaseIterator<
517 
518  HalfFaceVertexIter(const HalfFaceHandle& _hIdx, const TopologyKernel* _mesh);
519  HalfFaceVertexIter& operator=(const HalfFaceVertexIter& _c) {
520  BaseIter::operator=(_c);
521  vertices_ = _c.vertices_;
522  iter_ = vertices_.begin();
523  return *this;
524  }
525 
526  // Post increment/decrement operator
527  HalfFaceVertexIter operator++(int) {
528  HalfFaceVertexIter cpy = *this;
529  ++(*this);
530  return cpy;
531  }
532  HalfFaceVertexIter operator--(int) {
533  HalfFaceVertexIter cpy = *this;
534  --(*this);
535  return cpy;
536  }
537  HalfFaceVertexIter operator+(int _n) {
538  HalfFaceVertexIter cpy = *this;
539  for(int i = 0; i < _n; ++i) {
540  ++cpy;
541  }
542  return cpy;
543  }
544  HalfFaceVertexIter operator-(int _n) {
545  HalfFaceVertexIter cpy = *this;
546  for(int i = 0; i < _n; ++i) {
547  --cpy;
548  }
549  return cpy;
550  }
551  HalfFaceVertexIter& operator+=(int _n) {
552  for(int i = 0; i < _n; ++i) {
553  ++(*this);
554  }
555  return *this;
556  }
557  HalfFaceVertexIter& operator-=(int _n) {
558  for(int i = 0; i < _n; ++i) {
559  --(*this);
560  }
561  return *this;
562  }
563 
564  HalfFaceVertexIter& operator++();
565  HalfFaceVertexIter& operator--();
566 
567 private:
568  std::vector<VertexHandle> vertices_;
569  std::vector<VertexHandle>::const_iterator iter_;
570 };
571 
572 //===========================================================================
573 
574 class BoundaryHalfFaceHalfFaceIter : public BaseIterator<HalfFaceHandle,
575  HalfFaceHandle> {
576 private:
579 public:
581  const TopologyKernel* _mesh);
583  BaseIter::operator=(_c);
584  neighbor_halffaces_ = _c.neighbor_halffaces_;
585  cur_it_ = neighbor_halffaces_.begin();
586  return *this;
587  }
588 
589  // Post increment/decrement operator
590  BoundaryHalfFaceHalfFaceIter operator++(int) {
591  BoundaryHalfFaceHalfFaceIter cpy = *this;
592  ++(*this);
593  return cpy;
594  }
595  BoundaryHalfFaceHalfFaceIter operator--(int) {
596  BoundaryHalfFaceHalfFaceIter cpy = *this;
597  --(*this);
598  return cpy;
599  }
600  BoundaryHalfFaceHalfFaceIter operator+(int _n) {
601  BoundaryHalfFaceHalfFaceIter cpy = *this;
602  for(int i = 0; i < _n; ++i) {
603  ++cpy;
604  }
605  return cpy;
606  }
607  BoundaryHalfFaceHalfFaceIter operator-(int _n) {
608  BoundaryHalfFaceHalfFaceIter cpy = *this;
609  for(int i = 0; i < _n; ++i) {
610  --cpy;
611  }
612  return cpy;
613  }
614  BoundaryHalfFaceHalfFaceIter& operator+=(int _n) {
615  for(int i = 0; i < _n; ++i) {
616  ++(*this);
617  }
618  return *this;
619  }
620  BoundaryHalfFaceHalfFaceIter& operator-=(int _n) {
621  for(int i = 0; i < _n; ++i) {
622  --(*this);
623  }
624  return *this;
625  }
626 
627  const EdgeHandle& common_edge() const { return *edge_it_; }
628 
629  BoundaryHalfFaceHalfFaceIter& operator++();
630  BoundaryHalfFaceHalfFaceIter& operator--();
631 
632 private:
633  std::vector<HalfFaceHandle> neighbor_halffaces_;
634  std::vector<EdgeHandle> common_edges_;
635  std::vector<HalfFaceHandle>::const_iterator cur_it_;
636  std::vector<EdgeHandle>::const_iterator edge_it_;
637 };
638 
639 //===========================================================================
640 
641 class VertexIter : public BaseIterator<
642  VertexHandle,
643  VertexHandle> {
644 public:
645  typedef BaseIterator<
646  VertexHandle,
648 
649 
650  VertexIter(const TopologyKernel* _mesh, const VertexHandle& _vh = VertexHandle(0));
651 
652  // Post increment/decrement operator
653  VertexIter operator++(int) {
654  VertexIter cpy = *this;
655  ++(*this);
656  return cpy;
657  }
658  VertexIter operator--(int) {
659  VertexIter cpy = *this;
660  --(*this);
661  return cpy;
662  }
663  VertexIter operator+(int _n) {
664  VertexIter cpy = *this;
665  for(int i = 0; i < _n; ++i) {
666  ++cpy;
667  }
668  return cpy;
669  }
670  VertexIter operator-(int _n) {
671  VertexIter cpy = *this;
672  for(int i = 0; i < _n; ++i) {
673  --cpy;
674  }
675  return cpy;
676  }
677  VertexIter& operator+=(int _n) {
678  for(int i = 0; i < _n; ++i) {
679  ++(*this);
680  }
681  return *this;
682  }
683  VertexIter& operator-=(int _n) {
684  for(int i = 0; i < _n; ++i) {
685  --(*this);
686  }
687  return *this;
688  }
689 
690  VertexIter& operator++();
691  VertexIter& operator--();
692 
693 private:
694  int cur_index_;
695 };
696 
697 //===========================================================================
698 
699 class EdgeIter : public BaseIterator<
700  EdgeHandle,
701  EdgeHandle> {
702 public:
703  typedef BaseIterator<
704  EdgeHandle,
706 
707 
708  EdgeIter(const TopologyKernel* _mesh, const EdgeHandle& _eh = EdgeHandle(0));
709 
710  // Post increment/decrement operator
711  EdgeIter operator++(int) {
712  EdgeIter cpy = *this;
713  ++(*this);
714  return cpy;
715  }
716  EdgeIter operator--(int) {
717  EdgeIter cpy = *this;
718  --(*this);
719  return cpy;
720  }
721  EdgeIter operator+(int _n) {
722  EdgeIter cpy = *this;
723  for(int i = 0; i < _n; ++i) {
724  ++cpy;
725  }
726  return cpy;
727  }
728  EdgeIter operator-(int _n) {
729  EdgeIter cpy = *this;
730  for(int i = 0; i < _n; ++i) {
731  --cpy;
732  }
733  return cpy;
734  }
735  EdgeIter& operator+=(int _n) {
736  for(int i = 0; i < _n; ++i) {
737  ++(*this);
738  }
739  return *this;
740  }
741  EdgeIter& operator-=(int _n) {
742  for(int i = 0; i < _n; ++i) {
743  --(*this);
744  }
745  return *this;
746  }
747 
748  EdgeIter& operator++();
749  EdgeIter& operator--();
750 
751 private:
752  int cur_index_;
753 };
754 
755 //===========================================================================
756 
757 class HalfEdgeIter : public BaseIterator<
758  HalfEdgeHandle,
759  HalfEdgeHandle> {
760 public:
761  typedef BaseIterator<
764 
765 
766  HalfEdgeIter(const TopologyKernel* _mesh, const HalfEdgeHandle& _heh = HalfEdgeHandle(0));
767 
768  // Post increment/decrement operator
769  HalfEdgeIter operator++(int) {
770  HalfEdgeIter cpy = *this;
771  ++(*this);
772  return cpy;
773  }
774  HalfEdgeIter operator--(int) {
775  HalfEdgeIter cpy = *this;
776  --(*this);
777  return cpy;
778  }
779  HalfEdgeIter operator+(int _n) {
780  HalfEdgeIter cpy = *this;
781  for(int i = 0; i < _n; ++i) {
782  ++cpy;
783  }
784  return cpy;
785  }
786  HalfEdgeIter operator-(int _n) {
787  HalfEdgeIter cpy = *this;
788  for(int i = 0; i < _n; ++i) {
789  --cpy;
790  }
791  return cpy;
792  }
793  HalfEdgeIter& operator+=(int _n) {
794  for(int i = 0; i < _n; ++i) {
795  ++(*this);
796  }
797  return *this;
798  }
799  HalfEdgeIter& operator-=(int _n) {
800  for(int i = 0; i < _n; ++i) {
801  --(*this);
802  }
803  return *this;
804  }
805 
806  HalfEdgeIter& operator++();
807  HalfEdgeIter& operator--();
808 
809 private:
810  int cur_index_;
811 };
812 
813 //===========================================================================
814 
815 class FaceIter : public BaseIterator<
816  FaceHandle,
817  FaceHandle> {
818 public:
819  typedef BaseIterator<
820  FaceHandle,
822 
823 
824  FaceIter(const TopologyKernel* _mesh, const FaceHandle& _fh = FaceHandle(0));
825 
826  // Post increment/decrement operator
827  FaceIter operator++(int) {
828  FaceIter cpy = *this;
829  ++(*this);
830  return cpy;
831  }
832  FaceIter operator--(int) {
833  FaceIter cpy = *this;
834  --(*this);
835  return cpy;
836  }
837  FaceIter operator+(int _n) {
838  FaceIter cpy = *this;
839  for(int i = 0; i < _n; ++i) {
840  ++cpy;
841  }
842  return cpy;
843  }
844  FaceIter operator-(int _n) {
845  FaceIter cpy = *this;
846  for(int i = 0; i < _n; ++i) {
847  --cpy;
848  }
849  return cpy;
850  }
851  FaceIter& operator+=(int _n) {
852  for(int i = 0; i < _n; ++i) {
853  ++(*this);
854  }
855  return *this;
856  }
857  FaceIter& operator-=(int _n) {
858  for(int i = 0; i < _n; ++i) {
859  --(*this);
860  }
861  return *this;
862  }
863 
864  FaceIter& operator++();
865  FaceIter& operator--();
866 
867 private:
868  int cur_index_;
869 };
870 
871 //===========================================================================
872 
873 class HalfFaceIter : public BaseIterator<
874  HalfFaceHandle,
875  HalfFaceHandle> {
876 public:
877  typedef BaseIterator<
880 
881 
882  HalfFaceIter(const TopologyKernel* _mesh, const HalfFaceHandle& _hfh = HalfFaceHandle(0));
883 
884  // Post increment/decrement operator
885  HalfFaceIter operator++(int) {
886  HalfFaceIter cpy = *this;
887  ++(*this);
888  return cpy;
889  }
890  HalfFaceIter operator--(int) {
891  HalfFaceIter cpy = *this;
892  --(*this);
893  return cpy;
894  }
895  HalfFaceIter operator+(int _n) {
896  HalfFaceIter cpy = *this;
897  for(int i = 0; i < _n; ++i) {
898  ++cpy;
899  }
900  return cpy;
901  }
902  HalfFaceIter operator-(int _n) {
903  HalfFaceIter cpy = *this;
904  for(int i = 0; i < _n; ++i) {
905  --cpy;
906  }
907  return cpy;
908  }
909  HalfFaceIter& operator+=(int _n) {
910  for(int i = 0; i < _n; ++i) {
911  ++(*this);
912  }
913  return *this;
914  }
915  HalfFaceIter& operator-=(int _n) {
916  for(int i = 0; i < _n; ++i) {
917  --(*this);
918  }
919  return *this;
920  }
921 
922  HalfFaceIter& operator++();
923  HalfFaceIter& operator--();
924 
925 private:
926  int cur_index_;
927 };
928 
929 //===========================================================================
930 
931 class CellIter : public BaseIterator<
932  CellHandle,
933  CellHandle> {
934 public:
935  typedef BaseIterator<
936  CellHandle,
938 
939 
940  CellIter(const TopologyKernel* _mesh, const CellHandle& _ch = CellHandle(0));
941 
942  // Post increment/decrement operator
943  CellIter operator++(int) {
944  CellIter cpy = *this;
945  ++(*this);
946  return cpy;
947  }
948  CellIter operator--(int) {
949  CellIter cpy = *this;
950  --(*this);
951  return cpy;
952  }
953  CellIter operator+(int _n) {
954  CellIter cpy = *this;
955  for(int i = 0; i < _n; ++i) {
956  ++cpy;
957  }
958  return cpy;
959  }
960  CellIter operator-(int _n) {
961  CellIter cpy = *this;
962  for(int i = 0; i < _n; ++i) {
963  --cpy;
964  }
965  return cpy;
966  }
967  CellIter& operator+=(int _n) {
968  for(int i = 0; i < _n; ++i) {
969  ++(*this);
970  }
971  return *this;
972  }
973  CellIter& operator-=(int _n) {
974  for(int i = 0; i < _n; ++i) {
975  --(*this);
976  }
977  return *this;
978  }
979 
980  CellIter& operator++();
981  CellIter& operator--();
982 
983 private:
984  int cur_index_;
985 };
986 
987 //===========================================================================
988 
989 class BoundaryFaceIter : public BaseIterator<FaceHandle,FaceHandle> {
990 public:
991  typedef BaseIterator<
992  FaceHandle,
994 
995 
996  BoundaryFaceIter(const TopologyKernel* _mesh);
997 
998  // Post increment/decrement operator
999  BoundaryFaceIter operator++(int) {
1000  BoundaryFaceIter cpy = *this;
1001  ++(*this);
1002  return cpy;
1003  }
1004  BoundaryFaceIter operator--(int) {
1005  BoundaryFaceIter cpy = *this;
1006  --(*this);
1007  return cpy;
1008  }
1009  BoundaryFaceIter operator+(int _n) {
1010  BoundaryFaceIter cpy = *this;
1011  for(int i = 0; i < _n; ++i) {
1012  ++cpy;
1013  }
1014  return cpy;
1015  }
1016  BoundaryFaceIter operator-(int _n) {
1017  BoundaryFaceIter cpy = *this;
1018  for(int i = 0; i < _n; ++i) {
1019  --cpy;
1020  }
1021  return cpy;
1022  }
1023  BoundaryFaceIter& operator+=(int _n) {
1024  for(int i = 0; i < _n; ++i) {
1025  ++(*this);
1026  }
1027  return *this;
1028  }
1029  BoundaryFaceIter& operator-=(int _n) {
1030  for(int i = 0; i < _n; ++i) {
1031  --(*this);
1032  }
1033  return *this;
1034  }
1035 
1036  BoundaryFaceIter& operator++();
1037  BoundaryFaceIter& operator--();
1038 
1039 private:
1040  FaceIter bf_it_;
1041 };
1042 
1043 //===========================================================================
1044 
1045 } // Namespace OpenVolumeMesh
1046 
1047 #endif /* ITERATORS_HH_ */