00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #ifndef OPENMESH_ITERATORS_HH
00043 #define OPENMESH_ITERATORS_HH
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 #include <OpenMesh/Core/System/config.h>
00056 #include <OpenMesh/Core/Mesh/Status.hh>
00057 #include <assert.h>
00058
00059
00060
00061
00062 namespace OpenMesh {
00063 namespace Iterators {
00064
00065
00066
00067
00068
00069 template <class Mesh> class VertexIterT;
00070 template <class Mesh> class ConstVertexIterT;
00071 template <class Mesh> class HalfedgeIterT;
00072 template <class Mesh> class ConstHalfedgeIterT;
00073 template <class Mesh> class EdgeIterT;
00074 template <class Mesh> class ConstEdgeIterT;
00075 template <class Mesh> class FaceIterT;
00076 template <class Mesh> class ConstFaceIterT;
00077
00078
00079
00080
00081
00082
00083
00088 template <class Mesh>
00089 class VertexIterT
00090 {
00091 public:
00092
00093
00094
00095
00096 typedef typename Mesh::Vertex value_type;
00097 typedef typename Mesh::VertexHandle value_handle;
00098
00099 #if 0
00100 typedef std::bidirectional_iterator_tag iterator_category;
00101 typedef ptrdiff_t difference_type;
00102 typedef const value_type& reference;
00103 typedef const value_type* pointer;
00104 typedef const Mesh* mesh_ptr;
00105 typedef const Mesh& mesh_ref;
00106 #else
00107 typedef std::bidirectional_iterator_tag iterator_category;
00108 typedef ptrdiff_t difference_type;
00109 typedef value_type& reference;
00110 typedef value_type* pointer;
00111 typedef Mesh* mesh_ptr;
00112 typedef Mesh& mesh_ref;
00113 #endif
00114
00115
00117 VertexIterT()
00118 : mesh_(0), skip_bits_(0)
00119 {}
00120
00121
00123 VertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00124 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00125 {
00126 if (_skip) enable_skipping();
00127
00128
00129 if(_mesh.n_vertices() == 0) hnd_ = value_handle(-1);
00130 }
00131
00132
00134 VertexIterT(const VertexIterT& _rhs)
00135 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00136 {}
00137
00138
00140 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00141 {
00142 mesh_ = _rhs.mesh_;
00143 hnd_ = _rhs.hnd_;
00144 skip_bits_ = _rhs.skip_bits_;
00145 return *this;
00146 }
00147
00148
00149 #if 0
00150
00152 VertexIterT(const VertexIterT<Mesh>& _rhs)
00153 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00154 {}
00155
00156
00158 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00159 {
00160 mesh_ = _rhs.mesh_;
00161 hnd_ = _rhs.hnd_;
00162 skip_bits_ = _rhs.skip_bits_;
00163 return *this;
00164 }
00165
00166 #else
00167 friend class ConstVertexIterT<Mesh>;
00168 #endif
00169
00170
00172 reference operator*() const { return mesh_->deref(hnd_); }
00173
00175 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00176
00178 value_handle handle() const { return hnd_; }
00179
00181 operator value_handle() const { return hnd_; }
00182
00184 bool operator==(const VertexIterT& _rhs) const
00185 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00186
00188 bool operator!=(const VertexIterT& _rhs) const
00189 { return !operator==(_rhs); }
00190
00192 VertexIterT& operator++()
00193 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00194
00196 VertexIterT& operator--()
00197 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00198
00199
00201 void enable_skipping()
00202 {
00203 if (mesh_ && mesh_->has_vertex_status())
00204 {
00205 Attributes::StatusInfo status;
00206 status.set_deleted(true);
00207 status.set_hidden(true);
00208 skip_bits_ = status.bits();
00209 skip_fwd();
00210 }
00211 else skip_bits_ = 0;
00212 }
00213
00214
00216 void disable_skipping() { skip_bits_ = 0; }
00217
00218
00219
00220 private:
00221
00222 void skip_fwd()
00223 {
00224 assert(mesh_ && skip_bits_);
00225 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00226 (mesh_->status(hnd_).bits() & skip_bits_))
00227 hnd_.__increment();
00228 }
00229
00230
00231 void skip_bwd()
00232 {
00233 assert(mesh_ && skip_bits_);
00234 while ((hnd_.idx() >= 0) &&
00235 (mesh_->status(hnd_).bits() & skip_bits_))
00236 hnd_.__decrement();
00237 }
00238
00239
00240
00241 private:
00242 mesh_ptr mesh_;
00243 value_handle hnd_;
00244 unsigned int skip_bits_;
00245 };
00246
00247
00248
00249
00250
00255 template <class Mesh>
00256 class ConstVertexIterT
00257 {
00258 public:
00259
00260
00261
00262
00263 typedef typename Mesh::Vertex value_type;
00264 typedef typename Mesh::VertexHandle value_handle;
00265
00266 #if 1
00267 typedef std::bidirectional_iterator_tag iterator_category;
00268 typedef ptrdiff_t difference_type;
00269 typedef const value_type& reference;
00270 typedef const value_type* pointer;
00271 typedef const Mesh* mesh_ptr;
00272 typedef const Mesh& mesh_ref;
00273 #else
00274 typedef std::bidirectional_iterator_tag iterator_category;
00275 typedef ptrdiff_t difference_type;
00276 typedef value_type& reference;
00277 typedef value_type* pointer;
00278 typedef Mesh* mesh_ptr;
00279 typedef Mesh& mesh_ref;
00280 #endif
00281
00282
00283
00284
00286 ConstVertexIterT()
00287 : mesh_(0), skip_bits_(0)
00288 {}
00289
00290
00292 ConstVertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00293 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00294 {
00295 if (_skip) enable_skipping();
00296
00297
00298 if(_mesh.n_vertices() == 0) hnd_ = value_handle(-1);
00299 }
00300
00301
00303 ConstVertexIterT(const ConstVertexIterT& _rhs)
00304 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00305 {}
00306
00307
00309 ConstVertexIterT& operator=(const ConstVertexIterT<Mesh>& _rhs)
00310 {
00311 mesh_ = _rhs.mesh_;
00312 hnd_ = _rhs.hnd_;
00313 skip_bits_ = _rhs.skip_bits_;
00314 return *this;
00315 }
00316
00317
00318 #if 1
00319
00321 ConstVertexIterT(const VertexIterT<Mesh>& _rhs)
00322 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00323 {}
00324
00325
00327 ConstVertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00328 {
00329 mesh_ = _rhs.mesh_;
00330 hnd_ = _rhs.hnd_;
00331 skip_bits_ = _rhs.skip_bits_;
00332 return *this;
00333 }
00334
00335 #else
00336 friend class ConstVertexIterT<Mesh>;
00337 #endif
00338
00339
00341 reference operator*() const { return mesh_->deref(hnd_); }
00342
00344 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00345
00347 value_handle handle() const { return hnd_; }
00348
00350 operator value_handle() const { return hnd_; }
00351
00353 bool operator==(const ConstVertexIterT& _rhs) const
00354 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00355
00357 bool operator!=(const ConstVertexIterT& _rhs) const
00358 { return !operator==(_rhs); }
00359
00361 ConstVertexIterT& operator++()
00362 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00363
00365 ConstVertexIterT& operator--()
00366 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00367
00368
00370 void enable_skipping()
00371 {
00372 if (mesh_ && mesh_->has_vertex_status())
00373 {
00374 Attributes::StatusInfo status;
00375 status.set_deleted(true);
00376 status.set_hidden(true);
00377 skip_bits_ = status.bits();
00378 skip_fwd();
00379 }
00380 else skip_bits_ = 0;
00381 }
00382
00383
00385 void disable_skipping() { skip_bits_ = 0; }
00386
00387
00388
00389 private:
00390
00391 void skip_fwd()
00392 {
00393 assert(mesh_ && skip_bits_);
00394 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00395 (mesh_->status(hnd_).bits() & skip_bits_))
00396 hnd_.__increment();
00397 }
00398
00399
00400 void skip_bwd()
00401 {
00402 assert(mesh_ && skip_bits_);
00403 while ((hnd_.idx() >= 0) &&
00404 (mesh_->status(hnd_).bits() & skip_bits_))
00405 hnd_.__decrement();
00406 }
00407
00408
00409
00410 private:
00411 mesh_ptr mesh_;
00412 value_handle hnd_;
00413 unsigned int skip_bits_;
00414 };
00415
00416
00417
00418
00419
00424 template <class Mesh>
00425 class HalfedgeIterT
00426 {
00427 public:
00428
00429
00430
00431
00432 typedef typename Mesh::Halfedge value_type;
00433 typedef typename Mesh::HalfedgeHandle value_handle;
00434
00435 #if 0
00436 typedef std::bidirectional_iterator_tag iterator_category;
00437 typedef ptrdiff_t difference_type;
00438 typedef const value_type& reference;
00439 typedef const value_type* pointer;
00440 typedef const Mesh* mesh_ptr;
00441 typedef const Mesh& mesh_ref;
00442 #else
00443 typedef std::bidirectional_iterator_tag iterator_category;
00444 typedef ptrdiff_t difference_type;
00445 typedef value_type& reference;
00446 typedef value_type* pointer;
00447 typedef Mesh* mesh_ptr;
00448 typedef Mesh& mesh_ref;
00449 #endif
00450
00451
00452
00453
00455 HalfedgeIterT()
00456 : mesh_(0), skip_bits_(0)
00457 {}
00458
00459
00461 HalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00462 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00463 {
00464 if (_skip) enable_skipping();
00465
00466
00467 if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
00468 }
00469
00470
00472 HalfedgeIterT(const HalfedgeIterT& _rhs)
00473 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00474 {}
00475
00476
00478 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00479 {
00480 mesh_ = _rhs.mesh_;
00481 hnd_ = _rhs.hnd_;
00482 skip_bits_ = _rhs.skip_bits_;
00483 return *this;
00484 }
00485
00486
00487 #if 0
00488
00490 HalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00491 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00492 {}
00493
00494
00496 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00497 {
00498 mesh_ = _rhs.mesh_;
00499 hnd_ = _rhs.hnd_;
00500 skip_bits_ = _rhs.skip_bits_;
00501 return *this;
00502 }
00503
00504 #else
00505 friend class ConstHalfedgeIterT<Mesh>;
00506 #endif
00507
00508
00510 reference operator*() const { return mesh_->deref(hnd_); }
00511
00513 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00514
00516 value_handle handle() const { return hnd_; }
00517
00519 operator value_handle() const { return hnd_; }
00520
00522 bool operator==(const HalfedgeIterT& _rhs) const
00523 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00524
00526 bool operator!=(const HalfedgeIterT& _rhs) const
00527 { return !operator==(_rhs); }
00528
00530 HalfedgeIterT& operator++()
00531 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00532
00534 HalfedgeIterT& operator--()
00535 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00536
00537
00539 void enable_skipping()
00540 {
00541 if (mesh_ && mesh_->has_halfedge_status())
00542 {
00543 Attributes::StatusInfo status;
00544 status.set_deleted(true);
00545 status.set_hidden(true);
00546 skip_bits_ = status.bits();
00547 skip_fwd();
00548 }
00549 else skip_bits_ = 0;
00550 }
00551
00552
00554 void disable_skipping() { skip_bits_ = 0; }
00555
00556
00557
00558 private:
00559
00560 void skip_fwd()
00561 {
00562 assert(mesh_ && skip_bits_);
00563 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00564 (mesh_->status(hnd_).bits() & skip_bits_))
00565 hnd_.__increment();
00566 }
00567
00568
00569 void skip_bwd()
00570 {
00571 assert(mesh_ && skip_bits_);
00572 while ((hnd_.idx() >= 0) &&
00573 (mesh_->status(hnd_).bits() & skip_bits_))
00574 hnd_.__decrement();
00575 }
00576
00577
00578
00579 private:
00580 mesh_ptr mesh_;
00581 value_handle hnd_;
00582 unsigned int skip_bits_;
00583 };
00584
00585
00586
00587
00588
00593 template <class Mesh>
00594 class ConstHalfedgeIterT
00595 {
00596 public:
00597
00598
00599
00600
00601 typedef typename Mesh::Halfedge value_type;
00602 typedef typename Mesh::HalfedgeHandle value_handle;
00603
00604 #if 1
00605 typedef std::bidirectional_iterator_tag iterator_category;
00606 typedef ptrdiff_t difference_type;
00607 typedef const value_type& reference;
00608 typedef const value_type* pointer;
00609 typedef const Mesh* mesh_ptr;
00610 typedef const Mesh& mesh_ref;
00611 #else
00612 typedef std::bidirectional_iterator_tag iterator_category;
00613 typedef ptrdiff_t difference_type;
00614 typedef value_type& reference;
00615 typedef value_type* pointer;
00616 typedef Mesh* mesh_ptr;
00617 typedef Mesh& mesh_ref;
00618 #endif
00619
00620
00621
00622
00624 ConstHalfedgeIterT()
00625 : mesh_(0), skip_bits_(0)
00626 {}
00627
00628
00630 ConstHalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00631 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00632 {
00633 if (_skip) enable_skipping();
00634
00635
00636 if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
00637 }
00638
00639
00641 ConstHalfedgeIterT(const ConstHalfedgeIterT& _rhs)
00642 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00643 {}
00644
00645
00647 ConstHalfedgeIterT& operator=(const ConstHalfedgeIterT<Mesh>& _rhs)
00648 {
00649 mesh_ = _rhs.mesh_;
00650 hnd_ = _rhs.hnd_;
00651 skip_bits_ = _rhs.skip_bits_;
00652 return *this;
00653 }
00654
00655
00656 #if 1
00657
00659 ConstHalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00660 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00661 {}
00662
00663
00665 ConstHalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00666 {
00667 mesh_ = _rhs.mesh_;
00668 hnd_ = _rhs.hnd_;
00669 skip_bits_ = _rhs.skip_bits_;
00670 return *this;
00671 }
00672
00673 #else
00674 friend class ConstHalfedgeIterT<Mesh>;
00675 #endif
00676
00677
00679 reference operator*() const { return mesh_->deref(hnd_); }
00680
00682 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00683
00685 value_handle handle() const { return hnd_; }
00686
00688 operator value_handle() const { return hnd_; }
00689
00691 bool operator==(const ConstHalfedgeIterT& _rhs) const
00692 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00693
00695 bool operator!=(const ConstHalfedgeIterT& _rhs) const
00696 { return !operator==(_rhs); }
00697
00699 ConstHalfedgeIterT& operator++()
00700 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00701
00703 ConstHalfedgeIterT& operator--()
00704 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00705
00706
00708 void enable_skipping()
00709 {
00710 if (mesh_ && mesh_->has_halfedge_status())
00711 {
00712 Attributes::StatusInfo status;
00713 status.set_deleted(true);
00714 status.set_hidden(true);
00715 skip_bits_ = status.bits();
00716 skip_fwd();
00717 }
00718 else skip_bits_ = 0;
00719 }
00720
00721
00723 void disable_skipping() { skip_bits_ = 0; }
00724
00725
00726
00727 private:
00728
00729 void skip_fwd()
00730 {
00731 assert(mesh_ && skip_bits_);
00732 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00733 (mesh_->status(hnd_).bits() & skip_bits_))
00734 hnd_.__increment();
00735 }
00736
00737
00738 void skip_bwd()
00739 {
00740 assert(mesh_ && skip_bits_);
00741 while ((hnd_.idx() >= 0) &&
00742 (mesh_->status(hnd_).bits() & skip_bits_))
00743 hnd_.__decrement();
00744 }
00745
00746
00747
00748 private:
00749 mesh_ptr mesh_;
00750 value_handle hnd_;
00751 unsigned int skip_bits_;
00752 };
00753
00754
00755
00756
00757
00762 template <class Mesh>
00763 class EdgeIterT
00764 {
00765 public:
00766
00767
00768
00769
00770 typedef typename Mesh::Edge value_type;
00771 typedef typename Mesh::EdgeHandle value_handle;
00772
00773 #if 0
00774 typedef std::bidirectional_iterator_tag iterator_category;
00775 typedef ptrdiff_t difference_type;
00776 typedef const value_type& reference;
00777 typedef const value_type* pointer;
00778 typedef const Mesh* mesh_ptr;
00779 typedef const Mesh& mesh_ref;
00780 #else
00781 typedef std::bidirectional_iterator_tag iterator_category;
00782 typedef ptrdiff_t difference_type;
00783 typedef value_type& reference;
00784 typedef value_type* pointer;
00785 typedef Mesh* mesh_ptr;
00786 typedef Mesh& mesh_ref;
00787 #endif
00788
00789
00790
00791
00793 EdgeIterT()
00794 : mesh_(0), skip_bits_(0)
00795 {}
00796
00797
00799 EdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00800 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00801 {
00802 if (_skip) enable_skipping();
00803
00804
00805 if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
00806 }
00807
00808
00810 EdgeIterT(const EdgeIterT& _rhs)
00811 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00812 {}
00813
00814
00816 EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00817 {
00818 mesh_ = _rhs.mesh_;
00819 hnd_ = _rhs.hnd_;
00820 skip_bits_ = _rhs.skip_bits_;
00821 return *this;
00822 }
00823
00824
00825 #if 0
00826
00828 EdgeIterT(const EdgeIterT<Mesh>& _rhs)
00829 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00830 {}
00831
00832
00834 EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00835 {
00836 mesh_ = _rhs.mesh_;
00837 hnd_ = _rhs.hnd_;
00838 skip_bits_ = _rhs.skip_bits_;
00839 return *this;
00840 }
00841
00842 #else
00843 friend class ConstEdgeIterT<Mesh>;
00844 #endif
00845
00846
00848 reference operator*() const { return mesh_->deref(hnd_); }
00849
00851 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00852
00854 value_handle handle() const { return hnd_; }
00855
00857 operator value_handle() const { return hnd_; }
00858
00860 bool operator==(const EdgeIterT& _rhs) const
00861 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00862
00864 bool operator!=(const EdgeIterT& _rhs) const
00865 { return !operator==(_rhs); }
00866
00868 EdgeIterT& operator++()
00869 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00870
00872 EdgeIterT& operator--()
00873 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00874
00875
00877 void enable_skipping()
00878 {
00879 if (mesh_ && mesh_->has_edge_status())
00880 {
00881 Attributes::StatusInfo status;
00882 status.set_deleted(true);
00883 status.set_hidden(true);
00884 skip_bits_ = status.bits();
00885 skip_fwd();
00886 }
00887 else skip_bits_ = 0;
00888 }
00889
00890
00892 void disable_skipping() { skip_bits_ = 0; }
00893
00894
00895
00896 private:
00897
00898 void skip_fwd()
00899 {
00900 assert(mesh_ && skip_bits_);
00901 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
00902 (mesh_->status(hnd_).bits() & skip_bits_))
00903 hnd_.__increment();
00904 }
00905
00906
00907 void skip_bwd()
00908 {
00909 assert(mesh_ && skip_bits_);
00910 while ((hnd_.idx() >= 0) &&
00911 (mesh_->status(hnd_).bits() & skip_bits_))
00912 hnd_.__decrement();
00913 }
00914
00915
00916
00917 private:
00918 mesh_ptr mesh_;
00919 value_handle hnd_;
00920 unsigned int skip_bits_;
00921 };
00922
00923
00924
00925
00926
00931 template <class Mesh>
00932 class ConstEdgeIterT
00933 {
00934 public:
00935
00936
00937
00938
00939 typedef typename Mesh::Edge value_type;
00940 typedef typename Mesh::EdgeHandle value_handle;
00941
00942 #if 1
00943 typedef std::bidirectional_iterator_tag iterator_category;
00944 typedef ptrdiff_t difference_type;
00945 typedef const value_type& reference;
00946 typedef const value_type* pointer;
00947 typedef const Mesh* mesh_ptr;
00948 typedef const Mesh& mesh_ref;
00949 #else
00950 typedef std::bidirectional_iterator_tag iterator_category;
00951 typedef ptrdiff_t difference_type;
00952 typedef value_type& reference;
00953 typedef value_type* pointer;
00954 typedef Mesh* mesh_ptr;
00955 typedef Mesh& mesh_ref;
00956 #endif
00957
00958
00959
00960
00962 ConstEdgeIterT()
00963 : mesh_(0), skip_bits_(0)
00964 {}
00965
00966
00968 ConstEdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00969 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00970 {
00971 if (_skip) enable_skipping();
00972
00973
00974 if(_mesh.n_edges() == 0) hnd_ = value_handle(-1);
00975 }
00976
00977
00979 ConstEdgeIterT(const ConstEdgeIterT& _rhs)
00980 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00981 {}
00982
00983
00985 ConstEdgeIterT& operator=(const ConstEdgeIterT<Mesh>& _rhs)
00986 {
00987 mesh_ = _rhs.mesh_;
00988 hnd_ = _rhs.hnd_;
00989 skip_bits_ = _rhs.skip_bits_;
00990 return *this;
00991 }
00992
00993
00994 #if 1
00995
00997 ConstEdgeIterT(const EdgeIterT<Mesh>& _rhs)
00998 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00999 {}
01000
01001
01003 ConstEdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
01004 {
01005 mesh_ = _rhs.mesh_;
01006 hnd_ = _rhs.hnd_;
01007 skip_bits_ = _rhs.skip_bits_;
01008 return *this;
01009 }
01010
01011 #else
01012 friend class ConstEdgeIterT<Mesh>;
01013 #endif
01014
01015
01017 reference operator*() const { return mesh_->deref(hnd_); }
01018
01020 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01021
01023 value_handle handle() const { return hnd_; }
01024
01026 operator value_handle() const { return hnd_; }
01027
01029 bool operator==(const ConstEdgeIterT& _rhs) const
01030 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01031
01033 bool operator!=(const ConstEdgeIterT& _rhs) const
01034 { return !operator==(_rhs); }
01035
01037 ConstEdgeIterT& operator++()
01038 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01039
01041 ConstEdgeIterT& operator--()
01042 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01043
01044
01046 void enable_skipping()
01047 {
01048 if (mesh_ && mesh_->has_edge_status())
01049 {
01050 Attributes::StatusInfo status;
01051 status.set_deleted(true);
01052 status.set_hidden(true);
01053 skip_bits_ = status.bits();
01054 skip_fwd();
01055 }
01056 else skip_bits_ = 0;
01057 }
01058
01059
01061 void disable_skipping() { skip_bits_ = 0; }
01062
01063
01064
01065 private:
01066
01067 void skip_fwd()
01068 {
01069 assert(mesh_ && skip_bits_);
01070 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
01071 (mesh_->status(hnd_).bits() & skip_bits_))
01072 hnd_.__increment();
01073 }
01074
01075
01076 void skip_bwd()
01077 {
01078 assert(mesh_ && skip_bits_);
01079 while ((hnd_.idx() >= 0) &&
01080 (mesh_->status(hnd_).bits() & skip_bits_))
01081 hnd_.__decrement();
01082 }
01083
01084
01085
01086 private:
01087 mesh_ptr mesh_;
01088 value_handle hnd_;
01089 unsigned int skip_bits_;
01090 };
01091
01092
01093
01094
01095
01100 template <class Mesh>
01101 class FaceIterT
01102 {
01103 public:
01104
01105
01106
01107
01108 typedef typename Mesh::Face value_type;
01109 typedef typename Mesh::FaceHandle value_handle;
01110
01111 #if 0
01112 typedef std::bidirectional_iterator_tag iterator_category;
01113 typedef ptrdiff_t difference_type;
01114 typedef const value_type& reference;
01115 typedef const value_type* pointer;
01116 typedef const Mesh* mesh_ptr;
01117 typedef const Mesh& mesh_ref;
01118 #else
01119 typedef std::bidirectional_iterator_tag iterator_category;
01120 typedef ptrdiff_t difference_type;
01121 typedef value_type& reference;
01122 typedef value_type* pointer;
01123 typedef Mesh* mesh_ptr;
01124 typedef Mesh& mesh_ref;
01125 #endif
01126
01127
01128
01129
01131 FaceIterT()
01132 : mesh_(0), skip_bits_(0)
01133 {}
01134
01135
01137 FaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01138 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01139 {
01140 if (_skip) enable_skipping();
01141
01142
01143 if(_mesh.n_faces() == 0) hnd_ = value_handle(-1);
01144 }
01145
01146
01148 FaceIterT(const FaceIterT& _rhs)
01149 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01150 {}
01151
01152
01154 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01155 {
01156 mesh_ = _rhs.mesh_;
01157 hnd_ = _rhs.hnd_;
01158 skip_bits_ = _rhs.skip_bits_;
01159 return *this;
01160 }
01161
01162
01163 #if 0
01164
01166 FaceIterT(const FaceIterT<Mesh>& _rhs)
01167 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01168 {}
01169
01170
01172 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01173 {
01174 mesh_ = _rhs.mesh_;
01175 hnd_ = _rhs.hnd_;
01176 skip_bits_ = _rhs.skip_bits_;
01177 return *this;
01178 }
01179
01180 #else
01181 friend class ConstFaceIterT<Mesh>;
01182 #endif
01183
01184
01186 reference operator*() const { return mesh_->deref(hnd_); }
01187
01189 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01190
01192 value_handle handle() const { return hnd_; }
01193
01195 operator value_handle() const { return hnd_; }
01196
01198 bool operator==(const FaceIterT& _rhs) const
01199 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01200
01202 bool operator!=(const FaceIterT& _rhs) const
01203 { return !operator==(_rhs); }
01204
01206 FaceIterT& operator++()
01207 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01208
01210 FaceIterT& operator--()
01211 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01212
01213
01215 void enable_skipping()
01216 {
01217 if (mesh_ && mesh_->has_face_status())
01218 {
01219 Attributes::StatusInfo status;
01220 status.set_deleted(true);
01221 status.set_hidden(true);
01222 skip_bits_ = status.bits();
01223 skip_fwd();
01224 }
01225 else skip_bits_ = 0;
01226 }
01227
01228
01230 void disable_skipping() { skip_bits_ = 0; }
01231
01232
01233
01234 private:
01235
01236 void skip_fwd()
01237 {
01238 assert(mesh_ && skip_bits_);
01239 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01240 (mesh_->status(hnd_).bits() & skip_bits_))
01241 hnd_.__increment();
01242 }
01243
01244
01245 void skip_bwd()
01246 {
01247 assert(mesh_ && skip_bits_);
01248 while ((hnd_.idx() >= 0) &&
01249 (mesh_->status(hnd_).bits() & skip_bits_))
01250 hnd_.__decrement();
01251 }
01252
01253
01254
01255 private:
01256 mesh_ptr mesh_;
01257 value_handle hnd_;
01258 unsigned int skip_bits_;
01259 };
01260
01261
01262
01263
01264
01269 template <class Mesh>
01270 class ConstFaceIterT
01271 {
01272 public:
01273
01274
01275
01276
01277 typedef typename Mesh::Face value_type;
01278 typedef typename Mesh::FaceHandle value_handle;
01279
01280 #if 1
01281 typedef std::bidirectional_iterator_tag iterator_category;
01282 typedef ptrdiff_t difference_type;
01283 typedef const value_type& reference;
01284 typedef const value_type* pointer;
01285 typedef const Mesh* mesh_ptr;
01286 typedef const Mesh& mesh_ref;
01287 #else
01288 typedef std::bidirectional_iterator_tag iterator_category;
01289 typedef ptrdiff_t difference_type;
01290 typedef value_type& reference;
01291 typedef value_type* pointer;
01292 typedef Mesh* mesh_ptr;
01293 typedef Mesh& mesh_ref;
01294 #endif
01295
01296
01297
01298
01300 ConstFaceIterT()
01301 : mesh_(0), skip_bits_(0)
01302 {}
01303
01304
01306 ConstFaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01307 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01308 {
01309 if (_skip) enable_skipping();
01310
01311
01312 if(_mesh.n_faces() == 0) hnd_ = value_handle(-1);
01313 }
01314
01315
01317 ConstFaceIterT(const ConstFaceIterT& _rhs)
01318 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01319 {}
01320
01321
01323 ConstFaceIterT& operator=(const ConstFaceIterT<Mesh>& _rhs)
01324 {
01325 mesh_ = _rhs.mesh_;
01326 hnd_ = _rhs.hnd_;
01327 skip_bits_ = _rhs.skip_bits_;
01328 return *this;
01329 }
01330
01331
01332 #if 1
01333
01335 ConstFaceIterT(const FaceIterT<Mesh>& _rhs)
01336 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01337 {}
01338
01339
01341 ConstFaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01342 {
01343 mesh_ = _rhs.mesh_;
01344 hnd_ = _rhs.hnd_;
01345 skip_bits_ = _rhs.skip_bits_;
01346 return *this;
01347 }
01348
01349 #else
01350 friend class ConstFaceIterT<Mesh>;
01351 #endif
01352
01353
01355 reference operator*() const { return mesh_->deref(hnd_); }
01356
01358 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01359
01361 value_handle handle() const { return hnd_; }
01362
01364 operator value_handle() const { return hnd_; }
01365
01367 bool operator==(const ConstFaceIterT& _rhs) const
01368 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01369
01371 bool operator!=(const ConstFaceIterT& _rhs) const
01372 { return !operator==(_rhs); }
01373
01375 ConstFaceIterT& operator++()
01376 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01377
01379 ConstFaceIterT& operator--()
01380 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01381
01382
01384 void enable_skipping()
01385 {
01386 if (mesh_ && mesh_->has_face_status())
01387 {
01388 Attributes::StatusInfo status;
01389 status.set_deleted(true);
01390 status.set_hidden(true);
01391 skip_bits_ = status.bits();
01392 skip_fwd();
01393 }
01394 else skip_bits_ = 0;
01395 }
01396
01397
01399 void disable_skipping() { skip_bits_ = 0; }
01400
01401
01402
01403 private:
01404
01405 void skip_fwd()
01406 {
01407 assert(mesh_ && skip_bits_);
01408 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01409 (mesh_->status(hnd_).bits() & skip_bits_))
01410 hnd_.__increment();
01411 }
01412
01413
01414 void skip_bwd()
01415 {
01416 assert(mesh_ && skip_bits_);
01417 while ((hnd_.idx() >= 0) &&
01418 (mesh_->status(hnd_).bits() & skip_bits_))
01419 hnd_.__decrement();
01420 }
01421
01422
01423
01424 private:
01425 mesh_ptr mesh_;
01426 value_handle hnd_;
01427 unsigned int skip_bits_;
01428 };
01429
01430
01431
01432 }
01433 }
01434
01435 #endif
01436