Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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