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 const value_type& reference;
00101 typedef const value_type* pointer;
00102 typedef const Mesh* mesh_ptr;
00103 typedef const Mesh& mesh_ref;
00104 #else
00105 typedef value_type& reference;
00106 typedef value_type* pointer;
00107 typedef Mesh* mesh_ptr;
00108 typedef Mesh& mesh_ref;
00109 #endif
00110
00111
00112
00113
00115 VertexIterT()
00116 : mesh_(0), skip_bits_(0)
00117 {}
00118
00119
00121 VertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00122 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00123 {
00124 if (_skip) enable_skipping();
00125 }
00126
00127
00129 VertexIterT(const VertexIterT& _rhs)
00130 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00131 {}
00132
00133
00135 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00136 {
00137 mesh_ = _rhs.mesh_;
00138 hnd_ = _rhs.hnd_;
00139 skip_bits_ = _rhs.skip_bits_;
00140 return *this;
00141 }
00142
00143
00144 #if 0
00145
00147 VertexIterT(const VertexIterT<Mesh>& _rhs)
00148 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00149 {}
00150
00151
00153 VertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00154 {
00155 mesh_ = _rhs.mesh_;
00156 hnd_ = _rhs.hnd_;
00157 skip_bits_ = _rhs.skip_bits_;
00158 return *this;
00159 }
00160
00161 #else
00162 friend class ConstVertexIterT<Mesh>;
00163 #endif
00164
00165
00167 reference operator*() const { return mesh_->deref(hnd_); }
00168
00170 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00171
00173 value_handle handle() const { return hnd_; }
00174
00176 operator value_handle() const { return hnd_; }
00177
00179 bool operator==(const VertexIterT& _rhs) const
00180 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00181
00183 bool operator!=(const VertexIterT& _rhs) const
00184 { return !operator==(_rhs); }
00185
00187 VertexIterT& operator++()
00188 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00189
00191 VertexIterT& operator--()
00192 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00193
00194
00196 void enable_skipping()
00197 {
00198 if (mesh_ && mesh_->has_vertex_status())
00199 {
00200 Attributes::StatusInfo status;
00201 status.set_deleted(true);
00202 status.set_hidden(true);
00203 skip_bits_ = status.bits();
00204 skip_fwd();
00205 }
00206 else skip_bits_ = 0;
00207 }
00208
00209
00211 void disable_skipping() { skip_bits_ = 0; }
00212
00213
00214
00215 private:
00216
00217 void skip_fwd()
00218 {
00219 assert(mesh_ && skip_bits_);
00220 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00221 (mesh_->status(hnd_).bits() & skip_bits_))
00222 hnd_.__increment();
00223 }
00224
00225
00226 void skip_bwd()
00227 {
00228 assert(mesh_ && skip_bits_);
00229 while ((hnd_.idx() >= 0) &&
00230 (mesh_->status(hnd_).bits() & skip_bits_))
00231 hnd_.__decrement();
00232 }
00233
00234
00235
00236 private:
00237 mesh_ptr mesh_;
00238 value_handle hnd_;
00239 unsigned int skip_bits_;
00240 };
00241
00242
00243
00244
00245
00250 template <class Mesh>
00251 class ConstVertexIterT
00252 {
00253 public:
00254
00255
00256
00257
00258 typedef typename Mesh::Vertex value_type;
00259 typedef typename Mesh::VertexHandle value_handle;
00260
00261 #if 1
00262 typedef const value_type& reference;
00263 typedef const value_type* pointer;
00264 typedef const Mesh* mesh_ptr;
00265 typedef const Mesh& mesh_ref;
00266 #else
00267 typedef value_type& reference;
00268 typedef value_type* pointer;
00269 typedef Mesh* mesh_ptr;
00270 typedef Mesh& mesh_ref;
00271 #endif
00272
00273
00274
00275
00277 ConstVertexIterT()
00278 : mesh_(0), skip_bits_(0)
00279 {}
00280
00281
00283 ConstVertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00284 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00285 {
00286 if (_skip) enable_skipping();
00287 }
00288
00289
00291 ConstVertexIterT(const ConstVertexIterT& _rhs)
00292 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00293 {}
00294
00295
00297 ConstVertexIterT& operator=(const ConstVertexIterT<Mesh>& _rhs)
00298 {
00299 mesh_ = _rhs.mesh_;
00300 hnd_ = _rhs.hnd_;
00301 skip_bits_ = _rhs.skip_bits_;
00302 return *this;
00303 }
00304
00305
00306 #if 1
00307
00309 ConstVertexIterT(const VertexIterT<Mesh>& _rhs)
00310 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00311 {}
00312
00313
00315 ConstVertexIterT& operator=(const VertexIterT<Mesh>& _rhs)
00316 {
00317 mesh_ = _rhs.mesh_;
00318 hnd_ = _rhs.hnd_;
00319 skip_bits_ = _rhs.skip_bits_;
00320 return *this;
00321 }
00322
00323 #else
00324 friend class ConstVertexIterT<Mesh>;
00325 #endif
00326
00327
00329 reference operator*() const { return mesh_->deref(hnd_); }
00330
00332 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00333
00335 value_handle handle() const { return hnd_; }
00336
00338 operator value_handle() const { return hnd_; }
00339
00341 bool operator==(const ConstVertexIterT& _rhs) const
00342 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00343
00345 bool operator!=(const ConstVertexIterT& _rhs) const
00346 { return !operator==(_rhs); }
00347
00349 ConstVertexIterT& operator++()
00350 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00351
00353 ConstVertexIterT& operator--()
00354 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00355
00356
00358 void enable_skipping()
00359 {
00360 if (mesh_ && mesh_->has_vertex_status())
00361 {
00362 Attributes::StatusInfo status;
00363 status.set_deleted(true);
00364 status.set_hidden(true);
00365 skip_bits_ = status.bits();
00366 skip_fwd();
00367 }
00368 else skip_bits_ = 0;
00369 }
00370
00371
00373 void disable_skipping() { skip_bits_ = 0; }
00374
00375
00376
00377 private:
00378
00379 void skip_fwd()
00380 {
00381 assert(mesh_ && skip_bits_);
00382 while ((hnd_.idx() < (signed) mesh_->n_vertices()) &&
00383 (mesh_->status(hnd_).bits() & skip_bits_))
00384 hnd_.__increment();
00385 }
00386
00387
00388 void skip_bwd()
00389 {
00390 assert(mesh_ && skip_bits_);
00391 while ((hnd_.idx() >= 0) &&
00392 (mesh_->status(hnd_).bits() & skip_bits_))
00393 hnd_.__decrement();
00394 }
00395
00396
00397
00398 private:
00399 mesh_ptr mesh_;
00400 value_handle hnd_;
00401 unsigned int skip_bits_;
00402 };
00403
00404
00405
00406
00407
00412 template <class Mesh>
00413 class HalfedgeIterT
00414 {
00415 public:
00416
00417
00418
00419
00420 typedef typename Mesh::Halfedge value_type;
00421 typedef typename Mesh::HalfedgeHandle value_handle;
00422
00423 #if 0
00424 typedef const value_type& reference;
00425 typedef const value_type* pointer;
00426 typedef const Mesh* mesh_ptr;
00427 typedef const Mesh& mesh_ref;
00428 #else
00429 typedef value_type& reference;
00430 typedef value_type* pointer;
00431 typedef Mesh* mesh_ptr;
00432 typedef Mesh& mesh_ref;
00433 #endif
00434
00435
00436
00437
00439 HalfedgeIterT()
00440 : mesh_(0), skip_bits_(0)
00441 {}
00442
00443
00445 HalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00446 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00447 {
00448 if (_skip) enable_skipping();
00449 }
00450
00451
00453 HalfedgeIterT(const HalfedgeIterT& _rhs)
00454 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00455 {}
00456
00457
00459 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00460 {
00461 mesh_ = _rhs.mesh_;
00462 hnd_ = _rhs.hnd_;
00463 skip_bits_ = _rhs.skip_bits_;
00464 return *this;
00465 }
00466
00467
00468 #if 0
00469
00471 HalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00472 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00473 {}
00474
00475
00477 HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00478 {
00479 mesh_ = _rhs.mesh_;
00480 hnd_ = _rhs.hnd_;
00481 skip_bits_ = _rhs.skip_bits_;
00482 return *this;
00483 }
00484
00485 #else
00486 friend class ConstHalfedgeIterT<Mesh>;
00487 #endif
00488
00489
00491 reference operator*() const { return mesh_->deref(hnd_); }
00492
00494 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00495
00497 value_handle handle() const { return hnd_; }
00498
00500 operator value_handle() const { return hnd_; }
00501
00503 bool operator==(const HalfedgeIterT& _rhs) const
00504 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00505
00507 bool operator!=(const HalfedgeIterT& _rhs) const
00508 { return !operator==(_rhs); }
00509
00511 HalfedgeIterT& operator++()
00512 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00513
00515 HalfedgeIterT& operator--()
00516 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00517
00518
00520 void enable_skipping()
00521 {
00522 if (mesh_ && mesh_->has_halfedge_status())
00523 {
00524 Attributes::StatusInfo status;
00525 status.set_deleted(true);
00526 status.set_hidden(true);
00527 skip_bits_ = status.bits();
00528 skip_fwd();
00529 }
00530 else skip_bits_ = 0;
00531 }
00532
00533
00535 void disable_skipping() { skip_bits_ = 0; }
00536
00537
00538
00539 private:
00540
00541 void skip_fwd()
00542 {
00543 assert(mesh_ && skip_bits_);
00544 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00545 (mesh_->status(hnd_).bits() & skip_bits_))
00546 hnd_.__increment();
00547 }
00548
00549
00550 void skip_bwd()
00551 {
00552 assert(mesh_ && skip_bits_);
00553 while ((hnd_.idx() >= 0) &&
00554 (mesh_->status(hnd_).bits() & skip_bits_))
00555 hnd_.__decrement();
00556 }
00557
00558
00559
00560 private:
00561 mesh_ptr mesh_;
00562 value_handle hnd_;
00563 unsigned int skip_bits_;
00564 };
00565
00566
00567
00568
00569
00574 template <class Mesh>
00575 class ConstHalfedgeIterT
00576 {
00577 public:
00578
00579
00580
00581
00582 typedef typename Mesh::Halfedge value_type;
00583 typedef typename Mesh::HalfedgeHandle value_handle;
00584
00585 #if 1
00586 typedef const value_type& reference;
00587 typedef const value_type* pointer;
00588 typedef const Mesh* mesh_ptr;
00589 typedef const Mesh& mesh_ref;
00590 #else
00591 typedef value_type& reference;
00592 typedef value_type* pointer;
00593 typedef Mesh* mesh_ptr;
00594 typedef Mesh& mesh_ref;
00595 #endif
00596
00597
00598
00599
00601 ConstHalfedgeIterT()
00602 : mesh_(0), skip_bits_(0)
00603 {}
00604
00605
00607 ConstHalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00608 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00609 {
00610 if (_skip) enable_skipping();
00611 }
00612
00613
00615 ConstHalfedgeIterT(const ConstHalfedgeIterT& _rhs)
00616 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00617 {}
00618
00619
00621 ConstHalfedgeIterT& operator=(const ConstHalfedgeIterT<Mesh>& _rhs)
00622 {
00623 mesh_ = _rhs.mesh_;
00624 hnd_ = _rhs.hnd_;
00625 skip_bits_ = _rhs.skip_bits_;
00626 return *this;
00627 }
00628
00629
00630 #if 1
00631
00633 ConstHalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs)
00634 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00635 {}
00636
00637
00639 ConstHalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs)
00640 {
00641 mesh_ = _rhs.mesh_;
00642 hnd_ = _rhs.hnd_;
00643 skip_bits_ = _rhs.skip_bits_;
00644 return *this;
00645 }
00646
00647 #else
00648 friend class ConstHalfedgeIterT<Mesh>;
00649 #endif
00650
00651
00653 reference operator*() const { return mesh_->deref(hnd_); }
00654
00656 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00657
00659 value_handle handle() const { return hnd_; }
00660
00662 operator value_handle() const { return hnd_; }
00663
00665 bool operator==(const ConstHalfedgeIterT& _rhs) const
00666 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00667
00669 bool operator!=(const ConstHalfedgeIterT& _rhs) const
00670 { return !operator==(_rhs); }
00671
00673 ConstHalfedgeIterT& operator++()
00674 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00675
00677 ConstHalfedgeIterT& operator--()
00678 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00679
00680
00682 void enable_skipping()
00683 {
00684 if (mesh_ && mesh_->has_halfedge_status())
00685 {
00686 Attributes::StatusInfo status;
00687 status.set_deleted(true);
00688 status.set_hidden(true);
00689 skip_bits_ = status.bits();
00690 skip_fwd();
00691 }
00692 else skip_bits_ = 0;
00693 }
00694
00695
00697 void disable_skipping() { skip_bits_ = 0; }
00698
00699
00700
00701 private:
00702
00703 void skip_fwd()
00704 {
00705 assert(mesh_ && skip_bits_);
00706 while ((hnd_.idx() < (signed) mesh_->n_halfedges()) &&
00707 (mesh_->status(hnd_).bits() & skip_bits_))
00708 hnd_.__increment();
00709 }
00710
00711
00712 void skip_bwd()
00713 {
00714 assert(mesh_ && skip_bits_);
00715 while ((hnd_.idx() >= 0) &&
00716 (mesh_->status(hnd_).bits() & skip_bits_))
00717 hnd_.__decrement();
00718 }
00719
00720
00721
00722 private:
00723 mesh_ptr mesh_;
00724 value_handle hnd_;
00725 unsigned int skip_bits_;
00726 };
00727
00728
00729
00730
00731
00736 template <class Mesh>
00737 class EdgeIterT
00738 {
00739 public:
00740
00741
00742
00743
00744 typedef typename Mesh::Edge value_type;
00745 typedef typename Mesh::EdgeHandle value_handle;
00746
00747 #if 0
00748 typedef const value_type& reference;
00749 typedef const value_type* pointer;
00750 typedef const Mesh* mesh_ptr;
00751 typedef const Mesh& mesh_ref;
00752 #else
00753 typedef value_type& reference;
00754 typedef value_type* pointer;
00755 typedef Mesh* mesh_ptr;
00756 typedef Mesh& mesh_ref;
00757 #endif
00758
00759
00760
00761
00763 EdgeIterT()
00764 : mesh_(0), skip_bits_(0)
00765 {}
00766
00767
00769 EdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00770 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00771 {
00772 if (_skip) enable_skipping();
00773 }
00774
00775
00777 EdgeIterT(const EdgeIterT& _rhs)
00778 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00779 {}
00780
00781
00783 EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00784 {
00785 mesh_ = _rhs.mesh_;
00786 hnd_ = _rhs.hnd_;
00787 skip_bits_ = _rhs.skip_bits_;
00788 return *this;
00789 }
00790
00791
00792 #if 0
00793
00795 EdgeIterT(const EdgeIterT<Mesh>& _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 #else
00810 friend class ConstEdgeIterT<Mesh>;
00811 #endif
00812
00813
00815 reference operator*() const { return mesh_->deref(hnd_); }
00816
00818 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00819
00821 value_handle handle() const { return hnd_; }
00822
00824 operator value_handle() const { return hnd_; }
00825
00827 bool operator==(const EdgeIterT& _rhs) const
00828 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00829
00831 bool operator!=(const EdgeIterT& _rhs) const
00832 { return !operator==(_rhs); }
00833
00835 EdgeIterT& operator++()
00836 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00837
00839 EdgeIterT& operator--()
00840 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00841
00842
00844 void enable_skipping()
00845 {
00846 if (mesh_ && mesh_->has_edge_status())
00847 {
00848 Attributes::StatusInfo status;
00849 status.set_deleted(true);
00850 status.set_hidden(true);
00851 skip_bits_ = status.bits();
00852 skip_fwd();
00853 }
00854 else skip_bits_ = 0;
00855 }
00856
00857
00859 void disable_skipping() { skip_bits_ = 0; }
00860
00861
00862
00863 private:
00864
00865 void skip_fwd()
00866 {
00867 assert(mesh_ && skip_bits_);
00868 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
00869 (mesh_->status(hnd_).bits() & skip_bits_))
00870 hnd_.__increment();
00871 }
00872
00873
00874 void skip_bwd()
00875 {
00876 assert(mesh_ && skip_bits_);
00877 while ((hnd_.idx() >= 0) &&
00878 (mesh_->status(hnd_).bits() & skip_bits_))
00879 hnd_.__decrement();
00880 }
00881
00882
00883
00884 private:
00885 mesh_ptr mesh_;
00886 value_handle hnd_;
00887 unsigned int skip_bits_;
00888 };
00889
00890
00891
00892
00893
00898 template <class Mesh>
00899 class ConstEdgeIterT
00900 {
00901 public:
00902
00903
00904
00905
00906 typedef typename Mesh::Edge value_type;
00907 typedef typename Mesh::EdgeHandle value_handle;
00908
00909 #if 1
00910 typedef const value_type& reference;
00911 typedef const value_type* pointer;
00912 typedef const Mesh* mesh_ptr;
00913 typedef const Mesh& mesh_ref;
00914 #else
00915 typedef value_type& reference;
00916 typedef value_type* pointer;
00917 typedef Mesh* mesh_ptr;
00918 typedef Mesh& mesh_ref;
00919 #endif
00920
00921
00922
00923
00925 ConstEdgeIterT()
00926 : mesh_(0), skip_bits_(0)
00927 {}
00928
00929
00931 ConstEdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
00932 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
00933 {
00934 if (_skip) enable_skipping();
00935 }
00936
00937
00939 ConstEdgeIterT(const ConstEdgeIterT& _rhs)
00940 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00941 {}
00942
00943
00945 ConstEdgeIterT& operator=(const ConstEdgeIterT<Mesh>& _rhs)
00946 {
00947 mesh_ = _rhs.mesh_;
00948 hnd_ = _rhs.hnd_;
00949 skip_bits_ = _rhs.skip_bits_;
00950 return *this;
00951 }
00952
00953
00954 #if 1
00955
00957 ConstEdgeIterT(const EdgeIterT<Mesh>& _rhs)
00958 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00959 {}
00960
00961
00963 ConstEdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs)
00964 {
00965 mesh_ = _rhs.mesh_;
00966 hnd_ = _rhs.hnd_;
00967 skip_bits_ = _rhs.skip_bits_;
00968 return *this;
00969 }
00970
00971 #else
00972 friend class ConstEdgeIterT<Mesh>;
00973 #endif
00974
00975
00977 reference operator*() const { return mesh_->deref(hnd_); }
00978
00980 pointer operator->() const { return &(mesh_->deref(hnd_)); }
00981
00983 value_handle handle() const { return hnd_; }
00984
00986 operator value_handle() const { return hnd_; }
00987
00989 bool operator==(const ConstEdgeIterT& _rhs) const
00990 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00991
00993 bool operator!=(const ConstEdgeIterT& _rhs) const
00994 { return !operator==(_rhs); }
00995
00997 ConstEdgeIterT& operator++()
00998 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00999
01001 ConstEdgeIterT& operator--()
01002 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01003
01004
01006 void enable_skipping()
01007 {
01008 if (mesh_ && mesh_->has_edge_status())
01009 {
01010 Attributes::StatusInfo status;
01011 status.set_deleted(true);
01012 status.set_hidden(true);
01013 skip_bits_ = status.bits();
01014 skip_fwd();
01015 }
01016 else skip_bits_ = 0;
01017 }
01018
01019
01021 void disable_skipping() { skip_bits_ = 0; }
01022
01023
01024
01025 private:
01026
01027 void skip_fwd()
01028 {
01029 assert(mesh_ && skip_bits_);
01030 while ((hnd_.idx() < (signed) mesh_->n_edges()) &&
01031 (mesh_->status(hnd_).bits() & skip_bits_))
01032 hnd_.__increment();
01033 }
01034
01035
01036 void skip_bwd()
01037 {
01038 assert(mesh_ && skip_bits_);
01039 while ((hnd_.idx() >= 0) &&
01040 (mesh_->status(hnd_).bits() & skip_bits_))
01041 hnd_.__decrement();
01042 }
01043
01044
01045
01046 private:
01047 mesh_ptr mesh_;
01048 value_handle hnd_;
01049 unsigned int skip_bits_;
01050 };
01051
01052
01053
01054
01055
01060 template <class Mesh>
01061 class FaceIterT
01062 {
01063 public:
01064
01065
01066
01067
01068 typedef typename Mesh::Face value_type;
01069 typedef typename Mesh::FaceHandle value_handle;
01070
01071 #if 0
01072 typedef const value_type& reference;
01073 typedef const value_type* pointer;
01074 typedef const Mesh* mesh_ptr;
01075 typedef const Mesh& mesh_ref;
01076 #else
01077 typedef value_type& reference;
01078 typedef value_type* pointer;
01079 typedef Mesh* mesh_ptr;
01080 typedef Mesh& mesh_ref;
01081 #endif
01082
01083
01084
01085
01087 FaceIterT()
01088 : mesh_(0), skip_bits_(0)
01089 {}
01090
01091
01093 FaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01094 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01095 {
01096 if (_skip) enable_skipping();
01097 }
01098
01099
01101 FaceIterT(const FaceIterT& _rhs)
01102 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01103 {}
01104
01105
01107 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01108 {
01109 mesh_ = _rhs.mesh_;
01110 hnd_ = _rhs.hnd_;
01111 skip_bits_ = _rhs.skip_bits_;
01112 return *this;
01113 }
01114
01115
01116 #if 0
01117
01119 FaceIterT(const FaceIterT<Mesh>& _rhs)
01120 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01121 {}
01122
01123
01125 FaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01126 {
01127 mesh_ = _rhs.mesh_;
01128 hnd_ = _rhs.hnd_;
01129 skip_bits_ = _rhs.skip_bits_;
01130 return *this;
01131 }
01132
01133 #else
01134 friend class ConstFaceIterT<Mesh>;
01135 #endif
01136
01137
01139 reference operator*() const { return mesh_->deref(hnd_); }
01140
01142 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01143
01145 value_handle handle() const { return hnd_; }
01146
01148 operator value_handle() const { return hnd_; }
01149
01151 bool operator==(const FaceIterT& _rhs) const
01152 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01153
01155 bool operator!=(const FaceIterT& _rhs) const
01156 { return !operator==(_rhs); }
01157
01159 FaceIterT& operator++()
01160 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01161
01163 FaceIterT& operator--()
01164 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01165
01166
01168 void enable_skipping()
01169 {
01170 if (mesh_ && mesh_->has_face_status())
01171 {
01172 Attributes::StatusInfo status;
01173 status.set_deleted(true);
01174 status.set_hidden(true);
01175 skip_bits_ = status.bits();
01176 skip_fwd();
01177 }
01178 else skip_bits_ = 0;
01179 }
01180
01181
01183 void disable_skipping() { skip_bits_ = 0; }
01184
01185
01186
01187 private:
01188
01189 void skip_fwd()
01190 {
01191 assert(mesh_ && skip_bits_);
01192 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01193 (mesh_->status(hnd_).bits() & skip_bits_))
01194 hnd_.__increment();
01195 }
01196
01197
01198 void skip_bwd()
01199 {
01200 assert(mesh_ && skip_bits_);
01201 while ((hnd_.idx() >= 0) &&
01202 (mesh_->status(hnd_).bits() & skip_bits_))
01203 hnd_.__decrement();
01204 }
01205
01206
01207
01208 private:
01209 mesh_ptr mesh_;
01210 value_handle hnd_;
01211 unsigned int skip_bits_;
01212 };
01213
01214
01215
01216
01217
01222 template <class Mesh>
01223 class ConstFaceIterT
01224 {
01225 public:
01226
01227
01228
01229
01230 typedef typename Mesh::Face value_type;
01231 typedef typename Mesh::FaceHandle value_handle;
01232
01233 #if 1
01234 typedef const value_type& reference;
01235 typedef const value_type* pointer;
01236 typedef const Mesh* mesh_ptr;
01237 typedef const Mesh& mesh_ref;
01238 #else
01239 typedef value_type& reference;
01240 typedef value_type* pointer;
01241 typedef Mesh* mesh_ptr;
01242 typedef Mesh& mesh_ref;
01243 #endif
01244
01245
01246
01247
01249 ConstFaceIterT()
01250 : mesh_(0), skip_bits_(0)
01251 {}
01252
01253
01255 ConstFaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false)
01256 : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0)
01257 {
01258 if (_skip) enable_skipping();
01259 }
01260
01261
01263 ConstFaceIterT(const ConstFaceIterT& _rhs)
01264 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01265 {}
01266
01267
01269 ConstFaceIterT& operator=(const ConstFaceIterT<Mesh>& _rhs)
01270 {
01271 mesh_ = _rhs.mesh_;
01272 hnd_ = _rhs.hnd_;
01273 skip_bits_ = _rhs.skip_bits_;
01274 return *this;
01275 }
01276
01277
01278 #if 1
01279
01281 ConstFaceIterT(const FaceIterT<Mesh>& _rhs)
01282 : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01283 {}
01284
01285
01287 ConstFaceIterT& operator=(const FaceIterT<Mesh>& _rhs)
01288 {
01289 mesh_ = _rhs.mesh_;
01290 hnd_ = _rhs.hnd_;
01291 skip_bits_ = _rhs.skip_bits_;
01292 return *this;
01293 }
01294
01295 #else
01296 friend class ConstFaceIterT<Mesh>;
01297 #endif
01298
01299
01301 reference operator*() const { return mesh_->deref(hnd_); }
01302
01304 pointer operator->() const { return &(mesh_->deref(hnd_)); }
01305
01307 value_handle handle() const { return hnd_; }
01308
01310 operator value_handle() const { return hnd_; }
01311
01313 bool operator==(const ConstFaceIterT& _rhs) const
01314 { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01315
01317 bool operator!=(const ConstFaceIterT& _rhs) const
01318 { return !operator==(_rhs); }
01319
01321 ConstFaceIterT& operator++()
01322 { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01323
01325 ConstFaceIterT& operator--()
01326 { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01327
01328
01330 void enable_skipping()
01331 {
01332 if (mesh_ && mesh_->has_face_status())
01333 {
01334 Attributes::StatusInfo status;
01335 status.set_deleted(true);
01336 status.set_hidden(true);
01337 skip_bits_ = status.bits();
01338 skip_fwd();
01339 }
01340 else skip_bits_ = 0;
01341 }
01342
01343
01345 void disable_skipping() { skip_bits_ = 0; }
01346
01347
01348
01349 private:
01350
01351 void skip_fwd()
01352 {
01353 assert(mesh_ && skip_bits_);
01354 while ((hnd_.idx() < (signed) mesh_->n_faces()) &&
01355 (mesh_->status(hnd_).bits() & skip_bits_))
01356 hnd_.__increment();
01357 }
01358
01359
01360 void skip_bwd()
01361 {
01362 assert(mesh_ && skip_bits_);
01363 while ((hnd_.idx() >= 0) &&
01364 (mesh_->status(hnd_).bits() & skip_bits_))
01365 hnd_.__decrement();
01366 }
01367
01368
01369
01370 private:
01371 mesh_ptr mesh_;
01372 value_handle hnd_;
01373 unsigned int skip_bits_;
01374 };
01375
01376
01377
01378 }
01379 }
01380
01381 #endif
01382