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
00131 VertexIterT(const VertexIterT& _rhs)
00132 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00133 {}
00134
00135
00137 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00138 {
00139 mesh_ = _rhs.mesh_;
00140 hnd_ = _rhs.hnd_;
00141 skip_bits_ = _rhs.skip_bits_;
00142 return *this;
00143 }
00144
00145
00146 #if 0
00147
00149 VertexIterT(const VertexIterT<Mesh>& _rhs)
00150 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00151 {}
00152
00153
00155 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00156 {
00157 mesh_ = _rhs.mesh_;
00158 hnd_ = _rhs.hnd_;
00159 skip_bits_ = _rhs.skip_bits_;
00160 return *this;
00161 }
00162
00163 #else
00164 friend class ConstVertexIterT<Mesh>;
00165 #endif
00166
00167
00169 reference operator*() const { return mesh_->deref(hnd_); }
00170
00172 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00173
00175 value_handle handle() const { return hnd_; }
00176
00178 operator value_handle() const { return hnd_; }
00179
00181 bool operator==(const VertexIterT& _rhs) const
00182 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00183
00185 bool operator!=(const VertexIterT& _rhs) const
00186 { return !operator==(_rhs); }
00187
00189 VertexIterT& operator++()
00190 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00191
00193 VertexIterT& operator--()
00194 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00195
00196
00198 void enable_skipping()
00199 {
00200 if (mesh_ && mesh_->has_vertex_status())
00201 {
00202 Attributes::StatusInfo status;
00203 status.set_deleted(true);
00204 status.set_hidden(true);
00205 skip_bits_ = status.bits();
00206 skip_fwd();
00207 }
00208 else skip_bits_ = 0;
00209 }
00210
00211
00213 void disable_skipping() { skip_bits_ = 0; }
00214
00215
00216
00217 private:
00218
00219 void skip_fwd()
00220 {
00221 assert(mesh_ && skip_bits_);
00222 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00223 (mesh_->status(hnd_).bits() & skip_bits_))
00224 hnd_.__increment();
00225 }
00226
00227
00228 void skip_bwd()
00229 {
00230 assert(mesh_ && skip_bits_);
00231 while ((hnd_.idx() >= 0) &&
00232 (mesh_->status(hnd_).bits() & skip_bits_))
00233 hnd_.__decrement();
00234 }
00235
00236
00237
00238 private:
00239 mesh_ptr mesh_;
00240 value_handle hnd_;
00241 unsigned int skip_bits_;
00242 };
00243
00244
00245
00246
00247
00252 template <class Mesh>
00253 class ConstVertexIterT
00254 {
00255 public:
00256
00257
00258
00259
00260 typedef typename Mesh::Vertex value_type;
00261 typedef typename Mesh::VertexHandle value_handle;
00262
00263 #if 1
00264 typedef std::bidirectional_iterator_tag iterator_category;
00265 typedef ptrdiff_t difference_type;
00266 typedef const value_type& reference;
00267 typedef const value_type* pointer;
00268 typedef const Mesh* mesh_ptr;
00269 typedef const Mesh& mesh_ref;
00270 #else
00271 typedef std::bidirectional_iterator_tag iterator_category;
00272 typedef ptrdiff_t difference_type;
00273 typedef value_type& reference;
00274 typedef value_type* pointer;
00275 typedef Mesh* mesh_ptr;
00276 typedef Mesh& mesh_ref;
00277 #endif
00278
00279
00280
00281
00283 ConstVertexIterT()
00284 : mesh_(0), skip_bits_(0)
00285 {}
00286
00287
00289 ConstVertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00290 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00291 {
00292 if (_skip) enable_skipping();
00293 }
00294
00295
00297 ConstVertexIterT(const ConstVertexIterT& _rhs)
00298 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00299 {}
00300
00301
00303 ConstVertexIterT& operator=(const ConstVertexIterT<Mesh>& _rhs)
00304 {
00305 mesh_ = _rhs.mesh_;
00306 hnd_ = _rhs.hnd_;
00307 skip_bits_ = _rhs.skip_bits_;
00308 return *this;
00309 }
00310
00311
00312 #if 1
00313
00315 ConstVertexIterT(const VertexIterT<Mesh>& _rhs)
00316 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00317 {}
00318
00319
00321 ConstVertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00322 {
00323 mesh_ = _rhs.mesh_;
00324 hnd_ = _rhs.hnd_;
00325 skip_bits_ = _rhs.skip_bits_;
00326 return *this;
00327 }
00328
00329 #else
00330 friend class ConstVertexIterT<Mesh>;
00331 #endif
00332
00333
00335 reference operator*() const { return mesh_->deref(hnd_); }
00336
00338 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00339
00341 value_handle handle() const { return hnd_; }
00342
00344 operator value_handle() const { return hnd_; }
00345
00347 bool operator==(const ConstVertexIterT& _rhs) const
00348 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00349
00351 bool operator!=(const ConstVertexIterT& _rhs) const
00352 { return !operator==(_rhs); }
00353
00355 ConstVertexIterT& operator++()
00356 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00357
00359 ConstVertexIterT& operator--()
00360 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00361
00362
00364 void enable_skipping()
00365 {
00366 if (mesh_ && mesh_->has_vertex_status())
00367 {
00368 Attributes::StatusInfo status;
00369 status.set_deleted(true);
00370 status.set_hidden(true);
00371 skip_bits_ = status.bits();
00372 skip_fwd();
00373 }
00374 else skip_bits_ = 0;
00375 }
00376
00377
00379 void disable_skipping() { skip_bits_ = 0; }
00380
00381
00382
00383 private:
00384
00385 void skip_fwd()
00386 {
00387 assert(mesh_ && skip_bits_);
00388 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00389 (mesh_->status(hnd_).bits() & skip_bits_))
00390 hnd_.__increment();
00391 }
00392
00393
00394 void skip_bwd()
00395 {
00396 assert(mesh_ && skip_bits_);
00397 while ((hnd_.idx() >= 0) &&
00398 (mesh_->status(hnd_).bits() & skip_bits_))
00399 hnd_.__decrement();
00400 }
00401
00402
00403
00404 private:
00405 mesh_ptr mesh_;
00406 value_handle hnd_;
00407 unsigned int skip_bits_;
00408 };
00409
00410
00411
00412
00413
00418 template <class Mesh>
00419 class HalfedgeIterT
00420 {
00421 public:
00422
00423
00424
00425
00426 typedef typename Mesh::Halfedge value_type;
00427 typedef typename Mesh::HalfedgeHandle value_handle;
00428
00429 #if 0
00430 typedef std::bidirectional_iterator_tag iterator_category;
00431 typedef ptrdiff_t difference_type;
00432 typedef const value_type& reference;
00433 typedef const value_type* pointer;
00434 typedef const Mesh* mesh_ptr;
00435 typedef const Mesh& mesh_ref;
00436 #else
00437 typedef std::bidirectional_iterator_tag iterator_category;
00438 typedef ptrdiff_t difference_type;
00439 typedef value_type& reference;
00440 typedef value_type* pointer;
00441 typedef Mesh* mesh_ptr;
00442 typedef Mesh& mesh_ref;
00443 #endif
00444
00445
00446
00447
00449 HalfedgeIterT()
00450 : mesh_(0), skip_bits_(0)
00451 {}
00452
00453
00455 HalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00456 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00457 {
00458 if (_skip) enable_skipping();
00459 }
00460
00461
00463 HalfedgeIterT(const HalfedgeIterT& _rhs)
00464 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00465 {}
00466
00467
00469 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00470 {
00471 mesh_ = _rhs.mesh_;
00472 hnd_ = _rhs.hnd_;
00473 skip_bits_ = _rhs.skip_bits_;
00474 return *this;
00475 }
00476
00477
00478 #if 0
00479
00481 HalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00482 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00483 {}
00484
00485
00487 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00488 {
00489 mesh_ = _rhs.mesh_;
00490 hnd_ = _rhs.hnd_;
00491 skip_bits_ = _rhs.skip_bits_;
00492 return *this;
00493 }
00494
00495 #else
00496 friend class ConstHalfedgeIterT<Mesh>;
00497 #endif
00498
00499
00501 reference operator*() const { return mesh_->deref(hnd_); }
00502
00504 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00505
00507 value_handle handle() const { return hnd_; }
00508
00510 operator value_handle() const { return hnd_; }
00511
00513 bool operator==(const HalfedgeIterT& _rhs) const
00514 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00515
00517 bool operator!=(const HalfedgeIterT& _rhs) const
00518 { return !operator==(_rhs); }
00519
00521 HalfedgeIterT& operator++()
00522 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00523
00525 HalfedgeIterT& operator--()
00526 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00527
00528
00530 void enable_skipping()
00531 {
00532 if (mesh_ && mesh_->has_halfedge_status())
00533 {
00534 Attributes::StatusInfo status;
00535 status.set_deleted(true);
00536 status.set_hidden(true);
00537 skip_bits_ = status.bits();
00538 skip_fwd();
00539 }
00540 else skip_bits_ = 0;
00541 }
00542
00543
00545 void disable_skipping() { skip_bits_ = 0; }
00546
00547
00548
00549 private:
00550
00551 void skip_fwd()
00552 {
00553 assert(mesh_ && skip_bits_);
00554 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00555 (mesh_->status(hnd_).bits() & skip_bits_))
00556 hnd_.__increment();
00557 }
00558
00559
00560 void skip_bwd()
00561 {
00562 assert(mesh_ && skip_bits_);
00563 while ((hnd_.idx() >= 0) &&
00564 (mesh_->status(hnd_).bits() & skip_bits_))
00565 hnd_.__decrement();
00566 }
00567
00568
00569
00570 private:
00571 mesh_ptr mesh_;
00572 value_handle hnd_;
00573 unsigned int skip_bits_;
00574 };
00575
00576
00577
00578
00579
00584 template <class Mesh>
00585 class ConstHalfedgeIterT
00586 {
00587 public:
00588
00589
00590
00591
00592 typedef typename Mesh::Halfedge value_type;
00593 typedef typename Mesh::HalfedgeHandle value_handle;
00594
00595 #if 1
00596 typedef std::bidirectional_iterator_tag iterator_category;
00597 typedef ptrdiff_t difference_type;
00598 typedef const value_type& reference;
00599 typedef const value_type* pointer;
00600 typedef const Mesh* mesh_ptr;
00601 typedef const Mesh& mesh_ref;
00602 #else
00603 typedef std::bidirectional_iterator_tag iterator_category;
00604 typedef ptrdiff_t difference_type;
00605 typedef value_type& reference;
00606 typedef value_type* pointer;
00607 typedef Mesh* mesh_ptr;
00608 typedef Mesh& mesh_ref;
00609 #endif
00610
00611
00612
00613
00615 ConstHalfedgeIterT()
00616 : mesh_(0), skip_bits_(0)
00617 {}
00618
00619
00621 ConstHalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00622 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00623 {
00624 if (_skip) enable_skipping();
00625 }
00626
00627
00629 ConstHalfedgeIterT(const ConstHalfedgeIterT& _rhs)
00630 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00631 {}
00632
00633
00635 ConstHalfedgeIterT& operator=(const ConstHalfedgeIterT<Mesh>& _rhs)
00636 {
00637 mesh_ = _rhs.mesh_;
00638 hnd_ = _rhs.hnd_;
00639 skip_bits_ = _rhs.skip_bits_;
00640 return *this;
00641 }
00642
00643
00644 #if 1
00645
00647 ConstHalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00648 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00649 {}
00650
00651
00653 ConstHalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00654 {
00655 mesh_ = _rhs.mesh_;
00656 hnd_ = _rhs.hnd_;
00657 skip_bits_ = _rhs.skip_bits_;
00658 return *this;
00659 }
00660
00661 #else
00662 friend class ConstHalfedgeIterT<Mesh>;
00663 #endif
00664
00665
00667 reference operator*() const { return mesh_->deref(hnd_); }
00668
00670 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00671
00673 value_handle handle() const { return hnd_; }
00674
00676 operator value_handle() const { return hnd_; }
00677
00679 bool operator==(const ConstHalfedgeIterT& _rhs) const
00680 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00681
00683 bool operator!=(const ConstHalfedgeIterT& _rhs) const
00684 { return !operator==(_rhs); }
00685
00687 ConstHalfedgeIterT& operator++()
00688 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00689
00691 ConstHalfedgeIterT& operator--()
00692 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00693
00694
00696 void enable_skipping()
00697 {
00698 if (mesh_ && mesh_->has_halfedge_status())
00699 {
00700 Attributes::StatusInfo status;
00701 status.set_deleted(true);
00702 status.set_hidden(true);
00703 skip_bits_ = status.bits();
00704 skip_fwd();
00705 }
00706 else skip_bits_ = 0;
00707 }
00708
00709
00711 void disable_skipping() { skip_bits_ = 0; }
00712
00713
00714
00715 private:
00716
00717 void skip_fwd()
00718 {
00719 assert(mesh_ && skip_bits_);
00720 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00721 (mesh_->status(hnd_).bits() & skip_bits_))
00722 hnd_.__increment();
00723 }
00724
00725
00726 void skip_bwd()
00727 {
00728 assert(mesh_ && skip_bits_);
00729 while ((hnd_.idx() >= 0) &&
00730 (mesh_->status(hnd_).bits() & skip_bits_))
00731 hnd_.__decrement();
00732 }
00733
00734
00735
00736 private:
00737 mesh_ptr mesh_;
00738 value_handle hnd_;
00739 unsigned int skip_bits_;
00740 };
00741
00742
00743
00744
00745
00750 template <class Mesh>
00751 class EdgeIterT
00752 {
00753 public:
00754
00755
00756
00757
00758 typedef typename Mesh::Edge value_type;
00759 typedef typename Mesh::EdgeHandle value_handle;
00760
00761 #if 0
00762 typedef std::bidirectional_iterator_tag iterator_category;
00763 typedef ptrdiff_t difference_type;
00764 typedef const value_type& reference;
00765 typedef const value_type* pointer;
00766 typedef const Mesh* mesh_ptr;
00767 typedef const Mesh& mesh_ref;
00768 #else
00769 typedef std::bidirectional_iterator_tag iterator_category;
00770 typedef ptrdiff_t difference_type;
00771 typedef value_type& reference;
00772 typedef value_type* pointer;
00773 typedef Mesh* mesh_ptr;
00774 typedef Mesh& mesh_ref;
00775 #endif
00776
00777
00778
00779
00781 EdgeIterT()
00782 : mesh_(0), skip_bits_(0)
00783 {}
00784
00785
00787 EdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00788 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00789 {
00790 if (_skip) enable_skipping();
00791 }
00792
00793
00795 EdgeIterT(const EdgeIterT& _rhs)
00796 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00797 {}
00798
00799
00801 EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00802 {
00803 mesh_ = _rhs.mesh_;
00804 hnd_ = _rhs.hnd_;
00805 skip_bits_ = _rhs.skip_bits_;
00806 return *this;
00807 }
00808
00809
00810 #if 0
00811
00813 EdgeIterT(const EdgeIterT<Mesh>& _rhs)
00814 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00815 {}
00816
00817
00819 EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00820 {
00821 mesh_ = _rhs.mesh_;
00822 hnd_ = _rhs.hnd_;
00823 skip_bits_ = _rhs.skip_bits_;
00824 return *this;
00825 }
00826
00827 #else
00828 friend class ConstEdgeIterT<Mesh>;
00829 #endif
00830
00831
00833 reference operator*() const { return mesh_->deref(hnd_); }
00834
00836 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00837
00839 value_handle handle() const { return hnd_; }
00840
00842 operator value_handle() const { return hnd_; }
00843
00845 bool operator==(const EdgeIterT& _rhs) const
00846 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00847
00849 bool operator!=(const EdgeIterT& _rhs) const
00850 { return !operator==(_rhs); }
00851
00853 EdgeIterT& operator++()
00854 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00855
00857 EdgeIterT& operator--()
00858 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00859
00860
00862 void enable_skipping()
00863 {
00864 if (mesh_ && mesh_->has_edge_status())
00865 {
00866 Attributes::StatusInfo status;
00867 status.set_deleted(true);
00868 status.set_hidden(true);
00869 skip_bits_ = status.bits();
00870 skip_fwd();
00871 }
00872 else skip_bits_ = 0;
00873 }
00874
00875
00877 void disable_skipping() { skip_bits_ = 0; }
00878
00879
00880
00881 private:
00882
00883 void skip_fwd()
00884 {
00885 assert(mesh_ && skip_bits_);
00886 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
00887 (mesh_->status(hnd_).bits() & skip_bits_))
00888 hnd_.__increment();
00889 }
00890
00891
00892 void skip_bwd()
00893 {
00894 assert(mesh_ && skip_bits_);
00895 while ((hnd_.idx() >= 0) &&
00896 (mesh_->status(hnd_).bits() & skip_bits_))
00897 hnd_.__decrement();
00898 }
00899
00900
00901
00902 private:
00903 mesh_ptr mesh_;
00904 value_handle hnd_;
00905 unsigned int skip_bits_;
00906 };
00907
00908
00909
00910
00911
00916 template <class Mesh>
00917 class ConstEdgeIterT
00918 {
00919 public:
00920
00921
00922
00923
00924 typedef typename Mesh::Edge value_type;
00925 typedef typename Mesh::EdgeHandle value_handle;
00926
00927 #if 1
00928 typedef std::bidirectional_iterator_tag iterator_category;
00929 typedef ptrdiff_t difference_type;
00930 typedef const value_type& reference;
00931 typedef const value_type* pointer;
00932 typedef const Mesh* mesh_ptr;
00933 typedef const Mesh& mesh_ref;
00934 #else
00935 typedef std::bidirectional_iterator_tag iterator_category;
00936 typedef ptrdiff_t difference_type;
00937 typedef value_type& reference;
00938 typedef value_type* pointer;
00939 typedef Mesh* mesh_ptr;
00940 typedef Mesh& mesh_ref;
00941 #endif
00942
00943
00944
00945
00947 ConstEdgeIterT()
00948 : mesh_(0), skip_bits_(0)
00949 {}
00950
00951
00953 ConstEdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00954 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00955 {
00956 if (_skip) enable_skipping();
00957 }
00958
00959
00961 ConstEdgeIterT(const ConstEdgeIterT& _rhs)
00962 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00963 {}
00964
00965
00967 ConstEdgeIterT& operator=(const ConstEdgeIterT<Mesh>& _rhs)
00968 {
00969 mesh_ = _rhs.mesh_;
00970 hnd_ = _rhs.hnd_;
00971 skip_bits_ = _rhs.skip_bits_;
00972 return *this;
00973 }
00974
00975
00976 #if 1
00977
00979 ConstEdgeIterT(const EdgeIterT<Mesh>& _rhs)
00980 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00981 {}
00982
00983
00985 ConstEdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00986 {
00987 mesh_ = _rhs.mesh_;
00988 hnd_ = _rhs.hnd_;
00989 skip_bits_ = _rhs.skip_bits_;
00990 return *this;
00991 }
00992
00993 #else
00994 friend class ConstEdgeIterT<Mesh>;
00995 #endif
00996
00997
00999 reference operator*() const { return mesh_->deref(hnd_); }
01000
01002 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01003
01005 value_handle handle() const { return hnd_; }
01006
01008 operator value_handle() const { return hnd_; }
01009
01011 bool operator==(const ConstEdgeIterT& _rhs) const
01012 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01013
01015 bool operator!=(const ConstEdgeIterT& _rhs) const
01016 { return !operator==(_rhs); }
01017
01019 ConstEdgeIterT& operator++()
01020 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01021
01023 ConstEdgeIterT& operator--()
01024 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01025
01026
01028 void enable_skipping()
01029 {
01030 if (mesh_ && mesh_->has_edge_status())
01031 {
01032 Attributes::StatusInfo status;
01033 status.set_deleted(true);
01034 status.set_hidden(true);
01035 skip_bits_ = status.bits();
01036 skip_fwd();
01037 }
01038 else skip_bits_ = 0;
01039 }
01040
01041
01043 void disable_skipping() { skip_bits_ = 0; }
01044
01045
01046
01047 private:
01048
01049 void skip_fwd()
01050 {
01051 assert(mesh_ && skip_bits_);
01052 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
01053 (mesh_->status(hnd_).bits() & skip_bits_))
01054 hnd_.__increment();
01055 }
01056
01057
01058 void skip_bwd()
01059 {
01060 assert(mesh_ && skip_bits_);
01061 while ((hnd_.idx() >= 0) &&
01062 (mesh_->status(hnd_).bits() & skip_bits_))
01063 hnd_.__decrement();
01064 }
01065
01066
01067
01068 private:
01069 mesh_ptr mesh_;
01070 value_handle hnd_;
01071 unsigned int skip_bits_;
01072 };
01073
01074
01075
01076
01077
01082 template <class Mesh>
01083 class FaceIterT
01084 {
01085 public:
01086
01087
01088
01089
01090 typedef typename Mesh::Face value_type;
01091 typedef typename Mesh::FaceHandle value_handle;
01092
01093 #if 0
01094 typedef std::bidirectional_iterator_tag iterator_category;
01095 typedef ptrdiff_t difference_type;
01096 typedef const value_type& reference;
01097 typedef const value_type* pointer;
01098 typedef const Mesh* mesh_ptr;
01099 typedef const Mesh& mesh_ref;
01100 #else
01101 typedef std::bidirectional_iterator_tag iterator_category;
01102 typedef ptrdiff_t difference_type;
01103 typedef value_type& reference;
01104 typedef value_type* pointer;
01105 typedef Mesh* mesh_ptr;
01106 typedef Mesh& mesh_ref;
01107 #endif
01108
01109
01110
01111
01113 FaceIterT()
01114 : mesh_(0), skip_bits_(0)
01115 {}
01116
01117
01119 FaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01120 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01121 {
01122 if (_skip) enable_skipping();
01123 }
01124
01125
01127 FaceIterT(const FaceIterT& _rhs)
01128 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01129 {}
01130
01131
01133 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01134 {
01135 mesh_ = _rhs.mesh_;
01136 hnd_ = _rhs.hnd_;
01137 skip_bits_ = _rhs.skip_bits_;
01138 return *this;
01139 }
01140
01141
01142 #if 0
01143
01145 FaceIterT(const FaceIterT<Mesh>& _rhs)
01146 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01147 {}
01148
01149
01151 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01152 {
01153 mesh_ = _rhs.mesh_;
01154 hnd_ = _rhs.hnd_;
01155 skip_bits_ = _rhs.skip_bits_;
01156 return *this;
01157 }
01158
01159 #else
01160 friend class ConstFaceIterT<Mesh>;
01161 #endif
01162
01163
01165 reference operator*() const { return mesh_->deref(hnd_); }
01166
01168 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01169
01171 value_handle handle() const { return hnd_; }
01172
01174 operator value_handle() const { return hnd_; }
01175
01177 bool operator==(const FaceIterT& _rhs) const
01178 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01179
01181 bool operator!=(const FaceIterT& _rhs) const
01182 { return !operator==(_rhs); }
01183
01185 FaceIterT& operator++()
01186 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01187
01189 FaceIterT& operator--()
01190 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01191
01192
01194 void enable_skipping()
01195 {
01196 if (mesh_ && mesh_->has_face_status())
01197 {
01198 Attributes::StatusInfo status;
01199 status.set_deleted(true);
01200 status.set_hidden(true);
01201 skip_bits_ = status.bits();
01202 skip_fwd();
01203 }
01204 else skip_bits_ = 0;
01205 }
01206
01207
01209 void disable_skipping() { skip_bits_ = 0; }
01210
01211
01212
01213 private:
01214
01215 void skip_fwd()
01216 {
01217 assert(mesh_ && skip_bits_);
01218 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01219 (mesh_->status(hnd_).bits() & skip_bits_))
01220 hnd_.__increment();
01221 }
01222
01223
01224 void skip_bwd()
01225 {
01226 assert(mesh_ && skip_bits_);
01227 while ((hnd_.idx() >= 0) &&
01228 (mesh_->status(hnd_).bits() & skip_bits_))
01229 hnd_.__decrement();
01230 }
01231
01232
01233
01234 private:
01235 mesh_ptr mesh_;
01236 value_handle hnd_;
01237 unsigned int skip_bits_;
01238 };
01239
01240
01241
01242
01243
01248 template <class Mesh>
01249 class ConstFaceIterT
01250 {
01251 public:
01252
01253
01254
01255
01256 typedef typename Mesh::Face value_type;
01257 typedef typename Mesh::FaceHandle value_handle;
01258
01259 #if 1
01260 typedef std::bidirectional_iterator_tag iterator_category;
01261 typedef ptrdiff_t difference_type;
01262 typedef const value_type& reference;
01263 typedef const value_type* pointer;
01264 typedef const Mesh* mesh_ptr;
01265 typedef const Mesh& mesh_ref;
01266 #else
01267 typedef std::bidirectional_iterator_tag iterator_category;
01268 typedef ptrdiff_t difference_type;
01269 typedef value_type& reference;
01270 typedef value_type* pointer;
01271 typedef Mesh* mesh_ptr;
01272 typedef Mesh& mesh_ref;
01273 #endif
01274
01275
01276
01277
01279 ConstFaceIterT()
01280 : mesh_(0), skip_bits_(0)
01281 {}
01282
01283
01285 ConstFaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01286 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01287 {
01288 if (_skip) enable_skipping();
01289 }
01290
01291
01293 ConstFaceIterT(const ConstFaceIterT& _rhs)
01294 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01295 {}
01296
01297
01299 ConstFaceIterT& operator=(const ConstFaceIterT<Mesh>& _rhs)
01300 {
01301 mesh_ = _rhs.mesh_;
01302 hnd_ = _rhs.hnd_;
01303 skip_bits_ = _rhs.skip_bits_;
01304 return *this;
01305 }
01306
01307
01308 #if 1
01309
01311 ConstFaceIterT(const FaceIterT<Mesh>& _rhs)
01312 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01313 {}
01314
01315
01317 ConstFaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01318 {
01319 mesh_ = _rhs.mesh_;
01320 hnd_ = _rhs.hnd_;
01321 skip_bits_ = _rhs.skip_bits_;
01322 return *this;
01323 }
01324
01325 #else
01326 friend class ConstFaceIterT<Mesh>;
01327 #endif
01328
01329
01331 reference operator*() const { return mesh_->deref(hnd_); }
01332
01334 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01335
01337 value_handle handle() const { return hnd_; }
01338
01340 operator value_handle() const { return hnd_; }
01341
01343 bool operator==(const ConstFaceIterT& _rhs) const
01344 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01345
01347 bool operator!=(const ConstFaceIterT& _rhs) const
01348 { return !operator==(_rhs); }
01349
01351 ConstFaceIterT& operator++()
01352 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01353
01355 ConstFaceIterT& operator--()
01356 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01357
01358
01360 void enable_skipping()
01361 {
01362 if (mesh_ && mesh_->has_face_status())
01363 {
01364 Attributes::StatusInfo status;
01365 status.set_deleted(true);
01366 status.set_hidden(true);
01367 skip_bits_ = status.bits();
01368 skip_fwd();
01369 }
01370 else skip_bits_ = 0;
01371 }
01372
01373
01375 void disable_skipping() { skip_bits_ = 0; }
01376
01377
01378
01379 private:
01380
01381 void skip_fwd()
01382 {
01383 assert(mesh_ && skip_bits_);
01384 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01385 (mesh_->status(hnd_).bits() & skip_bits_))
01386 hnd_.__increment();
01387 }
01388
01389
01390 void skip_bwd()
01391 {
01392 assert(mesh_ && skip_bits_);
01393 while ((hnd_.idx() >= 0) &&
01394 (mesh_->status(hnd_).bits() & skip_bits_))
01395 hnd_.__decrement();
01396 }
01397
01398
01399
01400 private:
01401 mesh_ptr mesh_;
01402 value_handle hnd_;
01403 unsigned int skip_bits_;
01404 };
01405
01406
01407
01408 }
01409 }
01410
01411 #endif
01412