OpenMesh

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

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CirculatorsT.hh
1 /*===========================================================================*\
2 * *
3 * OpenMesh *
4 * Copyright (C) 2001-2012 by Computer Graphics Group, RWTH Aachen *
5 * www.openmesh.org *
6 * *
7 *---------------------------------------------------------------------------*
8 * This file is part of OpenMesh. *
9 * *
10 * OpenMesh 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 * OpenMesh 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 OpenMesh. If not, *
31 * see <http://www.gnu.org/licenses/>. *
32 * *
33 \*===========================================================================*/
34
35 /*===========================================================================*\
36 * *
37 * $Revision: 837 $ *
38 * $Date: 2013-06-12 15:14:36 +0200 (Mi, 12. Jun 2013) $ *
39 * *
40 \*===========================================================================*/
41
42 #ifndef OPENMESH_CIRCULATORS_HH
43 #define OPENMESH_CIRCULATORS_HH
44 //=============================================================================
45 //
46 // Vertex and Face circulators for PolyMesh/TriMesh
47 //
48 //=============================================================================
49
50
51
52 //== INCLUDES =================================================================
53
54 #include <OpenMesh/Core/System/config.h>
55 #include <cassert>
56 #include <cstddef>
57
58
59 //== NAMESPACES ===============================================================
60
61 namespace OpenMesh {
62 namespace Iterators {
63
64
65 //== FORWARD DECLARATIONS =====================================================
66
67
68 template <class Mesh> class VertexVertexIterT;
69 template <class Mesh> class VertexIHalfedgeIterT;
70 template <class Mesh> class VertexOHalfedgeIterT;
71 template <class Mesh> class VertexEdgeIterT;
72 template <class Mesh> class VertexFaceIterT;
73
74 template <class Mesh> class ConstVertexVertexIterT;
75 template <class Mesh> class ConstVertexIHalfedgeIterT;
76 template <class Mesh> class ConstVertexOHalfedgeIterT;
77 template <class Mesh> class ConstVertexEdgeIterT;
78 template <class Mesh> class ConstVertexFaceIterT;
79
80 template <class Mesh> class FaceVertexIterT;
81 template <class Mesh> class FaceHalfedgeIterT;
82 template <class Mesh> class FaceEdgeIterT;
83 template <class Mesh> class FaceFaceIterT;
84
85 template <class Mesh> class ConstFaceVertexIterT;
86 template <class Mesh> class ConstFaceHalfedgeIterT;
87 template <class Mesh> class ConstFaceEdgeIterT;
88 template <class Mesh> class ConstFaceFaceIterT;
89
90
91
92 //== CLASS DEFINITION =========================================================
93
94
99 template <class Mesh>
100 class VertexVertexIterT
101 {
102 public:
103
104
105 //--- Typedefs ---
106
107 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
108
109 typedef typename Mesh::Vertex value_type;
110 typedef typename Mesh::VertexHandle value_handle;
111
112 #if 0
113 typedef std::bidirectional_iterator_tag iterator_category;
114 typedef std::ptrdiff_t difference_type;
115 typedef const Mesh& mesh_ref;
116 typedef const Mesh* mesh_ptr;
117 typedef const typename Mesh::Vertex& reference;
118 typedef const typename Mesh::Vertex* pointer;
119 #else
120 typedef std::bidirectional_iterator_tag iterator_category;
121 typedef std::ptrdiff_t difference_type;
122 typedef Mesh& mesh_ref;
123 typedef Mesh* mesh_ptr;
124 typedef typename Mesh::Vertex& reference;
125 typedef typename Mesh::Vertex* pointer;
126 #endif
127
128
129
131 VertexVertexIterT() : mesh_(0), lap_counter_(0) {}
132
133
135 VertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
136 mesh_(&_mesh),
137 start_(_mesh.halfedge_handle(_start)),
138 heh_(start_),
139 lap_counter_(_end)
140 { ; }
141
142
144 VertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
145 mesh_(&_mesh),
146 start_(_heh),
147 heh_(_heh),
148 lap_counter_(_end)
149 { ; }
150
151
153 VertexVertexIterT(const VertexVertexIterT& _rhs) :
154 mesh_(_rhs.mesh_),
155 start_(_rhs.start_),
156 heh_(_rhs.heh_),
157 lap_counter_(_rhs.lap_counter_)
158 { ; }
159
160
162 VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
163 {
164 mesh_ = _rhs.mesh_;
165 start_ = _rhs.start_;
166 heh_ = _rhs.heh_;
167 lap_counter_ = _rhs.lap_counter_;
168 return *this;
169 }
170
171
172 #if 0
173
174 VertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :
175 mesh_(_rhs.mesh_),
176 start_(_rhs.start_),
177 heh_(_rhs.heh_),
178 lap_counter_(_rhs.lap_counter_)
179 { ; }
180
181
183 VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
184 {
185 mesh_ = _rhs.mesh_;
186 start_ = _rhs.start_;
187 heh_ = _rhs.heh_;
188 lap_counter_ = _rhs.lap_counter_;
189 return *this;
190 }
191 #else
192 friend class ConstVertexVertexIterT<Mesh>;
193 #endif
194
195
197 bool operator==(const VertexVertexIterT& _rhs) const {
198 return ((mesh_ == _rhs.mesh_) &&
199 (start_ == _rhs.start_) &&
200 (heh_ == _rhs.heh_) &&
201 (lap_counter_ == _rhs.lap_counter_));
202 }
203
204
206 bool operator!=(const VertexVertexIterT& _rhs) const {
207 return !operator==(_rhs);
208 }
209
210
212 VertexVertexIterT& operator++() {
213 assert(mesh_);
214 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
215 if(heh_ == start_) lap_counter_++;
216 return *this;
217 }
218
219
221 VertexVertexIterT& operator--() {
222 assert(mesh_);
223 if(heh_ == start_) lap_counter_--;
224 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
225 return *this;
226 }
227
228
233 HalfedgeHandle current_halfedge_handle() const {
234 return heh_;
235 }
236
237
239 typename Mesh::VertexHandle handle() const {
240 assert(mesh_);
241 return mesh_->to_vertex_handle(heh_);
242 }
243
244
246 operator typename Mesh::VertexHandle() const {
247 assert(mesh_);
248 return mesh_->to_vertex_handle(heh_);
249 }
250
251
253 reference operator*() const {
254 assert(mesh_);
255 return mesh_->deref(handle());
256 }
257
258
260 pointer operator->() const {
261 assert(mesh_);
262 return &mesh_->deref(handle());
263 }
264
265
272 operator bool() const {
273 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
274 }
275
276
277 protected:
278
279 mesh_ptr mesh_;
280 HalfedgeHandle start_, heh_;
281 int lap_counter_;
282 };
283
284
285
286 //== CLASS DEFINITION =========================================================
287
288
293 template <class Mesh>
294 class ConstVertexVertexIterT
295 {
296 public:
297
298
299 //--- Typedefs ---
300
301 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
302
303 typedef typename Mesh::Vertex value_type;
304 typedef typename Mesh::VertexHandle value_handle;
305
306 #if 1
307 typedef std::bidirectional_iterator_tag iterator_category;
308 typedef std::ptrdiff_t difference_type;
309 typedef const Mesh& mesh_ref;
310 typedef const Mesh* mesh_ptr;
311 typedef const typename Mesh::Vertex& reference;
312 typedef const typename Mesh::Vertex* pointer;
313 #else
314 typedef std::bidirectional_iterator_tag iterator_category;
315 typedef std::ptrdiff_t difference_type;
316 typedef Mesh& mesh_ref;
317 typedef Mesh* mesh_ptr;
318 typedef typename Mesh::Vertex& reference;
319 typedef typename Mesh::Vertex* pointer;
320 #endif
321
322
323
325 ConstVertexVertexIterT() : mesh_(0), lap_counter_(0) {}
326
327
329 ConstVertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
330 mesh_(&_mesh),
331 start_(_mesh.halfedge_handle(_start)),
332 heh_(start_),
333 lap_counter_(_end)
334 { ; }
335
336
338 ConstVertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
339 mesh_(&_mesh),
340 start_(_heh),
341 heh_(_heh),
342 lap_counter_(_end)
343 { ; }
344
345
347 ConstVertexVertexIterT(const ConstVertexVertexIterT& _rhs) :
348 mesh_(_rhs.mesh_),
349 start_(_rhs.start_),
350 heh_(_rhs.heh_),
351 lap_counter_(_rhs.lap_counter_)
352 { ; }
353
354
356 ConstVertexVertexIterT& operator=(const ConstVertexVertexIterT<Mesh>& _rhs)
357 {
358 mesh_ = _rhs.mesh_;
359 start_ = _rhs.start_;
360 heh_ = _rhs.heh_;
361 lap_counter_ = _rhs.lap_counter_;
362 return *this;
363 }
364
365
366 #if 1
367
368 ConstVertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :
369 mesh_(_rhs.mesh_),
370 start_(_rhs.start_),
371 heh_(_rhs.heh_),
372 lap_counter_(_rhs.lap_counter_)
373 { ; }
374
375
377 ConstVertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
378 {
379 mesh_ = _rhs.mesh_;
380 start_ = _rhs.start_;
381 heh_ = _rhs.heh_;
382 lap_counter_ = _rhs.lap_counter_;
383 return *this;
384 }
385 #else
386 friend class ConstVertexVertexIterT<Mesh>;
387 #endif
388
389
391 bool operator==(const ConstVertexVertexIterT& _rhs) const {
392 return ((mesh_ == _rhs.mesh_) &&
393 (start_ == _rhs.start_) &&
394 (heh_ == _rhs.heh_) &&
395 (lap_counter_ == _rhs.lap_counter_));
396 }
397
398
400 bool operator!=(const ConstVertexVertexIterT& _rhs) const {
401 return !operator==(_rhs);
402 }
403
404
406 ConstVertexVertexIterT& operator++() {
407 assert(mesh_);
408 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
409 if(heh_ == start_) lap_counter_++;
410 return *this;
411 }
412
413
415 ConstVertexVertexIterT& operator--() {
416 assert(mesh_);
417 if(heh_ == start_) lap_counter_--;
418 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
419 return *this;
420 }
421
422
427 HalfedgeHandle current_halfedge_handle() const {
428 return heh_;
429 }
430
431
433 typename Mesh::VertexHandle handle() const {
434 assert(mesh_);
435 return mesh_->to_vertex_handle(heh_);
436 }
437
438
440 operator typename Mesh::VertexHandle() const {
441 assert(mesh_);
442 return mesh_->to_vertex_handle(heh_);
443 }
444
445
447 reference operator*() const {
448 assert(mesh_);
449 return mesh_->deref(handle());
450 }
451
452
454 pointer operator->() const {
455 assert(mesh_);
456 return &mesh_->deref(handle());
457 }
458
459
466 operator bool() const {
467 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
468 }
469
470
471 protected:
472
473 mesh_ptr mesh_;
474 HalfedgeHandle start_, heh_;
475 int lap_counter_;
476 };
477
478
479
480 //== CLASS DEFINITION =========================================================
481
482
487 template <class Mesh>
488 class VertexOHalfedgeIterT
489 {
490 public:
491
492
493 //--- Typedefs ---
494
495 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
496
497 typedef typename Mesh::Halfedge value_type;
498 typedef typename Mesh::HalfedgeHandle value_handle;
499
500 #if 0
501 typedef std::bidirectional_iterator_tag iterator_category;
502 typedef std::ptrdiff_t difference_type;
503 typedef const Mesh& mesh_ref;
504 typedef const Mesh* mesh_ptr;
505 typedef const typename Mesh::Halfedge& reference;
506 typedef const typename Mesh::Halfedge* pointer;
507 #else
508 typedef std::bidirectional_iterator_tag iterator_category;
509 typedef std::ptrdiff_t difference_type;
510 typedef Mesh& mesh_ref;
511 typedef Mesh* mesh_ptr;
512 typedef typename Mesh::Halfedge& reference;
513 typedef typename Mesh::Halfedge* pointer;
514 #endif
515
516
517
519 VertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
520
521
523 VertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
524 mesh_(&_mesh),
525 start_(_mesh.halfedge_handle(_start)),
526 heh_(start_),
527 lap_counter_(_end)
528 { ; }
529
530
532 VertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
533 mesh_(&_mesh),
534 start_(_heh),
535 heh_(_heh),
536 lap_counter_(_end)
537 { ; }
538
539
541 VertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) :
542 mesh_(_rhs.mesh_),
543 start_(_rhs.start_),
544 heh_(_rhs.heh_),
545 lap_counter_(_rhs.lap_counter_)
546 { ; }
547
548
550 VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
551 {
552 mesh_ = _rhs.mesh_;
553 start_ = _rhs.start_;
554 heh_ = _rhs.heh_;
555 lap_counter_ = _rhs.lap_counter_;
556 return *this;
557 }
558
559
560 #if 0
561
562 VertexOHalfedgeIterT(const VertexOHalfedgeIterT<Mesh>& _rhs) :
563 mesh_(_rhs.mesh_),
564 start_(_rhs.start_),
565 heh_(_rhs.heh_),
566 lap_counter_(_rhs.lap_counter_)
567 { ; }
568
569
571 VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
572 {
573 mesh_ = _rhs.mesh_;
574 start_ = _rhs.start_;
575 heh_ = _rhs.heh_;
576 lap_counter_ = _rhs.lap_counter_;
577 return *this;
578 }
579 #else
580 friend class ConstVertexOHalfedgeIterT<Mesh>;
581 #endif
582
583
585 bool operator==(const VertexOHalfedgeIterT& _rhs) const {
586 return ((mesh_ == _rhs.mesh_) &&
587 (start_ == _rhs.start_) &&
588 (heh_ == _rhs.heh_) &&
589 (lap_counter_ == _rhs.lap_counter_));
590 }
591
592
594 bool operator!=(const VertexOHalfedgeIterT& _rhs) const {
595 return !operator==(_rhs);
596 }
597
598
600 VertexOHalfedgeIterT& operator++() {
601 assert(mesh_);
602 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
603 if(heh_ == start_) lap_counter_++;
604 return *this;
605 }
606
607
609 VertexOHalfedgeIterT& operator--() {
610 assert(mesh_);
611 if(heh_ == start_) lap_counter_--;
612 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
613 return *this;
614 }
615
616
621 HalfedgeHandle current_halfedge_handle() const {
622 return heh_;
623 }
624
625
627 typename Mesh::HalfedgeHandle handle() const {
628 assert(mesh_);
629 return heh_;
630 }
631
632
634 operator typename Mesh::HalfedgeHandle() const {
635 assert(mesh_);
636 return heh_;
637 }
638
639
641 reference operator*() const {
642 assert(mesh_);
643 return mesh_->deref(handle());
644 }
645
646
648 pointer operator->() const {
649 assert(mesh_);
650 return &mesh_->deref(handle());
651 }
652
653
660 operator bool() const {
661 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
662 }
663
664
665 protected:
666
667 mesh_ptr mesh_;
668 HalfedgeHandle start_, heh_;
669 int lap_counter_;
670 };
671
672
673
674 //== CLASS DEFINITION =========================================================
675
676
681 template <class Mesh>
682 class ConstVertexOHalfedgeIterT
683 {
684 public:
685
686
687 //--- Typedefs ---
688
689 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
690
691 typedef typename Mesh::Halfedge value_type;
692 typedef typename Mesh::HalfedgeHandle value_handle;
693
694 #if 1
695 typedef std::bidirectional_iterator_tag iterator_category;
696 typedef std::ptrdiff_t difference_type;
697 typedef const Mesh& mesh_ref;
698 typedef const Mesh* mesh_ptr;
699 typedef const typename Mesh::Halfedge& reference;
700 typedef const typename Mesh::Halfedge* pointer;
701 #else
702 typedef std::bidirectional_iterator_tag iterator_category;
703 typedef std::ptrdiff_t difference_type;
704 typedef Mesh& mesh_ref;
705 typedef Mesh* mesh_ptr;
706 typedef typename Mesh::Halfedge& reference;
707 typedef typename Mesh::Halfedge* pointer;
708 #endif
709
710
711
713 ConstVertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
714
715
717 ConstVertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
718 mesh_(&_mesh),
719 start_(_mesh.halfedge_handle(_start)),
720 heh_(start_),
721 lap_counter_(_end)
722 { ; }
723
724
726 ConstVertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
727 mesh_(&_mesh),
728 start_(_heh),
729 heh_(_heh),
730 lap_counter_(_end)
731 { ; }
732
733
735 ConstVertexOHalfedgeIterT(const ConstVertexOHalfedgeIterT& _rhs) :
736 mesh_(_rhs.mesh_),
737 start_(_rhs.start_),
738 heh_(_rhs.heh_),
739 lap_counter_(_rhs.lap_counter_)
740 { ; }
741
742
744 ConstVertexOHalfedgeIterT& operator=(const ConstVertexOHalfedgeIterT<Mesh>& _rhs)
745 {
746 mesh_ = _rhs.mesh_;
747 start_ = _rhs.start_;
748 heh_ = _rhs.heh_;
749 lap_counter_ = _rhs.lap_counter_;
750 return *this;
751 }
752
753
754 #if 1
755
756 ConstVertexOHalfedgeIterT(const VertexOHalfedgeIterT<Mesh>& _rhs) :
757 mesh_(_rhs.mesh_),
758 start_(_rhs.start_),
759 heh_(_rhs.heh_),
760 lap_counter_(_rhs.lap_counter_)
761 { ; }
762
763
765 ConstVertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
766 {
767 mesh_ = _rhs.mesh_;
768 start_ = _rhs.start_;
769 heh_ = _rhs.heh_;
770 lap_counter_ = _rhs.lap_counter_;
771 return *this;
772 }
773 #else
774 friend class ConstVertexOHalfedgeIterT<Mesh>;
775 #endif
776
777
779 bool operator==(const ConstVertexOHalfedgeIterT& _rhs) const {
780 return ((mesh_ == _rhs.mesh_) &&
781 (start_ == _rhs.start_) &&
782 (heh_ == _rhs.heh_) &&
783 (lap_counter_ == _rhs.lap_counter_));
784 }
785
786
788 bool operator!=(const ConstVertexOHalfedgeIterT& _rhs) const {
789 return !operator==(_rhs);
790 }
791
792
794 ConstVertexOHalfedgeIterT& operator++() {
795 assert(mesh_);
796 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
797 if(heh_ == start_) lap_counter_++;
798 return *this;
799 }
800
801
803 ConstVertexOHalfedgeIterT& operator--() {
804 assert(mesh_);
805 if(heh_ == start_) lap_counter_--;
806 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
807 return *this;
808 }
809
810
815 HalfedgeHandle current_halfedge_handle() const {
816 return heh_;
817 }
818
819
821 typename Mesh::HalfedgeHandle handle() const {
822 assert(mesh_);
823 return heh_;
824 }
825
826
828 operator typename Mesh::HalfedgeHandle() const {
829 assert(mesh_);
830 return heh_;
831 }
832
833
835 reference operator*() const {
836 assert(mesh_);
837 return mesh_->deref(handle());
838 }
839
840
842 pointer operator->() const {
843 assert(mesh_);
844 return &mesh_->deref(handle());
845 }
846
847
854 operator bool() const {
855 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
856 }
857
858
859 protected:
860
861 mesh_ptr mesh_;
862 HalfedgeHandle start_, heh_;
863 int lap_counter_;
864 };
865
866
867
868 //== CLASS DEFINITION =========================================================
869
870
875 template <class Mesh>
876 class VertexIHalfedgeIterT
877 {
878 public:
879
880
881 //--- Typedefs ---
882
883 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
884
885 typedef typename Mesh::Halfedge value_type;
886 typedef typename Mesh::HalfedgeHandle value_handle;
887
888 #if 0
889 typedef std::bidirectional_iterator_tag iterator_category;
890 typedef std::ptrdiff_t difference_type;
891 typedef const Mesh& mesh_ref;
892 typedef const Mesh* mesh_ptr;
893 typedef const typename Mesh::Halfedge& reference;
894 typedef const typename Mesh::Halfedge* pointer;
895 #else
896 typedef std::bidirectional_iterator_tag iterator_category;
897 typedef std::ptrdiff_t difference_type;
898 typedef Mesh& mesh_ref;
899 typedef Mesh* mesh_ptr;
900 typedef typename Mesh::Halfedge& reference;
901 typedef typename Mesh::Halfedge* pointer;
902 #endif
903
904
905
907 VertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
908
909
911 VertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
912 mesh_(&_mesh),
913 start_(_mesh.halfedge_handle(_start)),
914 heh_(start_),
915 lap_counter_(_end)
916 { ; }
917
918
920 VertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
921 mesh_(&_mesh),
922 start_(_heh),
923 heh_(_heh),
924 lap_counter_(_end)
925 { ; }
926
927
929 VertexIHalfedgeIterT(const VertexIHalfedgeIterT& _rhs) :
930 mesh_(_rhs.mesh_),
931 start_(_rhs.start_),
932 heh_(_rhs.heh_),
933 lap_counter_(_rhs.lap_counter_)
934 { ; }
935
936
938 VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
939 {
940 mesh_ = _rhs.mesh_;
941 start_ = _rhs.start_;
942 heh_ = _rhs.heh_;
943 lap_counter_ = _rhs.lap_counter_;
944 return *this;
945 }
946
947
948 #if 0
949
950 VertexIHalfedgeIterT(const VertexIHalfedgeIterT<Mesh>& _rhs) :
951 mesh_(_rhs.mesh_),
952 start_(_rhs.start_),
953 heh_(_rhs.heh_),
954 lap_counter_(_rhs.lap_counter_)
955 { ; }
956
957
959 VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
960 {
961 mesh_ = _rhs.mesh_;
962 start_ = _rhs.start_;
963 heh_ = _rhs.heh_;
964 lap_counter_ = _rhs.lap_counter_;
965 return *this;
966 }
967 #else
968 friend class ConstVertexIHalfedgeIterT<Mesh>;
969 #endif
970
971
973 bool operator==(const VertexIHalfedgeIterT& _rhs) const {
974 return ((mesh_ == _rhs.mesh_) &&
975 (start_ == _rhs.start_) &&
976 (heh_ == _rhs.heh_) &&
977 (lap_counter_ == _rhs.lap_counter_));
978 }
979
980
982 bool operator!=(const VertexIHalfedgeIterT& _rhs) const {
983 return !operator==(_rhs);
984 }
985
986
988 VertexIHalfedgeIterT& operator++() {
989 assert(mesh_);
990 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
991 if(heh_ == start_) lap_counter_++;
992 return *this;
993 }
994
995
997 VertexIHalfedgeIterT& operator--() {
998 assert(mesh_);
999 if(heh_ == start_) lap_counter_--;
1000 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
1001 return *this;
1002 }
1003
1004
1009 HalfedgeHandle current_halfedge_handle() const {
1010 return heh_;
1011 }
1012
1013
1015 typename Mesh::HalfedgeHandle handle() const {
1016 assert(mesh_);
1017 return mesh_->opposite_halfedge_handle(heh_);
1018 }
1019
1020
1022 operator typename Mesh::HalfedgeHandle() const {
1023 assert(mesh_);
1024 return mesh_->opposite_halfedge_handle(heh_);
1025 }
1026
1027
1029 reference operator*() const {
1030 assert(mesh_);
1031 return mesh_->deref(handle());
1032 }
1033
1034
1036 pointer operator->() const {
1037 assert(mesh_);
1038 return &mesh_->deref(handle());
1039 }
1040
1041
1048 operator bool() const {
1049 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
1050 }
1051
1052
1053 protected:
1054
1055 mesh_ptr mesh_;
1056 HalfedgeHandle start_, heh_;
1057 int lap_counter_;
1058 };
1059
1060
1061
1062 //== CLASS DEFINITION =========================================================
1063
1064
1069 template <class Mesh>
1070 class ConstVertexIHalfedgeIterT
1071 {
1072 public:
1073
1074
1075 //--- Typedefs ---
1076
1077 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
1078
1079 typedef typename Mesh::Halfedge value_type;
1080 typedef typename Mesh::HalfedgeHandle value_handle;
1081
1082 #if 1
1083 typedef std::bidirectional_iterator_tag iterator_category;
1084 typedef std::ptrdiff_t difference_type;
1085 typedef const Mesh& mesh_ref;
1086 typedef const Mesh* mesh_ptr;
1087 typedef const typename Mesh::Halfedge& reference;
1088 typedef const typename Mesh::Halfedge* pointer;
1089 #else
1090 typedef std::bidirectional_iterator_tag iterator_category;
1091 typedef std::ptrdiff_t difference_type;
1092 typedef Mesh& mesh_ref;
1093 typedef Mesh* mesh_ptr;
1094 typedef typename Mesh::Halfedge& reference;
1095 typedef typename Mesh::Halfedge* pointer;
1096 #endif
1097
1098
1099
1101 ConstVertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
1102
1103
1105 ConstVertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
1106 mesh_(&_mesh),
1107 start_(_mesh.halfedge_handle(_start)),
1108 heh_(start_),
1109 lap_counter_(_end)
1110 { ; }
1111
1112
1114 ConstVertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
1115 mesh_(&_mesh),
1116 start_(_heh),
1117 heh_(_heh),
1118 lap_counter_(_end)
1119 { ; }
1120
1121
1123 ConstVertexIHalfedgeIterT(const ConstVertexIHalfedgeIterT& _rhs) :
1124 mesh_(_rhs.mesh_),
1125 start_(_rhs.start_),
1126 heh_(_rhs.heh_),
1127 lap_counter_(_rhs.lap_counter_)
1128 { ; }
1129
1130
1132 ConstVertexIHalfedgeIterT& operator=(const ConstVertexIHalfedgeIterT<Mesh>& _rhs)
1133 {
1134 mesh_ = _rhs.mesh_;
1135 start_ = _rhs.start_;
1136 heh_ = _rhs.heh_;
1137 lap_counter_ = _rhs.lap_counter_;
1138 return *this;
1139 }
1140
1141
1142 #if 1
1143
1144 ConstVertexIHalfedgeIterT(const VertexIHalfedgeIterT<Mesh>& _rhs) :
1145 mesh_(_rhs.mesh_),
1146 start_(_rhs.start_),
1147 heh_(_rhs.heh_),
1148 lap_counter_(_rhs.lap_counter_)
1149 { ; }
1150
1151
1153 ConstVertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
1154 {
1155 mesh_ = _rhs.mesh_;
1156 start_ = _rhs.start_;
1157 heh_ = _rhs.heh_;
1158 lap_counter_ = _rhs.lap_counter_;
1159 return *this;
1160 }
1161 #else
1162 friend class ConstVertexIHalfedgeIterT<Mesh>;
1163 #endif
1164
1165
1167 bool operator==(const ConstVertexIHalfedgeIterT& _rhs) const {
1168 return ((mesh_ == _rhs.mesh_) &&
1169 (start_ == _rhs.start_) &&
1170 (heh_ == _rhs.heh_) &&
1171 (lap_counter_ == _rhs.lap_counter_));
1172 }
1173
1174
1176 bool operator!=(const ConstVertexIHalfedgeIterT& _rhs) const {
1177 return !operator==(_rhs);
1178 }
1179
1180
1182 ConstVertexIHalfedgeIterT& operator++() {
1183 assert(mesh_);
1184 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
1185 if(heh_ == start_) lap_counter_++;
1186 return *this;
1187 }
1188
1189
1191 ConstVertexIHalfedgeIterT& operator--() {
1192 assert(mesh_);
1193 if(heh_ == start_) lap_counter_--;
1194 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
1195 return *this;
1196 }
1197
1198
1203 HalfedgeHandle current_halfedge_handle() const {
1204 return heh_;
1205 }
1206
1207
1209 typename Mesh::HalfedgeHandle handle() const {
1210 assert(mesh_);
1211 return mesh_->opposite_halfedge_handle(heh_);
1212 }
1213
1214
1216 operator typename Mesh::HalfedgeHandle() const {
1217 assert(mesh_);
1218 return mesh_->opposite_halfedge_handle(heh_);
1219 }
1220
1221
1223 reference operator*() const {
1224 assert(mesh_);
1225 return mesh_->deref(handle());
1226 }
1227
1228
1230 pointer operator->() const {
1231 assert(mesh_);
1232 return &mesh_->deref(handle());
1233 }
1234
1235
1242 operator bool() const {
1243 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
1244 }
1245
1246
1247 protected:
1248
1249 mesh_ptr mesh_;
1250 HalfedgeHandle start_, heh_;
1251 int lap_counter_;
1252 };
1253
1254
1255
1256 //== CLASS DEFINITION =========================================================
1257
1258
1263 template <class Mesh>
1264 class VertexEdgeIterT
1265 {
1266 public:
1267
1268
1269 //--- Typedefs ---
1270
1271 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
1272
1273 typedef typename Mesh::Edge value_type;
1274 typedef typename Mesh::EdgeHandle value_handle;
1275
1276 #if 0
1277 typedef std::bidirectional_iterator_tag iterator_category;
1278 typedef std::ptrdiff_t difference_type;
1279 typedef const Mesh& mesh_ref;
1280 typedef const Mesh* mesh_ptr;
1281 typedef const typename Mesh::Edge& reference;
1282 typedef const typename Mesh::Edge* pointer;
1283 #else
1284 typedef std::bidirectional_iterator_tag iterator_category;
1285 typedef std::ptrdiff_t difference_type;
1286 typedef Mesh& mesh_ref;
1287 typedef Mesh* mesh_ptr;
1288 typedef typename Mesh::Edge& reference;
1289 typedef typename Mesh::Edge* pointer;
1290 #endif
1291
1292
1293
1295 VertexEdgeIterT() : mesh_(0), lap_counter_(false) {}
1296
1297
1299 VertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
1300 mesh_(&_mesh),
1301 start_(_mesh.halfedge_handle(_start)),
1302 heh_(start_),
1303 lap_counter_(_end)
1304 { ; }
1305
1306
1308 VertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
1309 mesh_(&_mesh),
1310 start_(_heh),
1311 heh_(_heh),
1312 lap_counter_(_end)
1313 { ; }
1314
1315
1317 VertexEdgeIterT(const VertexEdgeIterT& _rhs) :
1318 mesh_(_rhs.mesh_),
1319 start_(_rhs.start_),
1320 heh_(_rhs.heh_),
1321 lap_counter_(_rhs.lap_counter_)
1322 { ; }
1323
1324
1326 VertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
1327 {
1328 mesh_ = _rhs.mesh_;
1329 start_ = _rhs.start_;
1330 heh_ = _rhs.heh_;
1331 lap_counter_ = _rhs.lap_counter_;
1332 return *this;
1333 }
1334
1335
1336 #if 0
1337
1338 VertexEdgeIterT(const VertexEdgeIterT<Mesh>& _rhs) :
1339 mesh_(_rhs.mesh_),
1340 start_(_rhs.start_),
1341 heh_(_rhs.heh_),
1342 lap_counter_(_rhs.lap_counter_)
1343 { ; }
1344
1345
1347 VertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
1348 {
1349 mesh_ = _rhs.mesh_;
1350 start_ = _rhs.start_;
1351 heh_ = _rhs.heh_;
1352 lap_counter_ = _rhs.lap_counter_;
1353 return *this;
1354 }
1355 #else
1356 friend class ConstVertexEdgeIterT<Mesh>;
1357 #endif
1358
1359
1361 bool operator==(const VertexEdgeIterT& _rhs) const {
1362 return ((mesh_ == _rhs.mesh_) &&
1363 (start_ == _rhs.start_) &&
1364 (heh_ == _rhs.heh_) &&
1365 (lap_counter_ == _rhs.lap_counter_));
1366 }
1367
1368
1370 bool operator!=(const VertexEdgeIterT& _rhs) const {
1371 return !operator==(_rhs);
1372 }
1373
1374
1376 VertexEdgeIterT& operator++() {
1377 assert(mesh_);
1378 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
1379 if(heh_ == start_) lap_counter_++;
1380 return *this;
1381 }
1382
1383
1385 VertexEdgeIterT& operator--() {
1386 assert(mesh_);
1387 if(heh_ == start_) lap_counter_--;
1388 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
1389 return *this;
1390 }
1391
1392
1397 HalfedgeHandle current_halfedge_handle() const {
1398 return heh_;
1399 }
1400
1401
1403 typename Mesh::EdgeHandle handle() const {
1404 assert(mesh_);
1405 return mesh_->edge_handle(heh_);
1406 }
1407
1408
1410 operator typename Mesh::EdgeHandle() const {
1411 assert(mesh_);
1412 return mesh_->edge_handle(heh_);
1413 }
1414
1415
1417 reference operator*() const {
1418 assert(mesh_);
1419 return mesh_->deref(handle());
1420 }
1421
1422
1424 pointer operator->() const {
1425 assert(mesh_);
1426 return &mesh_->deref(handle());
1427 }
1428
1429
1436 operator bool() const {
1437 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
1438 }
1439
1440
1441 protected:
1442
1443 mesh_ptr mesh_;
1444 HalfedgeHandle start_, heh_;
1445 int lap_counter_;
1446 };
1447
1448
1449
1450 //== CLASS DEFINITION =========================================================
1451
1452
1457 template <class Mesh>
1458 class ConstVertexEdgeIterT
1459 {
1460 public:
1461
1462
1463 //--- Typedefs ---
1464
1465 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
1466
1467 typedef typename Mesh::Edge value_type;
1468 typedef typename Mesh::EdgeHandle value_handle;
1469
1470 #if 1
1471 typedef std::bidirectional_iterator_tag iterator_category;
1472 typedef std::ptrdiff_t difference_type;
1473 typedef const Mesh& mesh_ref;
1474 typedef const Mesh* mesh_ptr;
1475 typedef const typename Mesh::Edge& reference;
1476 typedef const typename Mesh::Edge* pointer;
1477 #else
1478 typedef std::bidirectional_iterator_tag iterator_category;
1479 typedef std::ptrdiff_t difference_type;
1480 typedef Mesh& mesh_ref;
1481 typedef Mesh* mesh_ptr;
1482 typedef typename Mesh::Edge& reference;
1483 typedef typename Mesh::Edge* pointer;
1484 #endif
1485
1486
1487
1489 ConstVertexEdgeIterT() : mesh_(0), lap_counter_(false) {}
1490
1491
1493 ConstVertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
1494 mesh_(&_mesh),
1495 start_(_mesh.halfedge_handle(_start)),
1496 heh_(start_),
1497 lap_counter_(_end)
1498 { ; }
1499
1500
1502 ConstVertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
1503 mesh_(&_mesh),
1504 start_(_heh),
1505 heh_(_heh),
1506 lap_counter_(_end)
1507 { ; }
1508
1509
1511 ConstVertexEdgeIterT(const ConstVertexEdgeIterT& _rhs) :
1512 mesh_(_rhs.mesh_),
1513 start_(_rhs.start_),
1514 heh_(_rhs.heh_),
1515 lap_counter_(_rhs.lap_counter_)
1516 { ; }
1517
1518
1520 ConstVertexEdgeIterT& operator=(const ConstVertexEdgeIterT<Mesh>& _rhs)
1521 {
1522 mesh_ = _rhs.mesh_;
1523 start_ = _rhs.start_;
1524 heh_ = _rhs.heh_;
1525 lap_counter_ = _rhs.lap_counter_;
1526 return *this;
1527 }
1528
1529
1530 #if 1
1531
1532 ConstVertexEdgeIterT(const VertexEdgeIterT<Mesh>& _rhs) :
1533 mesh_(_rhs.mesh_),
1534 start_(_rhs.start_),
1535 heh_(_rhs.heh_),
1536 lap_counter_(_rhs.lap_counter_)
1537 { ; }
1538
1539
1541 ConstVertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
1542 {
1543 mesh_ = _rhs.mesh_;
1544 start_ = _rhs.start_;
1545 heh_ = _rhs.heh_;
1546 lap_counter_ = _rhs.lap_counter_;
1547 return *this;
1548 }
1549 #else
1550 friend class ConstVertexEdgeIterT<Mesh>;
1551 #endif
1552
1553
1555 bool operator==(const ConstVertexEdgeIterT& _rhs) const {
1556 return ((mesh_ == _rhs.mesh_) &&
1557 (start_ == _rhs.start_) &&
1558 (heh_ == _rhs.heh_) &&
1559 (lap_counter_ == _rhs.lap_counter_));
1560 }
1561
1562
1564 bool operator!=(const ConstVertexEdgeIterT& _rhs) const {
1565 return !operator==(_rhs);
1566 }
1567
1568
1570 ConstVertexEdgeIterT& operator++() {
1571 assert(mesh_);
1572 heh_=mesh_->cw_rotated_halfedge_handle(heh_);
1573 if(heh_ == start_) lap_counter_++;
1574 return *this;
1575 }
1576
1577
1579 ConstVertexEdgeIterT& operator--() {
1580 assert(mesh_);
1581 if(heh_ == start_) lap_counter_--;
1582 heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
1583 return *this;
1584 }
1585
1586
1591 HalfedgeHandle current_halfedge_handle() const {
1592 return heh_;
1593 }
1594
1595
1597 typename Mesh::EdgeHandle handle() const {
1598 assert(mesh_);
1599 return mesh_->edge_handle(heh_);
1600 }
1601
1602
1604 operator typename Mesh::EdgeHandle() const {
1605 assert(mesh_);
1606 return mesh_->edge_handle(heh_);
1607 }
1608
1609
1611 reference operator*() const {
1612 assert(mesh_);
1613 return mesh_->deref(handle());
1614 }
1615
1616
1618 pointer operator->() const {
1619 assert(mesh_);
1620 return &mesh_->deref(handle());
1621 }
1622
1623
1630 operator bool() const {
1631 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
1632 }
1633
1634
1635 protected:
1636
1637 mesh_ptr mesh_;
1638 HalfedgeHandle start_, heh_;
1639 int lap_counter_;
1640 };
1641
1642
1643
1644 //== CLASS DEFINITION =========================================================
1645
1646
1651 template <class Mesh>
1652 class VertexFaceIterT
1653 {
1654 public:
1655
1656
1657 //--- Typedefs ---
1658
1659 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
1660
1661 typedef typename Mesh::Face value_type;
1662 typedef typename Mesh::FaceHandle value_handle;
1663
1664 #if 0
1665 typedef std::bidirectional_iterator_tag iterator_category;
1666 typedef std::ptrdiff_t difference_type;
1667 typedef const Mesh& mesh_ref;
1668 typedef const Mesh* mesh_ptr;
1669 typedef const typename Mesh::Face& reference;
1670 typedef const typename Mesh::Face* pointer;
1671 #else
1672 typedef std::bidirectional_iterator_tag iterator_category;
1673 typedef std::ptrdiff_t difference_type;
1674 typedef Mesh& mesh_ref;
1675 typedef Mesh* mesh_ptr;
1676 typedef typename Mesh::Face& reference;
1677 typedef typename Mesh::Face* pointer;
1678 #endif
1679
1680
1681
1683 VertexFaceIterT() : mesh_(0), lap_counter_(false) {}
1684
1685
1687 VertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
1688 mesh_(&_mesh),
1689 start_(_mesh.halfedge_handle(_start)),
1690 heh_(start_),
1691 lap_counter_(_end)
1692 { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; }
1693
1694
1696 VertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
1697 mesh_(&_mesh),
1698 start_(_heh),
1699 heh_(_heh),
1700 lap_counter_(_end)
1701 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1702
1703
1705 VertexFaceIterT(const VertexFaceIterT& _rhs) :
1706 mesh_(_rhs.mesh_),
1707 start_(_rhs.start_),
1708 heh_(_rhs.heh_),
1709 lap_counter_(_rhs.lap_counter_)
1710 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1711
1712
1714 VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
1715 {
1716 mesh_ = _rhs.mesh_;
1717 start_ = _rhs.start_;
1718 heh_ = _rhs.heh_;
1719 lap_counter_ = _rhs.lap_counter_;
1720 return *this;
1721 }
1722
1723
1724 #if 0
1725
1726 VertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) :
1727 mesh_(_rhs.mesh_),
1728 start_(_rhs.start_),
1729 heh_(_rhs.heh_),
1730 lap_counter_(_rhs.lap_counter_)
1731 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1732
1733
1735 VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
1736 {
1737 mesh_ = _rhs.mesh_;
1738 start_ = _rhs.start_;
1739 heh_ = _rhs.heh_;
1740 lap_counter_ = _rhs.lap_counter_;
1741 return *this;
1742 }
1743 #else
1744 friend class ConstVertexFaceIterT<Mesh>;
1745 #endif
1746
1747
1749 bool operator==(const VertexFaceIterT& _rhs) const {
1750 return ((mesh_ == _rhs.mesh_) &&
1751 (start_ == _rhs.start_) &&
1752 (heh_ == _rhs.heh_) &&
1753 (lap_counter_ == _rhs.lap_counter_));
1754 }
1755
1756
1758 bool operator!=(const VertexFaceIterT& _rhs) const {
1759 return !operator==(_rhs);
1760 }
1761
1762
1764 VertexFaceIterT& operator++() {
1765 assert(mesh_);
1766 do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));;
1767 return *this;
1768 }
1769
1770
1772 VertexFaceIterT& operator--() {
1773 assert(mesh_);
1774 do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
1775 return *this;
1776 }
1777
1778
1783 HalfedgeHandle current_halfedge_handle() const {
1784 return heh_;
1785 }
1786
1787
1789 typename Mesh::FaceHandle handle() const {
1790 assert(mesh_);
1791 return mesh_->face_handle(heh_);
1792 }
1793
1794
1796 operator typename Mesh::FaceHandle() const {
1797 assert(mesh_);
1798 return mesh_->face_handle(heh_);
1799 }
1800
1801
1803 reference operator*() const {
1804 assert(mesh_);
1805 return mesh_->deref(handle());
1806 }
1807
1808
1810 pointer operator->() const {
1811 assert(mesh_);
1812 return &mesh_->deref(handle());
1813 }
1814
1815
1822 operator bool() const {
1823 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
1824 }
1825
1826
1827 protected:
1828
1829 mesh_ptr mesh_;
1830 HalfedgeHandle start_, heh_;
1831 int lap_counter_;
1832 };
1833
1834
1835
1836 //== CLASS DEFINITION =========================================================
1837
1838
1843 template <class Mesh>
1844 class ConstVertexFaceIterT
1845 {
1846 public:
1847
1848
1849 //--- Typedefs ---
1850
1851 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
1852
1853 typedef typename Mesh::Face value_type;
1854 typedef typename Mesh::FaceHandle value_handle;
1855
1856 #if 1
1857 typedef std::bidirectional_iterator_tag iterator_category;
1858 typedef std::ptrdiff_t difference_type;
1859 typedef const Mesh& mesh_ref;
1860 typedef const Mesh* mesh_ptr;
1861 typedef const typename Mesh::Face& reference;
1862 typedef const typename Mesh::Face* pointer;
1863 #else
1864 typedef std::bidirectional_iterator_tag iterator_category;
1865 typedef std::ptrdiff_t difference_type;
1866 typedef Mesh& mesh_ref;
1867 typedef Mesh* mesh_ptr;
1868 typedef typename Mesh::Face& reference;
1869 typedef typename Mesh::Face* pointer;
1870 #endif
1871
1872
1873
1875 ConstVertexFaceIterT() : mesh_(0), lap_counter_(false) {}
1876
1877
1879 ConstVertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
1880 mesh_(&_mesh),
1881 start_(_mesh.halfedge_handle(_start)),
1882 heh_(start_),
1883 lap_counter_(_end)
1884 { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; }
1885
1886
1888 ConstVertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
1889 mesh_(&_mesh),
1890 start_(_heh),
1891 heh_(_heh),
1892 lap_counter_(_end)
1893 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1894
1895
1897 ConstVertexFaceIterT(const ConstVertexFaceIterT& _rhs) :
1898 mesh_(_rhs.mesh_),
1899 start_(_rhs.start_),
1900 heh_(_rhs.heh_),
1901 lap_counter_(_rhs.lap_counter_)
1902 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1903
1904
1906 ConstVertexFaceIterT& operator=(const ConstVertexFaceIterT<Mesh>& _rhs)
1907 {
1908 mesh_ = _rhs.mesh_;
1909 start_ = _rhs.start_;
1910 heh_ = _rhs.heh_;
1911 lap_counter_ = _rhs.lap_counter_;
1912 return *this;
1913 }
1914
1915
1916 #if 1
1917
1918 ConstVertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) :
1919 mesh_(_rhs.mesh_),
1920 start_(_rhs.start_),
1921 heh_(_rhs.heh_),
1922 lap_counter_(_rhs.lap_counter_)
1923 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
1924
1925
1927 ConstVertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
1928 {
1929 mesh_ = _rhs.mesh_;
1930 start_ = _rhs.start_;
1931 heh_ = _rhs.heh_;
1932 lap_counter_ = _rhs.lap_counter_;
1933 return *this;
1934 }
1935 #else
1936 friend class ConstVertexFaceIterT<Mesh>;
1937 #endif
1938
1939
1941 bool operator==(const ConstVertexFaceIterT& _rhs) const {
1942 return ((mesh_ == _rhs.mesh_) &&
1943 (start_ == _rhs.start_) &&
1944 (heh_ == _rhs.heh_) &&
1945 (lap_counter_ == _rhs.lap_counter_));
1946 }
1947
1948
1950 bool operator!=(const ConstVertexFaceIterT& _rhs) const {
1951 return !operator==(_rhs);
1952 }
1953
1954
1956 ConstVertexFaceIterT& operator++() {
1957 assert(mesh_);
1958 do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));;
1959 return *this;
1960 }
1961
1962
1964 ConstVertexFaceIterT& operator--() {
1965 assert(mesh_);
1966 do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
1967 return *this;
1968 }
1969
1970
1975 HalfedgeHandle current_halfedge_handle() const {
1976 return heh_;
1977 }
1978
1979
1981 typename Mesh::FaceHandle handle() const {
1982 assert(mesh_);
1983 return mesh_->face_handle(heh_);
1984 }
1985
1986
1988 operator typename Mesh::FaceHandle() const {
1989 assert(mesh_);
1990 return mesh_->face_handle(heh_);
1991 }
1992
1993
1995 reference operator*() const {
1996 assert(mesh_);
1997 return mesh_->deref(handle());
1998 }
1999
2000
2002 pointer operator->() const {
2003 assert(mesh_);
2004 return &mesh_->deref(handle());
2005 }
2006
2007
2014 operator bool() const {
2015 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2016 }
2017
2018
2019 protected:
2020
2021 mesh_ptr mesh_;
2022 HalfedgeHandle start_, heh_;
2023 int lap_counter_;
2024 };
2025
2026
2027
2028 //== CLASS DEFINITION =========================================================
2029
2030
2035 template <class Mesh>
2036 class FaceVertexIterT
2037 {
2038 public:
2039
2040
2041 //--- Typedefs ---
2042
2043 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
2044
2045 typedef typename Mesh::Vertex value_type;
2046 typedef typename Mesh::VertexHandle value_handle;
2047
2048 #if 0
2049 typedef std::bidirectional_iterator_tag iterator_category;
2050 typedef std::ptrdiff_t difference_type;
2051 typedef const Mesh& mesh_ref;
2052 typedef const Mesh* mesh_ptr;
2053 typedef const typename Mesh::Vertex& reference;
2054 typedef const typename Mesh::Vertex* pointer;
2055 #else
2056 typedef std::bidirectional_iterator_tag iterator_category;
2057 typedef std::ptrdiff_t difference_type;
2058 typedef Mesh& mesh_ref;
2059 typedef Mesh* mesh_ptr;
2060 typedef typename Mesh::Vertex& reference;
2061 typedef typename Mesh::Vertex* pointer;
2062 #endif
2063
2064
2065
2067 FaceVertexIterT() : mesh_(0), lap_counter_(false) {}
2068
2069
2071 FaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
2072 mesh_(&_mesh),
2073 start_(_mesh.halfedge_handle(_start)),
2074 heh_(start_),
2075 lap_counter_(_end)
2076 { ; }
2077
2078
2080 FaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
2081 mesh_(&_mesh),
2082 start_(_heh),
2083 heh_(_heh),
2084 lap_counter_(_end)
2085 { ; }
2086
2087
2089 FaceVertexIterT(const FaceVertexIterT& _rhs) :
2090 mesh_(_rhs.mesh_),
2091 start_(_rhs.start_),
2092 heh_(_rhs.heh_),
2093 lap_counter_(_rhs.lap_counter_)
2094 { ; }
2095
2096
2098 FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
2099 {
2100 mesh_ = _rhs.mesh_;
2101 start_ = _rhs.start_;
2102 heh_ = _rhs.heh_;
2103 lap_counter_ = _rhs.lap_counter_;
2104 return *this;
2105 }
2106
2107
2108 #if 0
2109
2110 FaceVertexIterT(const FaceVertexIterT<Mesh>& _rhs) :
2111 mesh_(_rhs.mesh_),
2112 start_(_rhs.start_),
2113 heh_(_rhs.heh_),
2114 lap_counter_(_rhs.lap_counter_)
2115 { ; }
2116
2117
2119 FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
2120 {
2121 mesh_ = _rhs.mesh_;
2122 start_ = _rhs.start_;
2123 heh_ = _rhs.heh_;
2124 lap_counter_ = _rhs.lap_counter_;
2125 return *this;
2126 }
2127 #else
2128 friend class ConstFaceVertexIterT<Mesh>;
2129 #endif
2130
2131
2133 bool operator==(const FaceVertexIterT& _rhs) const {
2134 return ((mesh_ == _rhs.mesh_) &&
2135 (start_ == _rhs.start_) &&
2136 (heh_ == _rhs.heh_) &&
2137 (lap_counter_ == _rhs.lap_counter_));
2138 }
2139
2140
2142 bool operator!=(const FaceVertexIterT& _rhs) const {
2143 return !operator==(_rhs);
2144 }
2145
2146
2148 FaceVertexIterT& operator++() {
2149 assert(mesh_);
2150 heh_=mesh_->next_halfedge_handle(heh_);
2151 if(heh_ == start_) lap_counter_++;
2152 return *this;
2153 }
2154
2155
2157 FaceVertexIterT& operator--() {
2158 assert(mesh_);
2159 if(heh_ == start_) lap_counter_--;
2160 heh_=mesh_->prev_halfedge_handle(heh_);
2161 return *this;
2162 }
2163
2164
2169 HalfedgeHandle current_halfedge_handle() const {
2170 return heh_;
2171 }
2172
2173
2175 typename Mesh::VertexHandle handle() const {
2176 assert(mesh_);
2177 return mesh_->to_vertex_handle(heh_);
2178 }
2179
2180
2182 operator typename Mesh::VertexHandle() const {
2183 assert(mesh_);
2184 return mesh_->to_vertex_handle(heh_);
2185 }
2186
2187
2189 reference operator*() const {
2190 assert(mesh_);
2191 return mesh_->deref(handle());
2192 }
2193
2194
2196 pointer operator->() const {
2197 assert(mesh_);
2198 return &mesh_->deref(handle());
2199 }
2200
2201
2208 operator bool() const {
2209 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2210 }
2211
2212
2213 protected:
2214
2215 mesh_ptr mesh_;
2216 HalfedgeHandle start_, heh_;
2217 int lap_counter_;
2218 };
2219
2220
2221
2222 //== CLASS DEFINITION =========================================================
2223
2224
2229 template <class Mesh>
2230 class ConstFaceVertexIterT
2231 {
2232 public:
2233
2234
2235 //--- Typedefs ---
2236
2237 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
2238
2239 typedef typename Mesh::Vertex value_type;
2240 typedef typename Mesh::VertexHandle value_handle;
2241
2242 #if 1
2243 typedef std::bidirectional_iterator_tag iterator_category;
2244 typedef std::ptrdiff_t difference_type;
2245 typedef const Mesh& mesh_ref;
2246 typedef const Mesh* mesh_ptr;
2247 typedef const typename Mesh::Vertex& reference;
2248 typedef const typename Mesh::Vertex* pointer;
2249 #else
2250 typedef std::bidirectional_iterator_tag iterator_category;
2251 typedef std::ptrdiff_t difference_type;
2252 typedef Mesh& mesh_ref;
2253 typedef Mesh* mesh_ptr;
2254 typedef typename Mesh::Vertex& reference;
2255 typedef typename Mesh::Vertex* pointer;
2256 #endif
2257
2258
2259
2261 ConstFaceVertexIterT() : mesh_(0), lap_counter_(false) {}
2262
2263
2265 ConstFaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
2266 mesh_(&_mesh),
2267 start_(_mesh.halfedge_handle(_start)),
2268 heh_(start_),
2269 lap_counter_(_end)
2270 { ; }
2271
2272
2274 ConstFaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
2275 mesh_(&_mesh),
2276 start_(_heh),
2277 heh_(_heh),
2278 lap_counter_(_end)
2279 { ; }
2280
2281
2283 ConstFaceVertexIterT(const ConstFaceVertexIterT& _rhs) :
2284 mesh_(_rhs.mesh_),
2285 start_(_rhs.start_),
2286 heh_(_rhs.heh_),
2287 lap_counter_(_rhs.lap_counter_)
2288 { ; }
2289
2290
2292 ConstFaceVertexIterT& operator=(const ConstFaceVertexIterT<Mesh>& _rhs)
2293 {
2294 mesh_ = _rhs.mesh_;
2295 start_ = _rhs.start_;
2296 heh_ = _rhs.heh_;
2297 lap_counter_ = _rhs.lap_counter_;
2298 return *this;
2299 }
2300
2301
2302 #if 1
2303
2304 ConstFaceVertexIterT(const FaceVertexIterT<Mesh>& _rhs) :
2305 mesh_(_rhs.mesh_),
2306 start_(_rhs.start_),
2307 heh_(_rhs.heh_),
2308 lap_counter_(_rhs.lap_counter_)
2309 { ; }
2310
2311
2313 ConstFaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
2314 {
2315 mesh_ = _rhs.mesh_;
2316 start_ = _rhs.start_;
2317 heh_ = _rhs.heh_;
2318 lap_counter_ = _rhs.lap_counter_;
2319 return *this;
2320 }
2321 #else
2322 friend class ConstFaceVertexIterT<Mesh>;
2323 #endif
2324
2325
2327 bool operator==(const ConstFaceVertexIterT& _rhs) const {
2328 return ((mesh_ == _rhs.mesh_) &&
2329 (start_ == _rhs.start_) &&
2330 (heh_ == _rhs.heh_) &&
2331 (lap_counter_ == _rhs.lap_counter_));
2332 }
2333
2334
2336 bool operator!=(const ConstFaceVertexIterT& _rhs) const {
2337 return !operator==(_rhs);
2338 }
2339
2340
2342 ConstFaceVertexIterT& operator++() {
2343 assert(mesh_);
2344 heh_=mesh_->next_halfedge_handle(heh_);
2345 if(heh_ == start_) lap_counter_++;
2346 return *this;
2347 }
2348
2349
2351 ConstFaceVertexIterT& operator--() {
2352 assert(mesh_);
2353 if(heh_ == start_) lap_counter_--;
2354 heh_=mesh_->prev_halfedge_handle(heh_);
2355 return *this;
2356 }
2357
2358
2363 HalfedgeHandle current_halfedge_handle() const {
2364 return heh_;
2365 }
2366
2367
2369 typename Mesh::VertexHandle handle() const {
2370 assert(mesh_);
2371 return mesh_->to_vertex_handle(heh_);
2372 }
2373
2374
2376 operator typename Mesh::VertexHandle() const {
2377 assert(mesh_);
2378 return mesh_->to_vertex_handle(heh_);
2379 }
2380
2381
2383 reference operator*() const {
2384 assert(mesh_);
2385 return mesh_->deref(handle());
2386 }
2387
2388
2390 pointer operator->() const {
2391 assert(mesh_);
2392 return &mesh_->deref(handle());
2393 }
2394
2395
2402 operator bool() const {
2403 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2404 }
2405
2406
2407 protected:
2408
2409 mesh_ptr mesh_;
2410 HalfedgeHandle start_, heh_;
2411 int lap_counter_;
2412 };
2413
2414
2415
2416 //== CLASS DEFINITION =========================================================
2417
2418
2423 template <class Mesh>
2424 class FaceHalfedgeIterT
2425 {
2426 public:
2427
2428
2429 //--- Typedefs ---
2430
2431 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
2432
2433 typedef typename Mesh::Halfedge value_type;
2434 typedef typename Mesh::HalfedgeHandle value_handle;
2435
2436 #if 0
2437 typedef std::bidirectional_iterator_tag iterator_category;
2438 typedef std::ptrdiff_t difference_type;
2439 typedef const Mesh& mesh_ref;
2440 typedef const Mesh* mesh_ptr;
2441 typedef const typename Mesh::Halfedge& reference;
2442 typedef const typename Mesh::Halfedge* pointer;
2443 #else
2444 typedef std::bidirectional_iterator_tag iterator_category;
2445 typedef std::ptrdiff_t difference_type;
2446 typedef Mesh& mesh_ref;
2447 typedef Mesh* mesh_ptr;
2448 typedef typename Mesh::Halfedge& reference;
2449 typedef typename Mesh::Halfedge* pointer;
2450 #endif
2451
2452
2453
2455 FaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
2456
2457
2459 FaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
2460 mesh_(&_mesh),
2461 start_(_mesh.halfedge_handle(_start)),
2462 heh_(start_),
2463 lap_counter_(_end)
2464 { ; }
2465
2466
2468 FaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
2469 mesh_(&_mesh),
2470 start_(_heh),
2471 heh_(_heh),
2472 lap_counter_(_end)
2473 { ; }
2474
2475
2477 FaceHalfedgeIterT(const FaceHalfedgeIterT& _rhs) :
2478 mesh_(_rhs.mesh_),
2479 start_(_rhs.start_),
2480 heh_(_rhs.heh_),
2481 lap_counter_(_rhs.lap_counter_)
2482 { ; }
2483
2484
2486 FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
2487 {
2488 mesh_ = _rhs.mesh_;
2489 start_ = _rhs.start_;
2490 heh_ = _rhs.heh_;
2491 lap_counter_ = _rhs.lap_counter_;
2492 return *this;
2493 }
2494
2495
2496 #if 0
2497
2498 FaceHalfedgeIterT(const FaceHalfedgeIterT<Mesh>& _rhs) :
2499 mesh_(_rhs.mesh_),
2500 start_(_rhs.start_),
2501 heh_(_rhs.heh_),
2502 lap_counter_(_rhs.lap_counter_)
2503 { ; }
2504
2505
2507 FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
2508 {
2509 mesh_ = _rhs.mesh_;
2510 start_ = _rhs.start_;
2511 heh_ = _rhs.heh_;
2512 lap_counter_ = _rhs.lap_counter_;
2513 return *this;
2514 }
2515 #else
2516 friend class ConstFaceHalfedgeIterT<Mesh>;
2517 #endif
2518
2519
2521 bool operator==(const FaceHalfedgeIterT& _rhs) const {
2522 return ((mesh_ == _rhs.mesh_) &&
2523 (start_ == _rhs.start_) &&
2524 (heh_ == _rhs.heh_) &&
2525 (lap_counter_ == _rhs.lap_counter_));
2526 }
2527
2528
2530 bool operator!=(const FaceHalfedgeIterT& _rhs) const {
2531 return !operator==(_rhs);
2532 }
2533
2534
2536 FaceHalfedgeIterT& operator++() {
2537 assert(mesh_);
2538 heh_=mesh_->next_halfedge_handle(heh_);
2539 if(heh_ == start_) lap_counter_++;
2540 return *this;
2541 }
2542
2543
2545 FaceHalfedgeIterT& operator--() {
2546 assert(mesh_);
2547 if(heh_ == start_) lap_counter_--;
2548 heh_=mesh_->prev_halfedge_handle(heh_);
2549 return *this;
2550 }
2551
2552
2557 HalfedgeHandle current_halfedge_handle() const {
2558 return heh_;
2559 }
2560
2561
2563 typename Mesh::HalfedgeHandle handle() const {
2564 assert(mesh_);
2565 return heh_;
2566 }
2567
2568
2570 operator typename Mesh::HalfedgeHandle() const {
2571 assert(mesh_);
2572 return heh_;
2573 }
2574
2575
2577 reference operator*() const {
2578 assert(mesh_);
2579 return mesh_->deref(handle());
2580 }
2581
2582
2584 pointer operator->() const {
2585 assert(mesh_);
2586 return &mesh_->deref(handle());
2587 }
2588
2589
2596 operator bool() const {
2597 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2598 }
2599
2600
2601 protected:
2602
2603 mesh_ptr mesh_;
2604 HalfedgeHandle start_, heh_;
2605 int lap_counter_;
2606 };
2607
2608
2609
2610 //== CLASS DEFINITION =========================================================
2611
2612
2617 template <class Mesh>
2618 class ConstFaceHalfedgeIterT
2619 {
2620 public:
2621
2622
2623 //--- Typedefs ---
2624
2625 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
2626
2627 typedef typename Mesh::Halfedge value_type;
2628 typedef typename Mesh::HalfedgeHandle value_handle;
2629
2630 #if 1
2631 typedef std::bidirectional_iterator_tag iterator_category;
2632 typedef std::ptrdiff_t difference_type;
2633 typedef const Mesh& mesh_ref;
2634 typedef const Mesh* mesh_ptr;
2635 typedef const typename Mesh::Halfedge& reference;
2636 typedef const typename Mesh::Halfedge* pointer;
2637 #else
2638 typedef std::bidirectional_iterator_tag iterator_category;
2639 typedef std::ptrdiff_t difference_type;
2640 typedef Mesh& mesh_ref;
2641 typedef Mesh* mesh_ptr;
2642 typedef typename Mesh::Halfedge& reference;
2643 typedef typename Mesh::Halfedge* pointer;
2644 #endif
2645
2646
2647
2649 ConstFaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
2650
2651
2653 ConstFaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
2654 mesh_(&_mesh),
2655 start_(_mesh.halfedge_handle(_start)),
2656 heh_(start_),
2657 lap_counter_(_end)
2658 { ; }
2659
2660
2662 ConstFaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
2663 mesh_(&_mesh),
2664 start_(_heh),
2665 heh_(_heh),
2666 lap_counter_(_end)
2667 { ; }
2668
2669
2671 ConstFaceHalfedgeIterT(const ConstFaceHalfedgeIterT& _rhs) :
2672 mesh_(_rhs.mesh_),
2673 start_(_rhs.start_),
2674 heh_(_rhs.heh_),
2675 lap_counter_(_rhs.lap_counter_)
2676 { ; }
2677
2678
2680 ConstFaceHalfedgeIterT& operator=(const ConstFaceHalfedgeIterT<Mesh>& _rhs)
2681 {
2682 mesh_ = _rhs.mesh_;
2683 start_ = _rhs.start_;
2684 heh_ = _rhs.heh_;
2685 lap_counter_ = _rhs.lap_counter_;
2686 return *this;
2687 }
2688
2689
2690 #if 1
2691
2692 ConstFaceHalfedgeIterT(const FaceHalfedgeIterT<Mesh>& _rhs) :
2693 mesh_(_rhs.mesh_),
2694 start_(_rhs.start_),
2695 heh_(_rhs.heh_),
2696 lap_counter_(_rhs.lap_counter_)
2697 { ; }
2698
2699
2701 ConstFaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
2702 {
2703 mesh_ = _rhs.mesh_;
2704 start_ = _rhs.start_;
2705 heh_ = _rhs.heh_;
2706 lap_counter_ = _rhs.lap_counter_;
2707 return *this;
2708 }
2709 #else
2710 friend class ConstFaceHalfedgeIterT<Mesh>;
2711 #endif
2712
2713
2715 bool operator==(const ConstFaceHalfedgeIterT& _rhs) const {
2716 return ((mesh_ == _rhs.mesh_) &&
2717 (start_ == _rhs.start_) &&
2718 (heh_ == _rhs.heh_) &&
2719 (lap_counter_ == _rhs.lap_counter_));
2720 }
2721
2722
2724 bool operator!=(const ConstFaceHalfedgeIterT& _rhs) const {
2725 return !operator==(_rhs);
2726 }
2727
2728
2730 ConstFaceHalfedgeIterT& operator++() {
2731 assert(mesh_);
2732 heh_=mesh_->next_halfedge_handle(heh_);
2733 if(heh_ == start_) lap_counter_++;
2734 return *this;
2735 }
2736
2737
2739 ConstFaceHalfedgeIterT& operator--() {
2740 assert(mesh_);
2741 if(heh_ == start_) lap_counter_--;
2742 heh_=mesh_->prev_halfedge_handle(heh_);
2743 return *this;
2744 }
2745
2746
2751 HalfedgeHandle current_halfedge_handle() const {
2752 return heh_;
2753 }
2754
2755
2757 typename Mesh::HalfedgeHandle handle() const {
2758 assert(mesh_);
2759 return heh_;
2760 }
2761
2762
2764 operator typename Mesh::HalfedgeHandle() const {
2765 assert(mesh_);
2766 return heh_;
2767 }
2768
2769
2771 reference operator*() const {
2772 assert(mesh_);
2773 return mesh_->deref(handle());
2774 }
2775
2776
2778 pointer operator->() const {
2779 assert(mesh_);
2780 return &mesh_->deref(handle());
2781 }
2782
2783
2790 operator bool() const {
2791 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2792 }
2793
2794
2795 protected:
2796
2797 mesh_ptr mesh_;
2798 HalfedgeHandle start_, heh_;
2799 int lap_counter_;
2800 };
2801
2802
2803
2804 //== CLASS DEFINITION =========================================================
2805
2806
2811 template <class Mesh>
2812 class FaceEdgeIterT
2813 {
2814 public:
2815
2816
2817 //--- Typedefs ---
2818
2819 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
2820
2821 typedef typename Mesh::Edge value_type;
2822 typedef typename Mesh::EdgeHandle value_handle;
2823
2824 #if 0
2825 typedef std::bidirectional_iterator_tag iterator_category;
2826 typedef std::ptrdiff_t difference_type;
2827 typedef const Mesh& mesh_ref;
2828 typedef const Mesh* mesh_ptr;
2829 typedef const typename Mesh::Edge& reference;
2830 typedef const typename Mesh::Edge* pointer;
2831 #else
2832 typedef std::bidirectional_iterator_tag iterator_category;
2833 typedef std::ptrdiff_t difference_type;
2834 typedef Mesh& mesh_ref;
2835 typedef Mesh* mesh_ptr;
2836 typedef typename Mesh::Edge& reference;
2837 typedef typename Mesh::Edge* pointer;
2838 #endif
2839
2840
2841
2843 FaceEdgeIterT() : mesh_(0), lap_counter_(false) {}
2844
2845
2847 FaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
2848 mesh_(&_mesh),
2849 start_(_mesh.halfedge_handle(_start)),
2850 heh_(start_),
2851 lap_counter_(_end)
2852 { ; }
2853
2854
2856 FaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
2857 mesh_(&_mesh),
2858 start_(_heh),
2859 heh_(_heh),
2860 lap_counter_(_end)
2861 { ; }
2862
2863
2865 FaceEdgeIterT(const FaceEdgeIterT& _rhs) :
2866 mesh_(_rhs.mesh_),
2867 start_(_rhs.start_),
2868 heh_(_rhs.heh_),
2869 lap_counter_(_rhs.lap_counter_)
2870 { ; }
2871
2872
2874 FaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
2875 {
2876 mesh_ = _rhs.mesh_;
2877 start_ = _rhs.start_;
2878 heh_ = _rhs.heh_;
2879 lap_counter_ = _rhs.lap_counter_;
2880 return *this;
2881 }
2882
2883
2884 #if 0
2885
2886 FaceEdgeIterT(const FaceEdgeIterT<Mesh>& _rhs) :
2887 mesh_(_rhs.mesh_),
2888 start_(_rhs.start_),
2889 heh_(_rhs.heh_),
2890 lap_counter_(_rhs.lap_counter_)
2891 { ; }
2892
2893
2895 FaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
2896 {
2897 mesh_ = _rhs.mesh_;
2898 start_ = _rhs.start_;
2899 heh_ = _rhs.heh_;
2900 lap_counter_ = _rhs.lap_counter_;
2901 return *this;
2902 }
2903 #else
2904 friend class ConstFaceEdgeIterT<Mesh>;
2905 #endif
2906
2907
2909 bool operator==(const FaceEdgeIterT& _rhs) const {
2910 return ((mesh_ == _rhs.mesh_) &&
2911 (start_ == _rhs.start_) &&
2912 (heh_ == _rhs.heh_) &&
2913 (lap_counter_ == _rhs.lap_counter_));
2914 }
2915
2916
2918 bool operator!=(const FaceEdgeIterT& _rhs) const {
2919 return !operator==(_rhs);
2920 }
2921
2922
2924 FaceEdgeIterT& operator++() {
2925 assert(mesh_);
2926 heh_=mesh_->next_halfedge_handle(heh_);
2927 if(heh_ == start_) lap_counter_++;
2928 return *this;
2929 }
2930
2931
2933 FaceEdgeIterT& operator--() {
2934 assert(mesh_);
2935 if(heh_ == start_) lap_counter_--;
2936 heh_=mesh_->prev_halfedge_handle(heh_);
2937 return *this;
2938 }
2939
2940
2945 HalfedgeHandle current_halfedge_handle() const {
2946 return heh_;
2947 }
2948
2949
2951 typename Mesh::EdgeHandle handle() const {
2952 assert(mesh_);
2953 return mesh_->edge_handle(heh_);
2954 }
2955
2956
2958 operator typename Mesh::EdgeHandle() const {
2959 assert(mesh_);
2960 return mesh_->edge_handle(heh_);
2961 }
2962
2963
2965 reference operator*() const {
2966 assert(mesh_);
2967 return mesh_->deref(handle());
2968 }
2969
2970
2972 pointer operator->() const {
2973 assert(mesh_);
2974 return &mesh_->deref(handle());
2975 }
2976
2977
2984 operator bool() const {
2985 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
2986 }
2987
2988
2989 protected:
2990
2991 mesh_ptr mesh_;
2992 HalfedgeHandle start_, heh_;
2993 int lap_counter_;
2994 };
2995
2996
2997
2998 //== CLASS DEFINITION =========================================================
2999
3000
3005 template <class Mesh>
3006 class ConstFaceEdgeIterT
3007 {
3008 public:
3009
3010
3011 //--- Typedefs ---
3012
3013 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
3014
3015 typedef typename Mesh::Edge value_type;
3016 typedef typename Mesh::EdgeHandle value_handle;
3017
3018 #if 1
3019 typedef std::bidirectional_iterator_tag iterator_category;
3020 typedef std::ptrdiff_t difference_type;
3021 typedef const Mesh& mesh_ref;
3022 typedef const Mesh* mesh_ptr;
3023 typedef const typename Mesh::Edge& reference;
3024 typedef const typename Mesh::Edge* pointer;
3025 #else
3026 typedef std::bidirectional_iterator_tag iterator_category;
3027 typedef std::ptrdiff_t difference_type;
3028 typedef Mesh& mesh_ref;
3029 typedef Mesh* mesh_ptr;
3030 typedef typename Mesh::Edge& reference;
3031 typedef typename Mesh::Edge* pointer;
3032 #endif
3033
3034
3035
3037 ConstFaceEdgeIterT() : mesh_(0), lap_counter_(false) {}
3038
3039
3041 ConstFaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
3042 mesh_(&_mesh),
3043 start_(_mesh.halfedge_handle(_start)),
3044 heh_(start_),
3045 lap_counter_(_end)
3046 { ; }
3047
3048
3050 ConstFaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
3051 mesh_(&_mesh),
3052 start_(_heh),
3053 heh_(_heh),
3054 lap_counter_(_end)
3055 { ; }
3056
3057
3059 ConstFaceEdgeIterT(const ConstFaceEdgeIterT& _rhs) :
3060 mesh_(_rhs.mesh_),
3061 start_(_rhs.start_),
3062 heh_(_rhs.heh_),
3063 lap_counter_(_rhs.lap_counter_)
3064 { ; }
3065
3066
3068 ConstFaceEdgeIterT& operator=(const ConstFaceEdgeIterT<Mesh>& _rhs)
3069 {
3070 mesh_ = _rhs.mesh_;
3071 start_ = _rhs.start_;
3072 heh_ = _rhs.heh_;
3073 lap_counter_ = _rhs.lap_counter_;
3074 return *this;
3075 }
3076
3077
3078 #if 1
3079
3080 ConstFaceEdgeIterT(const FaceEdgeIterT<Mesh>& _rhs) :
3081 mesh_(_rhs.mesh_),
3082 start_(_rhs.start_),
3083 heh_(_rhs.heh_),
3084 lap_counter_(_rhs.lap_counter_)
3085 { ; }
3086
3087
3089 ConstFaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
3090 {
3091 mesh_ = _rhs.mesh_;
3092 start_ = _rhs.start_;
3093 heh_ = _rhs.heh_;
3094 lap_counter_ = _rhs.lap_counter_;
3095 return *this;
3096 }
3097 #else
3098 friend class ConstFaceEdgeIterT<Mesh>;
3099 #endif
3100
3101
3103 bool operator==(const ConstFaceEdgeIterT& _rhs) const {
3104 return ((mesh_ == _rhs.mesh_) &&
3105 (start_ == _rhs.start_) &&
3106 (heh_ == _rhs.heh_) &&
3107 (lap_counter_ == _rhs.lap_counter_));
3108 }
3109
3110
3112 bool operator!=(const ConstFaceEdgeIterT& _rhs) const {
3113 return !operator==(_rhs);
3114 }
3115
3116
3118 ConstFaceEdgeIterT& operator++() {
3119 assert(mesh_);
3120 heh_=mesh_->next_halfedge_handle(heh_);
3121 if(heh_ == start_) lap_counter_++;
3122 return *this;
3123 }
3124
3125
3127 ConstFaceEdgeIterT& operator--() {
3128 assert(mesh_);
3129 if(heh_ == start_) lap_counter_--;
3130 heh_=mesh_->prev_halfedge_handle(heh_);
3131 return *this;
3132 }
3133
3134
3139 HalfedgeHandle current_halfedge_handle() const {
3140 return heh_;
3141 }
3142
3143
3145 typename Mesh::EdgeHandle handle() const {
3146 assert(mesh_);
3147 return mesh_->edge_handle(heh_);
3148 }
3149
3150
3152 operator typename Mesh::EdgeHandle() const {
3153 assert(mesh_);
3154 return mesh_->edge_handle(heh_);
3155 }
3156
3157
3159 reference operator*() const {
3160 assert(mesh_);
3161 return mesh_->deref(handle());
3162 }
3163
3164
3166 pointer operator->() const {
3167 assert(mesh_);
3168 return &mesh_->deref(handle());
3169 }
3170
3171
3178 operator bool() const {
3179 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
3180 }
3181
3182
3183 protected:
3184
3185 mesh_ptr mesh_;
3186 HalfedgeHandle start_, heh_;
3187 int lap_counter_;
3188 };
3189
3190
3191
3192 //== CLASS DEFINITION =========================================================
3193
3194
3199 template <class Mesh>
3200 class FaceFaceIterT
3201 {
3202 public:
3203
3204
3205 //--- Typedefs ---
3206
3207 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
3208
3209 typedef typename Mesh::Face value_type;
3210 typedef typename Mesh::FaceHandle value_handle;
3211
3212 #if 0
3213 typedef std::bidirectional_iterator_tag iterator_category;
3214 typedef std::ptrdiff_t difference_type;
3215 typedef const Mesh& mesh_ref;
3216 typedef const Mesh* mesh_ptr;
3217 typedef const typename Mesh::Face& reference;
3218 typedef const typename Mesh::Face* pointer;
3219 #else
3220 typedef std::bidirectional_iterator_tag iterator_category;
3221 typedef std::ptrdiff_t difference_type;
3222 typedef Mesh& mesh_ref;
3223 typedef Mesh* mesh_ptr;
3224 typedef typename Mesh::Face& reference;
3225 typedef typename Mesh::Face* pointer;
3226 #endif
3227
3228
3229
3231 FaceFaceIterT() : mesh_(0), lap_counter_(false) {}
3232
3233
3235 FaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
3236 mesh_(&_mesh),
3237 start_(_mesh.halfedge_handle(_start)),
3238 heh_(start_),
3239 lap_counter_(_end)
3240 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3241
3242
3244 FaceFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
3245 mesh_(&_mesh),
3246 start_(_heh),
3247 heh_(_heh),
3248 lap_counter_(_end)
3249 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3250
3251
3253 FaceFaceIterT(const FaceFaceIterT& _rhs) :
3254 mesh_(_rhs.mesh_),
3255 start_(_rhs.start_),
3256 heh_(_rhs.heh_),
3257 lap_counter_(_rhs.lap_counter_)
3258 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3259
3260
3262 FaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
3263 {
3264 mesh_ = _rhs.mesh_;
3265 start_ = _rhs.start_;
3266 heh_ = _rhs.heh_;
3267 lap_counter_ = _rhs.lap_counter_;
3268 return *this;
3269 }
3270
3271
3272 #if 0
3273
3274 FaceFaceIterT(const FaceFaceIterT<Mesh>& _rhs) :
3275 mesh_(_rhs.mesh_),
3276 start_(_rhs.start_),
3277 heh_(_rhs.heh_),
3278 lap_counter_(_rhs.lap_counter_)
3279 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3280
3281
3283 FaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
3284 {
3285 mesh_ = _rhs.mesh_;
3286 start_ = _rhs.start_;
3287 heh_ = _rhs.heh_;
3288 lap_counter_ = _rhs.lap_counter_;
3289 return *this;
3290 }
3291 #else
3292 friend class ConstFaceFaceIterT<Mesh>;
3293 #endif
3294
3295
3297 bool operator==(const FaceFaceIterT& _rhs) const {
3298 return ((mesh_ == _rhs.mesh_) &&
3299 (start_ == _rhs.start_) &&
3300 (heh_ == _rhs.heh_) &&
3301 (lap_counter_ == _rhs.lap_counter_));
3302 }
3303
3304
3306 bool operator!=(const FaceFaceIterT& _rhs) const {
3307 return !operator==(_rhs);
3308 }
3309
3310
3312 FaceFaceIterT& operator++() {
3313 assert(mesh_);
3314 do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));
3315 return *this;
3316 }
3317
3318
3320 FaceFaceIterT& operator--() {
3321 assert(mesh_);
3322 do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));
3323 return *this;
3324 }
3325
3326
3331 HalfedgeHandle current_halfedge_handle() const {
3332 return heh_;
3333 }
3334
3335
3337 typename Mesh::FaceHandle handle() const {
3338 assert(mesh_);
3339 return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_));
3340 }
3341
3342
3344 operator typename Mesh::FaceHandle() const {
3345 assert(mesh_);
3346 return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_));
3347 }
3348
3349
3351 reference operator*() const {
3352 assert(mesh_);
3353 return mesh_->deref(handle());
3354 }
3355
3356
3358 pointer operator->() const {
3359 assert(mesh_);
3360 return &mesh_->deref(handle());
3361 }
3362
3363
3370 operator bool() const {
3371 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
3372 }
3373
3374
3375 protected:
3376
3377 mesh_ptr mesh_;
3378 HalfedgeHandle start_, heh_;
3379 int lap_counter_;
3380 };
3381
3382
3383
3384 //== CLASS DEFINITION =========================================================
3385
3386
3391 template <class Mesh>
3392 class ConstFaceFaceIterT
3393 {
3394 public:
3395
3396
3397 //--- Typedefs ---
3398
3399 typedef typename Mesh::HalfedgeHandle HalfedgeHandle;
3400
3401 typedef typename Mesh::Face value_type;
3402 typedef typename Mesh::FaceHandle value_handle;
3403
3404 #if 1
3405 typedef std::bidirectional_iterator_tag iterator_category;
3406 typedef std::ptrdiff_t difference_type;
3407 typedef const Mesh& mesh_ref;
3408 typedef const Mesh* mesh_ptr;
3409 typedef const typename Mesh::Face& reference;
3410 typedef const typename Mesh::Face* pointer;
3411 #else
3412 typedef std::bidirectional_iterator_tag iterator_category;
3413 typedef std::ptrdiff_t difference_type;
3414 typedef Mesh& mesh_ref;
3415 typedef Mesh* mesh_ptr;
3416 typedef typename Mesh::Face& reference;
3417 typedef typename Mesh::Face* pointer;
3418 #endif
3419
3420
3421
3423 ConstFaceFaceIterT() : mesh_(0), lap_counter_(false) {}
3424
3425
3427 ConstFaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
3428 mesh_(&_mesh),
3429 start_(_mesh.halfedge_handle(_start)),
3430 heh_(start_),
3431 lap_counter_(_end)
3432 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3433
3434
3436 ConstFaceFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
3437 mesh_(&_mesh),
3438 start_(_heh),
3439 heh_(_heh),
3440 lap_counter_(_end)
3441 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3442
3443
3445 ConstFaceFaceIterT(const ConstFaceFaceIterT& _rhs) :
3446 mesh_(_rhs.mesh_),
3447 start_(_rhs.start_),
3448 heh_(_rhs.heh_),
3449 lap_counter_(_rhs.lap_counter_)
3450 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3451
3452
3454 ConstFaceFaceIterT& operator=(const ConstFaceFaceIterT<Mesh>& _rhs)
3455 {
3456 mesh_ = _rhs.mesh_;
3457 start_ = _rhs.start_;
3458 heh_ = _rhs.heh_;
3459 lap_counter_ = _rhs.lap_counter_;
3460 return *this;
3461 }
3462
3463
3464 #if 1
3465
3466 ConstFaceFaceIterT(const FaceFaceIterT<Mesh>& _rhs) :
3467 mesh_(_rhs.mesh_),
3468 start_(_rhs.start_),
3469 heh_(_rhs.heh_),
3470 lap_counter_(_rhs.lap_counter_)
3471 { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
3472
3473
3475 ConstFaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
3476 {
3477 mesh_ = _rhs.mesh_;
3478 start_ = _rhs.start_;
3479 heh_ = _rhs.heh_;
3480 lap_counter_ = _rhs.lap_counter_;
3481 return *this;
3482 }
3483 #else
3484 friend class ConstFaceFaceIterT<Mesh>;
3485 #endif
3486
3487
3489 bool operator==(const ConstFaceFaceIterT& _rhs) const {
3490 return ((mesh_ == _rhs.mesh_) &&
3491 (start_ == _rhs.start_) &&
3492 (heh_ == _rhs.heh_) &&
3493 (lap_counter_ == _rhs.lap_counter_));
3494 }
3495
3496
3498 bool operator!=(const ConstFaceFaceIterT& _rhs) const {
3499 return !operator==(_rhs);
3500 }
3501
3502
3504 ConstFaceFaceIterT& operator++() {
3505 assert(mesh_);
3506 do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));;
3507 return *this;
3508 }
3509
3510
3512 ConstFaceFaceIterT& operator--() {
3513 assert(mesh_);
3514 do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
3515 return *this;
3516 }
3517
3518
3523 HalfedgeHandle current_halfedge_handle() const {
3524 return heh_;
3525 }
3526
3527
3529 typename Mesh::FaceHandle handle() const {
3530 assert(mesh_);
3531 return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_));
3532 }
3533
3534
3536 operator typename Mesh::FaceHandle() const {
3537 assert(mesh_);
3538 return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_));
3539 }
3540
3541
3543 reference operator*() const {
3544 assert(mesh_);
3545 return mesh_->deref(handle());
3546 }
3547
3548
3550 pointer operator->() const {
3551 assert(mesh_);
3552 return &mesh_->deref(handle());
3553 }
3554
3555
3562 operator bool() const {
3563 return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
3564 }
3565
3566
3567 protected:
3568
3569 mesh_ptr mesh_;
3570 HalfedgeHandle start_, heh_;
3571 int lap_counter_;
3572 };
3573
3574
3575
3576 //=============================================================================
3577 } // namespace Iterators
3578 } // namespace OpenMesh
3579 //=============================================================================
3580 #endif
3581 //=============================================================================