Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

IteratorsT.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *                                                                           *
00009  *                                License                                    *
00010  *                                                                           *
00011  *  This library is free software; you can redistribute it and/or modify it  *
00012  *  under the terms of the GNU Library General Public License as published   *
00013  *  by the Free Software Foundation, version 2.                              *
00014  *                                                                           *
00015  *  This library is distributed in the hope that it will be useful, but      *
00016  *  WITHOUT ANY WARRANTY; without even the implied warranty of               *
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        *
00018  *  Library General Public License for more details.                         *
00019  *                                                                           *
00020  *  You should have received a copy of the GNU Library General Public        *
00021  *  License along with this library; if not, write to the Free Software      *
00022  *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.                *
00023  *                                                                           *
00024 \*===========================================================================*/
00025 #ifndef OPENMESH_ITERATORS_HH
00026 #define OPENMESH_ITERATORS_HH
00027 //=============================================================================
00028 //
00029 //  Iterators for PolyMesh/TriMesh
00030 //
00031 //=============================================================================
00032 
00033 
00034 
00035 //== INCLUDES =================================================================
00036 
00037 #include <OpenMesh/Core/System/config.hh>
00038 #include <OpenMesh/Core/Attributes/Status.hh>
00039 #include <assert.h>
00040 
00041 
00042 //== NAMESPACES ===============================================================
00043 
00044 namespace OpenMesh {
00045 namespace Iterators {
00046 
00047 
00048 //== FORWARD DECLARATIONS =====================================================
00049 
00050 
00051 template <class Mesh> class VertexIterT;
00052 template <class Mesh> class ConstVertexIterT;
00053 template <class Mesh> class HalfedgeIterT;
00054 template <class Mesh> class ConstHalfedgeIterT;
00055 template <class Mesh> class EdgeIterT;
00056 template <class Mesh> class ConstEdgeIterT;
00057 template <class Mesh> class FaceIterT;
00058 template <class Mesh> class ConstFaceIterT;
00059 
00060 
00061 
00062 
00063 //== CLASS DEFINITION =========================================================
00064 
00065               
00070 template <class Mesh>
00071 class VertexIterT
00072 {
00073 public:
00074   
00075 
00076   //--- Typedefs ---
00077 
00078   typedef typename Mesh::Vertex           value_type;
00079   typedef typename Mesh::VertexHandle         value_handle;
00080 
00081 #if 0
00082   typedef const value_type&    reference;
00083   typedef const value_type*    pointer;
00084   typedef const Mesh*          mesh_ptr;
00085   typedef const Mesh&          mesh_ref;
00086 #else
00087   typedef value_type&          reference;
00088   typedef value_type*          pointer;
00089   typedef Mesh*                mesh_ptr;
00090   typedef Mesh&                mesh_ref;
00091 #endif
00092 
00093 
00094 
00095 
00097   VertexIterT() 
00098     : mesh_(0), skip_bits_(0) 
00099   {}
00100 
00101 
00103   VertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00104     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00105   {
00106     if (_skip) enable_skipping();
00107   }
00108 
00109 
00111   VertexIterT(const VertexIterT& _rhs) 
00112     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00113   {}
00114   
00115 
00117   VertexIterT& operator=(const VertexIterT<Mesh>& _rhs) 
00118   {
00119     mesh_      = _rhs.mesh_;
00120     hnd_       = _rhs.hnd_;
00121     skip_bits_ = _rhs.skip_bits_;
00122     return *this;
00123   }
00124 
00125 
00126 #if 0
00127 
00129   VertexIterT(const VertexIterT<Mesh>& _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 #else
00144   friend class ConstVertexIterT<Mesh>;
00145 #endif
00146 
00147 
00149   reference operator*()  const { return mesh_->deref(hnd_); }
00150   
00152   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00153   
00155   value_handle handle() const { return hnd_; }
00156 
00158   operator value_handle() const { return hnd_; }
00159 
00161   bool operator==(const VertexIterT& _rhs) const 
00162   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00163 
00165   bool operator!=(const VertexIterT& _rhs) const 
00166   { return !operator==(_rhs); }
00167   
00169   VertexIterT& operator++() 
00170   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00171 
00173   VertexIterT& operator--() 
00174   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00175   
00176 
00178   void enable_skipping()
00179   {
00180     if (mesh_ && mesh_->has_vertex_status())
00181     {
00182       Attributes::StatusInfo status;
00183       status.set_deleted(true);
00184       status.set_hidden(true);
00185       skip_bits_ = status.bits();
00186       skip_fwd();
00187     }
00188     else skip_bits_ = 0;
00189   }
00190 
00191 
00193   void disable_skipping() { skip_bits_ = 0; }
00194 
00195 
00196 
00197 private:
00198 
00199   void skip_fwd() 
00200   {
00201     assert(mesh_ && skip_bits_);
00202     while ((hnd_.idx() < (signed) mesh_->n_vertices()) && 
00203            (mesh_->status(hnd_).bits() & skip_bits_))
00204       hnd_.__increment();
00205   }
00206 
00207 
00208   void skip_bwd() 
00209   {
00210     assert(mesh_ && skip_bits_);
00211     while ((hnd_.idx() >= 0) && 
00212            (mesh_->status(hnd_).bits() & skip_bits_))
00213       hnd_.__decrement();
00214   }
00215 
00216 
00217 
00218 private:
00219   mesh_ptr      mesh_;
00220   value_handle  hnd_;
00221   unsigned int  skip_bits_;
00222 };
00223 
00224 
00225 //== CLASS DEFINITION =========================================================
00226 
00227               
00232 template <class Mesh>
00233 class ConstVertexIterT
00234 {
00235 public:
00236   
00237 
00238   //--- Typedefs ---
00239 
00240   typedef typename Mesh::Vertex           value_type;
00241   typedef typename Mesh::VertexHandle         value_handle;
00242 
00243 #if 1
00244   typedef const value_type&    reference;
00245   typedef const value_type*    pointer;
00246   typedef const Mesh*          mesh_ptr;
00247   typedef const Mesh&          mesh_ref;
00248 #else
00249   typedef value_type&          reference;
00250   typedef value_type*          pointer;
00251   typedef Mesh*                mesh_ptr;
00252   typedef Mesh&                mesh_ref;
00253 #endif
00254 
00255 
00256 
00257 
00259   ConstVertexIterT() 
00260     : mesh_(0), skip_bits_(0) 
00261   {}
00262 
00263 
00265   ConstVertexIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00266     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00267   {
00268     if (_skip) enable_skipping();
00269   }
00270 
00271 
00273   ConstVertexIterT(const ConstVertexIterT& _rhs) 
00274     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00275   {}
00276   
00277 
00279   ConstVertexIterT& operator=(const ConstVertexIterT<Mesh>& _rhs) 
00280   {
00281     mesh_      = _rhs.mesh_;
00282     hnd_       = _rhs.hnd_;
00283     skip_bits_ = _rhs.skip_bits_;
00284     return *this;
00285   }
00286 
00287 
00288 #if 1
00289 
00291   ConstVertexIterT(const VertexIterT<Mesh>& _rhs) 
00292     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_) 
00293   {}
00294   
00295 
00297   ConstVertexIterT& operator=(const VertexIterT<Mesh>& _rhs) 
00298   {
00299     mesh_      = _rhs.mesh_;
00300     hnd_       = _rhs.hnd_;
00301     skip_bits_ = _rhs.skip_bits_;
00302     return *this;
00303   }
00304 
00305 #else
00306   friend class ConstVertexIterT<Mesh>;
00307 #endif
00308 
00309 
00311   reference operator*()  const { return mesh_->deref(hnd_); }
00312   
00314   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00315   
00317   value_handle handle() const { return hnd_; }
00318 
00320   operator value_handle() const { return hnd_; }
00321 
00323   bool operator==(const ConstVertexIterT& _rhs) const 
00324   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00325 
00327   bool operator!=(const ConstVertexIterT& _rhs) const 
00328   { return !operator==(_rhs); }
00329   
00331   ConstVertexIterT& operator++() 
00332   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00333 
00335   ConstVertexIterT& operator--() 
00336   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00337   
00338 
00340   void enable_skipping()
00341   {
00342     if (mesh_ && mesh_->has_vertex_status())
00343     {
00344       Attributes::StatusInfo status;
00345       status.set_deleted(true);
00346       status.set_hidden(true);
00347       skip_bits_ = status.bits();
00348       skip_fwd();
00349     }
00350     else skip_bits_ = 0;
00351   }
00352 
00353 
00355   void disable_skipping() { skip_bits_ = 0; }
00356 
00357 
00358 
00359 private:
00360 
00361   void skip_fwd() 
00362   {
00363     assert(mesh_ && skip_bits_);
00364     while ((hnd_.idx() < (signed) mesh_->n_vertices()) && 
00365            (mesh_->status(hnd_).bits() & skip_bits_))
00366       hnd_.__increment();
00367   }
00368 
00369 
00370   void skip_bwd() 
00371   {
00372     assert(mesh_ && skip_bits_);
00373     while ((hnd_.idx() >= 0) && 
00374            (mesh_->status(hnd_).bits() & skip_bits_))
00375       hnd_.__decrement();
00376   }
00377 
00378 
00379 
00380 private:
00381   mesh_ptr      mesh_;
00382   value_handle  hnd_;
00383   unsigned int  skip_bits_;
00384 };
00385 
00386 
00387 //== CLASS DEFINITION =========================================================
00388 
00389               
00394 template <class Mesh>
00395 class HalfedgeIterT
00396 {
00397 public:
00398   
00399 
00400   //--- Typedefs ---
00401 
00402   typedef typename Mesh::Halfedge           value_type;
00403   typedef typename Mesh::HalfedgeHandle         value_handle;
00404 
00405 #if 0
00406   typedef const value_type&    reference;
00407   typedef const value_type*    pointer;
00408   typedef const Mesh*          mesh_ptr;
00409   typedef const Mesh&          mesh_ref;
00410 #else
00411   typedef value_type&          reference;
00412   typedef value_type*          pointer;
00413   typedef Mesh*                mesh_ptr;
00414   typedef Mesh&                mesh_ref;
00415 #endif
00416 
00417 
00418 
00419 
00421   HalfedgeIterT() 
00422     : mesh_(0), skip_bits_(0) 
00423   {}
00424 
00425 
00427   HalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00428     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00429   {
00430     if (_skip) enable_skipping();
00431   }
00432 
00433 
00435   HalfedgeIterT(const HalfedgeIterT& _rhs) 
00436     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00437   {}
00438   
00439 
00441   HalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs) 
00442   {
00443     mesh_      = _rhs.mesh_;
00444     hnd_       = _rhs.hnd_;
00445     skip_bits_ = _rhs.skip_bits_;
00446     return *this;
00447   }
00448 
00449 
00450 #if 0
00451 
00453   HalfedgeIterT(const HalfedgeIterT<Mesh>& _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 #else
00468   friend class ConstHalfedgeIterT<Mesh>;
00469 #endif
00470 
00471 
00473   reference operator*()  const { return mesh_->deref(hnd_); }
00474   
00476   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00477   
00479   value_handle handle() const { return hnd_; }
00480 
00482   operator value_handle() const { return hnd_; }
00483 
00485   bool operator==(const HalfedgeIterT& _rhs) const 
00486   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00487 
00489   bool operator!=(const HalfedgeIterT& _rhs) const 
00490   { return !operator==(_rhs); }
00491   
00493   HalfedgeIterT& operator++() 
00494   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00495 
00497   HalfedgeIterT& operator--() 
00498   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00499   
00500 
00502   void enable_skipping()
00503   {
00504     if (mesh_ && mesh_->has_halfedge_status())
00505     {
00506       Attributes::StatusInfo status;
00507       status.set_deleted(true);
00508       status.set_hidden(true);
00509       skip_bits_ = status.bits();
00510       skip_fwd();
00511     }
00512     else skip_bits_ = 0;
00513   }
00514 
00515 
00517   void disable_skipping() { skip_bits_ = 0; }
00518 
00519 
00520 
00521 private:
00522 
00523   void skip_fwd() 
00524   {
00525     assert(mesh_ && skip_bits_);
00526     while ((hnd_.idx() < (signed) mesh_->n_halfedges()) && 
00527            (mesh_->status(hnd_).bits() & skip_bits_))
00528       hnd_.__increment();
00529   }
00530 
00531 
00532   void skip_bwd() 
00533   {
00534     assert(mesh_ && skip_bits_);
00535     while ((hnd_.idx() >= 0) && 
00536            (mesh_->status(hnd_).bits() & skip_bits_))
00537       hnd_.__decrement();
00538   }
00539 
00540 
00541 
00542 private:
00543   mesh_ptr      mesh_;
00544   value_handle  hnd_;
00545   unsigned int  skip_bits_;
00546 };
00547 
00548 
00549 //== CLASS DEFINITION =========================================================
00550 
00551               
00556 template <class Mesh>
00557 class ConstHalfedgeIterT
00558 {
00559 public:
00560   
00561 
00562   //--- Typedefs ---
00563 
00564   typedef typename Mesh::Halfedge           value_type;
00565   typedef typename Mesh::HalfedgeHandle         value_handle;
00566 
00567 #if 1
00568   typedef const value_type&    reference;
00569   typedef const value_type*    pointer;
00570   typedef const Mesh*          mesh_ptr;
00571   typedef const Mesh&          mesh_ref;
00572 #else
00573   typedef value_type&          reference;
00574   typedef value_type*          pointer;
00575   typedef Mesh*                mesh_ptr;
00576   typedef Mesh&                mesh_ref;
00577 #endif
00578 
00579 
00580 
00581 
00583   ConstHalfedgeIterT() 
00584     : mesh_(0), skip_bits_(0) 
00585   {}
00586 
00587 
00589   ConstHalfedgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00590     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00591   {
00592     if (_skip) enable_skipping();
00593   }
00594 
00595 
00597   ConstHalfedgeIterT(const ConstHalfedgeIterT& _rhs) 
00598     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00599   {}
00600   
00601 
00603   ConstHalfedgeIterT& operator=(const ConstHalfedgeIterT<Mesh>& _rhs) 
00604   {
00605     mesh_      = _rhs.mesh_;
00606     hnd_       = _rhs.hnd_;
00607     skip_bits_ = _rhs.skip_bits_;
00608     return *this;
00609   }
00610 
00611 
00612 #if 1
00613 
00615   ConstHalfedgeIterT(const HalfedgeIterT<Mesh>& _rhs) 
00616     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_) 
00617   {}
00618   
00619 
00621   ConstHalfedgeIterT& operator=(const HalfedgeIterT<Mesh>& _rhs) 
00622   {
00623     mesh_      = _rhs.mesh_;
00624     hnd_       = _rhs.hnd_;
00625     skip_bits_ = _rhs.skip_bits_;
00626     return *this;
00627   }
00628 
00629 #else
00630   friend class ConstHalfedgeIterT<Mesh>;
00631 #endif
00632 
00633 
00635   reference operator*()  const { return mesh_->deref(hnd_); }
00636   
00638   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00639   
00641   value_handle handle() const { return hnd_; }
00642 
00644   operator value_handle() const { return hnd_; }
00645 
00647   bool operator==(const ConstHalfedgeIterT& _rhs) const 
00648   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00649 
00651   bool operator!=(const ConstHalfedgeIterT& _rhs) const 
00652   { return !operator==(_rhs); }
00653   
00655   ConstHalfedgeIterT& operator++() 
00656   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00657 
00659   ConstHalfedgeIterT& operator--() 
00660   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00661   
00662 
00664   void enable_skipping()
00665   {
00666     if (mesh_ && mesh_->has_halfedge_status())
00667     {
00668       Attributes::StatusInfo status;
00669       status.set_deleted(true);
00670       status.set_hidden(true);
00671       skip_bits_ = status.bits();
00672       skip_fwd();
00673     }
00674     else skip_bits_ = 0;
00675   }
00676 
00677 
00679   void disable_skipping() { skip_bits_ = 0; }
00680 
00681 
00682 
00683 private:
00684 
00685   void skip_fwd() 
00686   {
00687     assert(mesh_ && skip_bits_);
00688     while ((hnd_.idx() < (signed) mesh_->n_halfedges()) && 
00689            (mesh_->status(hnd_).bits() & skip_bits_))
00690       hnd_.__increment();
00691   }
00692 
00693 
00694   void skip_bwd() 
00695   {
00696     assert(mesh_ && skip_bits_);
00697     while ((hnd_.idx() >= 0) && 
00698            (mesh_->status(hnd_).bits() & skip_bits_))
00699       hnd_.__decrement();
00700   }
00701 
00702 
00703 
00704 private:
00705   mesh_ptr      mesh_;
00706   value_handle  hnd_;
00707   unsigned int  skip_bits_;
00708 };
00709 
00710 
00711 //== CLASS DEFINITION =========================================================
00712 
00713               
00718 template <class Mesh>
00719 class EdgeIterT
00720 {
00721 public:
00722   
00723 
00724   //--- Typedefs ---
00725 
00726   typedef typename Mesh::Edge           value_type;
00727   typedef typename Mesh::EdgeHandle         value_handle;
00728 
00729 #if 0
00730   typedef const value_type&    reference;
00731   typedef const value_type*    pointer;
00732   typedef const Mesh*          mesh_ptr;
00733   typedef const Mesh&          mesh_ref;
00734 #else
00735   typedef value_type&          reference;
00736   typedef value_type*          pointer;
00737   typedef Mesh*                mesh_ptr;
00738   typedef Mesh&                mesh_ref;
00739 #endif
00740 
00741 
00742 
00743 
00745   EdgeIterT() 
00746     : mesh_(0), skip_bits_(0) 
00747   {}
00748 
00749 
00751   EdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00752     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00753   {
00754     if (_skip) enable_skipping();
00755   }
00756 
00757 
00759   EdgeIterT(const EdgeIterT& _rhs) 
00760     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00761   {}
00762   
00763 
00765   EdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs) 
00766   {
00767     mesh_      = _rhs.mesh_;
00768     hnd_       = _rhs.hnd_;
00769     skip_bits_ = _rhs.skip_bits_;
00770     return *this;
00771   }
00772 
00773 
00774 #if 0
00775 
00777   EdgeIterT(const EdgeIterT<Mesh>& _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 #else
00792   friend class ConstEdgeIterT<Mesh>;
00793 #endif
00794 
00795 
00797   reference operator*()  const { return mesh_->deref(hnd_); }
00798   
00800   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00801   
00803   value_handle handle() const { return hnd_; }
00804 
00806   operator value_handle() const { return hnd_; }
00807 
00809   bool operator==(const EdgeIterT& _rhs) const 
00810   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00811 
00813   bool operator!=(const EdgeIterT& _rhs) const 
00814   { return !operator==(_rhs); }
00815   
00817   EdgeIterT& operator++() 
00818   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00819 
00821   EdgeIterT& operator--() 
00822   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00823   
00824 
00826   void enable_skipping()
00827   {
00828     if (mesh_ && mesh_->has_edge_status())
00829     {
00830       Attributes::StatusInfo status;
00831       status.set_deleted(true);
00832       status.set_hidden(true);
00833       skip_bits_ = status.bits();
00834       skip_fwd();
00835     }
00836     else skip_bits_ = 0;
00837   }
00838 
00839 
00841   void disable_skipping() { skip_bits_ = 0; }
00842 
00843 
00844 
00845 private:
00846 
00847   void skip_fwd() 
00848   {
00849     assert(mesh_ && skip_bits_);
00850     while ((hnd_.idx() < (signed) mesh_->n_edges()) && 
00851            (mesh_->status(hnd_).bits() & skip_bits_))
00852       hnd_.__increment();
00853   }
00854 
00855 
00856   void skip_bwd() 
00857   {
00858     assert(mesh_ && skip_bits_);
00859     while ((hnd_.idx() >= 0) && 
00860            (mesh_->status(hnd_).bits() & skip_bits_))
00861       hnd_.__decrement();
00862   }
00863 
00864 
00865 
00866 private:
00867   mesh_ptr      mesh_;
00868   value_handle  hnd_;
00869   unsigned int  skip_bits_;
00870 };
00871 
00872 
00873 //== CLASS DEFINITION =========================================================
00874 
00875               
00880 template <class Mesh>
00881 class ConstEdgeIterT
00882 {
00883 public:
00884   
00885 
00886   //--- Typedefs ---
00887 
00888   typedef typename Mesh::Edge           value_type;
00889   typedef typename Mesh::EdgeHandle         value_handle;
00890 
00891 #if 1
00892   typedef const value_type&    reference;
00893   typedef const value_type*    pointer;
00894   typedef const Mesh*          mesh_ptr;
00895   typedef const Mesh&          mesh_ref;
00896 #else
00897   typedef value_type&          reference;
00898   typedef value_type*          pointer;
00899   typedef Mesh*                mesh_ptr;
00900   typedef Mesh&                mesh_ref;
00901 #endif
00902 
00903 
00904 
00905 
00907   ConstEdgeIterT() 
00908     : mesh_(0), skip_bits_(0) 
00909   {}
00910 
00911 
00913   ConstEdgeIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
00914     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
00915   {
00916     if (_skip) enable_skipping();
00917   }
00918 
00919 
00921   ConstEdgeIterT(const ConstEdgeIterT& _rhs) 
00922     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
00923   {}
00924   
00925 
00927   ConstEdgeIterT& operator=(const ConstEdgeIterT<Mesh>& _rhs) 
00928   {
00929     mesh_      = _rhs.mesh_;
00930     hnd_       = _rhs.hnd_;
00931     skip_bits_ = _rhs.skip_bits_;
00932     return *this;
00933   }
00934 
00935 
00936 #if 1
00937 
00939   ConstEdgeIterT(const EdgeIterT<Mesh>& _rhs) 
00940     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_) 
00941   {}
00942   
00943 
00945   ConstEdgeIterT& operator=(const EdgeIterT<Mesh>& _rhs) 
00946   {
00947     mesh_      = _rhs.mesh_;
00948     hnd_       = _rhs.hnd_;
00949     skip_bits_ = _rhs.skip_bits_;
00950     return *this;
00951   }
00952 
00953 #else
00954   friend class ConstEdgeIterT<Mesh>;
00955 #endif
00956 
00957 
00959   reference operator*()  const { return mesh_->deref(hnd_); }
00960   
00962   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
00963   
00965   value_handle handle() const { return hnd_; }
00966 
00968   operator value_handle() const { return hnd_; }
00969 
00971   bool operator==(const ConstEdgeIterT& _rhs) const 
00972   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
00973 
00975   bool operator!=(const ConstEdgeIterT& _rhs) const 
00976   { return !operator==(_rhs); }
00977   
00979   ConstEdgeIterT& operator++() 
00980   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
00981 
00983   ConstEdgeIterT& operator--() 
00984   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
00985   
00986 
00988   void enable_skipping()
00989   {
00990     if (mesh_ && mesh_->has_edge_status())
00991     {
00992       Attributes::StatusInfo status;
00993       status.set_deleted(true);
00994       status.set_hidden(true);
00995       skip_bits_ = status.bits();
00996       skip_fwd();
00997     }
00998     else skip_bits_ = 0;
00999   }
01000 
01001 
01003   void disable_skipping() { skip_bits_ = 0; }
01004 
01005 
01006 
01007 private:
01008 
01009   void skip_fwd() 
01010   {
01011     assert(mesh_ && skip_bits_);
01012     while ((hnd_.idx() < (signed) mesh_->n_edges()) && 
01013            (mesh_->status(hnd_).bits() & skip_bits_))
01014       hnd_.__increment();
01015   }
01016 
01017 
01018   void skip_bwd() 
01019   {
01020     assert(mesh_ && skip_bits_);
01021     while ((hnd_.idx() >= 0) && 
01022            (mesh_->status(hnd_).bits() & skip_bits_))
01023       hnd_.__decrement();
01024   }
01025 
01026 
01027 
01028 private:
01029   mesh_ptr      mesh_;
01030   value_handle  hnd_;
01031   unsigned int  skip_bits_;
01032 };
01033 
01034 
01035 //== CLASS DEFINITION =========================================================
01036 
01037               
01042 template <class Mesh>
01043 class FaceIterT
01044 {
01045 public:
01046   
01047 
01048   //--- Typedefs ---
01049 
01050   typedef typename Mesh::Face           value_type;
01051   typedef typename Mesh::FaceHandle         value_handle;
01052 
01053 #if 0
01054   typedef const value_type&    reference;
01055   typedef const value_type*    pointer;
01056   typedef const Mesh*          mesh_ptr;
01057   typedef const Mesh&          mesh_ref;
01058 #else
01059   typedef value_type&          reference;
01060   typedef value_type*          pointer;
01061   typedef Mesh*                mesh_ptr;
01062   typedef Mesh&                mesh_ref;
01063 #endif
01064 
01065 
01066 
01067 
01069   FaceIterT() 
01070     : mesh_(0), skip_bits_(0) 
01071   {}
01072 
01073 
01075   FaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
01076     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
01077   {
01078     if (_skip) enable_skipping();
01079   }
01080 
01081 
01083   FaceIterT(const FaceIterT& _rhs) 
01084     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01085   {}
01086   
01087 
01089   FaceIterT& operator=(const FaceIterT<Mesh>& _rhs) 
01090   {
01091     mesh_      = _rhs.mesh_;
01092     hnd_       = _rhs.hnd_;
01093     skip_bits_ = _rhs.skip_bits_;
01094     return *this;
01095   }
01096 
01097 
01098 #if 0
01099 
01101   FaceIterT(const FaceIterT<Mesh>& _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 #else
01116   friend class ConstFaceIterT<Mesh>;
01117 #endif
01118 
01119 
01121   reference operator*()  const { return mesh_->deref(hnd_); }
01122   
01124   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
01125   
01127   value_handle handle() const { return hnd_; }
01128 
01130   operator value_handle() const { return hnd_; }
01131 
01133   bool operator==(const FaceIterT& _rhs) const 
01134   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01135 
01137   bool operator!=(const FaceIterT& _rhs) const 
01138   { return !operator==(_rhs); }
01139   
01141   FaceIterT& operator++() 
01142   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01143 
01145   FaceIterT& operator--() 
01146   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01147   
01148 
01150   void enable_skipping()
01151   {
01152     if (mesh_ && mesh_->has_face_status())
01153     {
01154       Attributes::StatusInfo status;
01155       status.set_deleted(true);
01156       status.set_hidden(true);
01157       skip_bits_ = status.bits();
01158       skip_fwd();
01159     }
01160     else skip_bits_ = 0;
01161   }
01162 
01163 
01165   void disable_skipping() { skip_bits_ = 0; }
01166 
01167 
01168 
01169 private:
01170 
01171   void skip_fwd() 
01172   {
01173     assert(mesh_ && skip_bits_);
01174     while ((hnd_.idx() < (signed) mesh_->n_faces()) && 
01175            (mesh_->status(hnd_).bits() & skip_bits_))
01176       hnd_.__increment();
01177   }
01178 
01179 
01180   void skip_bwd() 
01181   {
01182     assert(mesh_ && skip_bits_);
01183     while ((hnd_.idx() >= 0) && 
01184            (mesh_->status(hnd_).bits() & skip_bits_))
01185       hnd_.__decrement();
01186   }
01187 
01188 
01189 
01190 private:
01191   mesh_ptr      mesh_;
01192   value_handle  hnd_;
01193   unsigned int  skip_bits_;
01194 };
01195 
01196 
01197 //== CLASS DEFINITION =========================================================
01198 
01199               
01204 template <class Mesh>
01205 class ConstFaceIterT
01206 {
01207 public:
01208   
01209 
01210   //--- Typedefs ---
01211 
01212   typedef typename Mesh::Face           value_type;
01213   typedef typename Mesh::FaceHandle         value_handle;
01214 
01215 #if 1
01216   typedef const value_type&    reference;
01217   typedef const value_type*    pointer;
01218   typedef const Mesh*          mesh_ptr;
01219   typedef const Mesh&          mesh_ref;
01220 #else
01221   typedef value_type&          reference;
01222   typedef value_type*          pointer;
01223   typedef Mesh*                mesh_ptr;
01224   typedef Mesh&                mesh_ref;
01225 #endif
01226 
01227 
01228 
01229 
01231   ConstFaceIterT() 
01232     : mesh_(0), skip_bits_(0) 
01233   {}
01234 
01235 
01237   ConstFaceIterT(mesh_ref _mesh, value_handle _hnd, bool _skip=false) 
01238     : mesh_(&_mesh), hnd_(_hnd), skip_bits_(0) 
01239   {
01240     if (_skip) enable_skipping();
01241   }
01242 
01243 
01245   ConstFaceIterT(const ConstFaceIterT& _rhs) 
01246     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_)
01247   {}
01248   
01249 
01251   ConstFaceIterT& operator=(const ConstFaceIterT<Mesh>& _rhs) 
01252   {
01253     mesh_      = _rhs.mesh_;
01254     hnd_       = _rhs.hnd_;
01255     skip_bits_ = _rhs.skip_bits_;
01256     return *this;
01257   }
01258 
01259 
01260 #if 1
01261 
01263   ConstFaceIterT(const FaceIterT<Mesh>& _rhs) 
01264     : mesh_(_rhs.mesh_), hnd_(_rhs.hnd_), skip_bits_(_rhs.skip_bits_) 
01265   {}
01266   
01267 
01269   ConstFaceIterT& operator=(const FaceIterT<Mesh>& _rhs) 
01270   {
01271     mesh_      = _rhs.mesh_;
01272     hnd_       = _rhs.hnd_;
01273     skip_bits_ = _rhs.skip_bits_;
01274     return *this;
01275   }
01276 
01277 #else
01278   friend class ConstFaceIterT<Mesh>;
01279 #endif
01280 
01281 
01283   reference operator*()  const { return mesh_->deref(hnd_); }
01284   
01286   pointer   operator->() const { return &(mesh_->deref(hnd_)); }
01287   
01289   value_handle handle() const { return hnd_; }
01290 
01292   operator value_handle() const { return hnd_; }
01293 
01295   bool operator==(const ConstFaceIterT& _rhs) const 
01296   { return ((mesh_ == _rhs.mesh_) && (hnd_ == _rhs.hnd_)); }
01297 
01299   bool operator!=(const ConstFaceIterT& _rhs) const 
01300   { return !operator==(_rhs); }
01301   
01303   ConstFaceIterT& operator++() 
01304   { hnd_.__increment(); if (skip_bits_) skip_fwd(); return *this; }
01305 
01307   ConstFaceIterT& operator--() 
01308   { hnd_.__decrement(); if (skip_bits_) skip_bwd(); return *this; }
01309   
01310 
01312   void enable_skipping()
01313   {
01314     if (mesh_ && mesh_->has_face_status())
01315     {
01316       Attributes::StatusInfo status;
01317       status.set_deleted(true);
01318       status.set_hidden(true);
01319       skip_bits_ = status.bits();
01320       skip_fwd();
01321     }
01322     else skip_bits_ = 0;
01323   }
01324 
01325 
01327   void disable_skipping() { skip_bits_ = 0; }
01328 
01329 
01330 
01331 private:
01332 
01333   void skip_fwd() 
01334   {
01335     assert(mesh_ && skip_bits_);
01336     while ((hnd_.idx() < (signed) mesh_->n_faces()) && 
01337            (mesh_->status(hnd_).bits() & skip_bits_))
01338       hnd_.__increment();
01339   }
01340 
01341 
01342   void skip_bwd() 
01343   {
01344     assert(mesh_ && skip_bits_);
01345     while ((hnd_.idx() >= 0) && 
01346            (mesh_->status(hnd_).bits() & skip_bits_))
01347       hnd_.__decrement();
01348   }
01349 
01350 
01351 
01352 private:
01353   mesh_ptr      mesh_;
01354   value_handle  hnd_;
01355   unsigned int  skip_bits_;
01356 };
01357 
01358 
01359 //=============================================================================
01360 } // namespace Iterators
01361 } // namespace OpenMesh
01362 //=============================================================================
01363 #endif 
01364 //=============================================================================

acg pic Project OpenMesh, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .