OpenMesh
OpenMesh/Core/Mesh/CirculatorsT.hh
00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                               OpenMesh                                    *
00004  *      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openmesh.org                                *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------* 
00008  *  This file is part of OpenMesh.                                           *
00009  *                                                                           *
00010  *  OpenMesh is free software: you can redistribute it and/or modify         * 
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenMesh is distributed in the hope that it will be useful,              *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenMesh.  If not,                                    *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/ 
00034 
00035 /*===========================================================================*\
00036  *                                                                           *             
00037  *   $Revision: 424 $                                                         *
00038  *   $Date: 2011-10-10 14:24:43 +0200 (Mo, 10 Okt 2011) $                   *
00039  *                                                                           *
00040 \*===========================================================================*/
00041 
00042 #ifndef OPENMESH_CIRCULATORS_HH
00043 #define OPENMESH_CIRCULATORS_HH
00044 //=============================================================================
00045 //
00046 //  Vertex and Face circulators for PolyMesh/TriMesh
00047 //
00048 //=============================================================================
00049 
00050 
00051 
00052 //== INCLUDES =================================================================
00053 
00054 #include <OpenMesh/Core/System/config.h>
00055 #include <assert.h>
00056 #include <cstddef>
00057 
00058 
00059 //== NAMESPACES ===============================================================
00060 
00061 namespace OpenMesh {
00062 namespace Iterators {
00063 
00064 
00065 //== FORWARD DECLARATIONS =====================================================
00066 
00067 
00068 template <class Mesh> class VertexVertexIterT;
00069 template <class Mesh> class VertexIHalfedgeIterT;
00070 template <class Mesh> class VertexOHalfedgeIterT;
00071 template <class Mesh> class VertexEdgeIterT;
00072 template <class Mesh> class VertexFaceIterT;
00073 
00074 template <class Mesh> class ConstVertexVertexIterT;
00075 template <class Mesh> class ConstVertexIHalfedgeIterT;
00076 template <class Mesh> class ConstVertexOHalfedgeIterT;
00077 template <class Mesh> class ConstVertexEdgeIterT;
00078 template <class Mesh> class ConstVertexFaceIterT;
00079 
00080 template <class Mesh> class FaceVertexIterT;
00081 template <class Mesh> class FaceHalfedgeIterT;
00082 template <class Mesh> class FaceEdgeIterT;
00083 template <class Mesh> class FaceFaceIterT;
00084 
00085 template <class Mesh> class ConstFaceVertexIterT;
00086 template <class Mesh> class ConstFaceHalfedgeIterT;
00087 template <class Mesh> class ConstFaceEdgeIterT;
00088 template <class Mesh> class ConstFaceFaceIterT;
00089 
00090 
00091 
00092 //== CLASS DEFINITION =========================================================
00093 
00094               
00099 template <class Mesh>
00100 class VertexVertexIterT
00101 {
00102  public:
00103 
00104 
00105   //--- Typedefs ---
00106 
00107   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
00108 
00109   typedef typename Mesh::Vertex             value_type;
00110   typedef typename Mesh::VertexHandle       value_handle;
00111 
00112 #if 0
00113   typedef std::bidirectional_iterator_tag   iterator_category;
00114   typedef std::ptrdiff_t                    difference_type;
00115   typedef const Mesh&                       mesh_ref;
00116   typedef const Mesh*                       mesh_ptr;
00117   typedef const typename Mesh::Vertex&      reference;
00118   typedef const typename Mesh::Vertex*      pointer;
00119 #else
00120   typedef std::bidirectional_iterator_tag   iterator_category;
00121   typedef std::ptrdiff_t                    difference_type;
00122   typedef Mesh&                             mesh_ref;
00123   typedef Mesh*                             mesh_ptr;
00124   typedef typename Mesh::Vertex&            reference;
00125   typedef typename Mesh::Vertex*            pointer;
00126 #endif
00127 
00128 
00129 
00131   VertexVertexIterT() : mesh_(0), lap_counter_(0) {}
00132 
00133 
00135   VertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
00136     mesh_(&_mesh), 
00137     start_(_mesh.halfedge_handle(_start)),
00138     heh_(start_),
00139     lap_counter_(_end)
00140   {  ; }
00141 
00142 
00144   VertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
00145     mesh_(&_mesh),
00146     start_(_heh),
00147     heh_(_heh),
00148     lap_counter_(_end)
00149   {  ; }
00150 
00151 
00153   VertexVertexIterT(const VertexVertexIterT& _rhs) :
00154     mesh_(_rhs.mesh_),
00155     start_(_rhs.start_),
00156     heh_(_rhs.heh_),
00157     lap_counter_(_rhs.lap_counter_)
00158   {  ; }
00159 
00160 
00162   VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
00163   {
00164     mesh_   = _rhs.mesh_;
00165     start_  = _rhs.start_;
00166     heh_    = _rhs.heh_;
00167     lap_counter_ = _rhs.lap_counter_;
00168     return *this;
00169   }
00170 
00171 
00172 #if 0
00173 
00174   VertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :
00175     mesh_(_rhs.mesh_),
00176     start_(_rhs.start_),
00177     heh_(_rhs.heh_),
00178     lap_counter_(_rhs.lap_counter_)
00179   {  ; }
00180 
00181 
00183   VertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
00184   {
00185     mesh_   = _rhs.mesh_;
00186     start_  = _rhs.start_;
00187     heh_    = _rhs.heh_;
00188     lap_counter_ = _rhs.lap_counter_;
00189     return *this;
00190   }
00191 #else
00192   friend class ConstVertexVertexIterT<Mesh>;
00193 #endif  
00194 
00195 
00197   bool operator==(const VertexVertexIterT& _rhs) const {
00198     return ((mesh_   == _rhs.mesh_) &&
00199             (start_  == _rhs.start_) &&
00200             (heh_    == _rhs.heh_) &&
00201             (lap_counter_ == _rhs.lap_counter_));
00202   }
00203 
00204 
00206   bool operator!=(const VertexVertexIterT& _rhs) const {
00207     return !operator==(_rhs);
00208   }
00209 
00210 
00212   VertexVertexIterT& operator++() { 
00213     assert(mesh_);
00214     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
00215     if(heh_ == start_) lap_counter_++;
00216     return *this;
00217   }
00218 
00219 
00221   VertexVertexIterT& operator--() { 
00222     assert(mesh_);
00223     if(heh_ == start_) lap_counter_--;
00224     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
00225     return *this;
00226   }
00227 
00228 
00233   HalfedgeHandle current_halfedge_handle() const {
00234     return heh_;
00235   }
00236 
00237 
00239   typename Mesh::VertexHandle handle() const {
00240     assert(mesh_);
00241     return mesh_->to_vertex_handle(heh_);; 
00242   }
00243 
00244 
00246   operator typename Mesh::VertexHandle() const {
00247     assert(mesh_);
00248     return mesh_->to_vertex_handle(heh_);; 
00249   }
00250     
00251 
00253   reference operator*() const { 
00254     assert(mesh_);
00255     return mesh_->deref(handle());
00256   }
00257 
00258 
00260   pointer operator->() const {
00261     assert(mesh_);
00262     return &mesh_->deref(handle());
00263   }
00264 
00265 
00272   operator bool() const {
00273     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
00274   }
00275 
00276 
00277 protected:
00278 
00279   mesh_ptr         mesh_;
00280   HalfedgeHandle   start_, heh_;
00281   int              lap_counter_;
00282 };
00283 
00284 
00285 
00286 //== CLASS DEFINITION =========================================================
00287 
00288               
00293 template <class Mesh>
00294 class ConstVertexVertexIterT
00295 {
00296  public:
00297 
00298 
00299   //--- Typedefs ---
00300 
00301   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
00302 
00303   typedef typename Mesh::Vertex             value_type;
00304   typedef typename Mesh::VertexHandle       value_handle;
00305 
00306 #if 1
00307   typedef std::bidirectional_iterator_tag   iterator_category;
00308   typedef std::ptrdiff_t                    difference_type;
00309   typedef const Mesh&                       mesh_ref;
00310   typedef const Mesh*                       mesh_ptr;
00311   typedef const typename Mesh::Vertex&      reference;
00312   typedef const typename Mesh::Vertex*      pointer;
00313 #else
00314   typedef std::bidirectional_iterator_tag   iterator_category;
00315   typedef std::ptrdiff_t                    difference_type;
00316   typedef Mesh&                             mesh_ref;
00317   typedef Mesh*                             mesh_ptr;
00318   typedef typename Mesh::Vertex&            reference;
00319   typedef typename Mesh::Vertex*            pointer;
00320 #endif
00321 
00322 
00323 
00325   ConstVertexVertexIterT() : mesh_(0), lap_counter_(0) {}
00326 
00327 
00329   ConstVertexVertexIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
00330     mesh_(&_mesh), 
00331     start_(_mesh.halfedge_handle(_start)),
00332     heh_(start_),
00333     lap_counter_(_end)
00334   {  ; }
00335 
00336 
00338   ConstVertexVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
00339     mesh_(&_mesh),
00340     start_(_heh),
00341     heh_(_heh),
00342     lap_counter_(_end)
00343   {  ; }
00344 
00345 
00347   ConstVertexVertexIterT(const ConstVertexVertexIterT& _rhs) :
00348     mesh_(_rhs.mesh_),
00349     start_(_rhs.start_),
00350     heh_(_rhs.heh_),
00351     lap_counter_(_rhs.lap_counter_)
00352   {  ; }
00353 
00354 
00356   ConstVertexVertexIterT& operator=(const ConstVertexVertexIterT<Mesh>& _rhs)
00357   {
00358     mesh_   = _rhs.mesh_;
00359     start_  = _rhs.start_;
00360     heh_    = _rhs.heh_;
00361     lap_counter_ = _rhs.lap_counter_;
00362     return *this;
00363   }
00364 
00365 
00366 #if 1
00367 
00368   ConstVertexVertexIterT(const VertexVertexIterT<Mesh>& _rhs) :
00369     mesh_(_rhs.mesh_),
00370     start_(_rhs.start_),
00371     heh_(_rhs.heh_),
00372     lap_counter_(_rhs.lap_counter_)
00373   {  ; }
00374 
00375 
00377   ConstVertexVertexIterT& operator=(const VertexVertexIterT<Mesh>& _rhs)
00378   {
00379     mesh_   = _rhs.mesh_;
00380     start_  = _rhs.start_;
00381     heh_    = _rhs.heh_;
00382     lap_counter_ = _rhs.lap_counter_;
00383     return *this;
00384   }
00385 #else
00386   friend class ConstVertexVertexIterT<Mesh>;
00387 #endif  
00388 
00389 
00391   bool operator==(const ConstVertexVertexIterT& _rhs) const {
00392     return ((mesh_   == _rhs.mesh_) &&
00393             (start_  == _rhs.start_) &&
00394             (heh_    == _rhs.heh_) &&
00395             (lap_counter_ == _rhs.lap_counter_));
00396   }
00397 
00398 
00400   bool operator!=(const ConstVertexVertexIterT& _rhs) const {
00401     return !operator==(_rhs);
00402   }
00403 
00404 
00406   ConstVertexVertexIterT& operator++() { 
00407     assert(mesh_);
00408     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
00409     if(heh_ == start_) lap_counter_++;
00410     return *this;
00411   }
00412 
00413 
00415   ConstVertexVertexIterT& operator--() { 
00416     assert(mesh_);
00417     if(heh_ == start_) lap_counter_--;
00418     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
00419     return *this;
00420   }
00421 
00422 
00427   HalfedgeHandle current_halfedge_handle() const {
00428     return heh_;
00429   }
00430 
00431 
00433   typename Mesh::VertexHandle handle() const {
00434     assert(mesh_);
00435     return mesh_->to_vertex_handle(heh_);; 
00436   }
00437 
00438 
00440   operator typename Mesh::VertexHandle() const {
00441     assert(mesh_);
00442     return mesh_->to_vertex_handle(heh_);; 
00443   }
00444     
00445 
00447   reference operator*() const { 
00448     assert(mesh_);
00449     return mesh_->deref(handle());
00450   }
00451 
00452 
00454   pointer operator->() const { 
00455     assert(mesh_);
00456     return &mesh_->deref(handle());
00457   }
00458 
00459 
00466   operator bool() const { 
00467     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
00468   }
00469 
00470 
00471 protected:
00472 
00473   mesh_ptr         mesh_;
00474   HalfedgeHandle   start_, heh_;
00475   int              lap_counter_;
00476 };
00477 
00478 
00479 
00480 //== CLASS DEFINITION =========================================================
00481 
00482 
00487 template <class Mesh>
00488 class VertexOHalfedgeIterT
00489 {
00490  public:
00491 
00492 
00493   //--- Typedefs ---
00494 
00495   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
00496 
00497   typedef typename Mesh::Halfedge           value_type;
00498   typedef typename Mesh::HalfedgeHandle     value_handle;
00499 
00500 #if 0
00501   typedef std::bidirectional_iterator_tag   iterator_category;
00502   typedef std::ptrdiff_t                    difference_type;
00503   typedef const Mesh&                       mesh_ref;
00504   typedef const Mesh*                       mesh_ptr;
00505   typedef const typename Mesh::Halfedge&    reference;
00506   typedef const typename Mesh::Halfedge*    pointer;
00507 #else
00508   typedef std::bidirectional_iterator_tag   iterator_category;
00509   typedef std::ptrdiff_t                    difference_type;
00510   typedef Mesh&                             mesh_ref;
00511   typedef Mesh*                             mesh_ptr;
00512   typedef typename Mesh::Halfedge&          reference;
00513   typedef typename Mesh::Halfedge*          pointer;
00514 #endif
00515 
00516 
00517 
00519   VertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
00520 
00521 
00523   VertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
00524     mesh_(&_mesh), 
00525     start_(_mesh.halfedge_handle(_start)),
00526     heh_(start_),
00527     lap_counter_(_end)
00528   {  ; }
00529 
00530 
00532   VertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
00533     mesh_(&_mesh),
00534     start_(_heh),
00535     heh_(_heh),
00536     lap_counter_(_end)
00537   {  ; }
00538 
00539 
00541   VertexOHalfedgeIterT(const VertexOHalfedgeIterT& _rhs) :
00542     mesh_(_rhs.mesh_),
00543     start_(_rhs.start_),
00544     heh_(_rhs.heh_),
00545     lap_counter_(_rhs.lap_counter_)
00546   {  ; }
00547 
00548 
00550   VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
00551   {
00552     mesh_   = _rhs.mesh_;
00553     start_  = _rhs.start_;
00554     heh_    = _rhs.heh_;
00555     lap_counter_ = _rhs.lap_counter_;
00556     return *this;
00557   }
00558 
00559 
00560 #if 0
00561 
00562   VertexOHalfedgeIterT(const VertexOHalfedgeIterT<Mesh>& _rhs) :
00563     mesh_(_rhs.mesh_),
00564     start_(_rhs.start_),
00565     heh_(_rhs.heh_),
00566     lap_counter_(_rhs.lap_counter_)
00567   {  ; }
00568 
00569 
00571   VertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
00572   {
00573     mesh_   = _rhs.mesh_;
00574     start_  = _rhs.start_;
00575     heh_    = _rhs.heh_;
00576     lap_counter_ = _rhs.lap_counter_;
00577     return *this;
00578   }
00579 #else
00580   friend class ConstVertexOHalfedgeIterT<Mesh>;
00581 #endif  
00582 
00583 
00585   bool operator==(const VertexOHalfedgeIterT& _rhs) const {
00586     return ((mesh_   == _rhs.mesh_) &&
00587             (start_  == _rhs.start_) &&
00588             (heh_    == _rhs.heh_) &&
00589             (lap_counter_ == _rhs.lap_counter_));
00590   }
00591 
00592 
00594   bool operator!=(const VertexOHalfedgeIterT& _rhs) const {
00595     return !operator==(_rhs);
00596   }
00597 
00598 
00600   VertexOHalfedgeIterT& operator++() { 
00601     assert(mesh_);
00602     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
00603     if(heh_ == start_) lap_counter_++;
00604     return *this;
00605   }
00606 
00607 
00609   VertexOHalfedgeIterT& operator--() { 
00610     assert(mesh_);
00611     if(heh_ == start_) lap_counter_--;
00612     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
00613     return *this;
00614   }
00615 
00616 
00621   HalfedgeHandle current_halfedge_handle() const {
00622     return heh_;
00623   }
00624 
00625 
00627   typename Mesh::HalfedgeHandle handle() const {
00628     assert(mesh_);
00629     return heh_; 
00630   }
00631 
00632 
00634   operator typename Mesh::HalfedgeHandle() const {
00635     assert(mesh_);
00636     return heh_; 
00637   }
00638     
00639 
00641   reference operator*() const {
00642     assert(mesh_);
00643     return mesh_->deref(handle());
00644   }
00645 
00646 
00648   pointer operator->() const { 
00649     assert(mesh_);
00650     return &mesh_->deref(handle());
00651   }
00652 
00653 
00660   operator bool() const { 
00661     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
00662   }
00663 
00664 
00665 protected:
00666 
00667   mesh_ptr         mesh_;
00668   HalfedgeHandle   start_, heh_;
00669   int              lap_counter_;
00670 };
00671 
00672 
00673 
00674 //== CLASS DEFINITION =========================================================
00675 
00676               
00681 template <class Mesh>
00682 class ConstVertexOHalfedgeIterT
00683 {
00684  public:
00685 
00686 
00687   //--- Typedefs ---
00688 
00689   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
00690 
00691   typedef typename Mesh::Halfedge           value_type;
00692   typedef typename Mesh::HalfedgeHandle     value_handle;
00693 
00694 #if 1
00695   typedef std::bidirectional_iterator_tag   iterator_category;
00696   typedef std::ptrdiff_t                    difference_type;
00697   typedef const Mesh&                       mesh_ref;
00698   typedef const Mesh*                       mesh_ptr;
00699   typedef const typename Mesh::Halfedge&    reference;
00700   typedef const typename Mesh::Halfedge*    pointer;
00701 #else
00702   typedef std::bidirectional_iterator_tag   iterator_category;
00703   typedef std::ptrdiff_t                    difference_type;
00704   typedef Mesh&                             mesh_ref;
00705   typedef Mesh*                             mesh_ptr;
00706   typedef typename Mesh::Halfedge&          reference;
00707   typedef typename Mesh::Halfedge*          pointer;
00708 #endif
00709 
00710 
00711 
00713   ConstVertexOHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
00714 
00715 
00717   ConstVertexOHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
00718     mesh_(&_mesh), 
00719     start_(_mesh.halfedge_handle(_start)),
00720     heh_(start_),
00721     lap_counter_(_end)
00722   {  ; }
00723 
00724 
00726   ConstVertexOHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
00727     mesh_(&_mesh),
00728     start_(_heh),
00729     heh_(_heh),
00730     lap_counter_(_end)
00731   {  ; }
00732 
00733 
00735   ConstVertexOHalfedgeIterT(const ConstVertexOHalfedgeIterT& _rhs) :
00736     mesh_(_rhs.mesh_),
00737     start_(_rhs.start_),
00738     heh_(_rhs.heh_),
00739     lap_counter_(_rhs.lap_counter_)
00740   {  ; }
00741 
00742 
00744   ConstVertexOHalfedgeIterT& operator=(const ConstVertexOHalfedgeIterT<Mesh>& _rhs)
00745   {
00746     mesh_   = _rhs.mesh_;
00747     start_  = _rhs.start_;
00748     heh_    = _rhs.heh_;
00749     lap_counter_ = _rhs.lap_counter_;
00750     return *this;
00751   }
00752 
00753 
00754 #if 1
00755 
00756   ConstVertexOHalfedgeIterT(const VertexOHalfedgeIterT<Mesh>& _rhs) :
00757     mesh_(_rhs.mesh_),
00758     start_(_rhs.start_),
00759     heh_(_rhs.heh_),
00760     lap_counter_(_rhs.lap_counter_)
00761   {  ; }
00762 
00763 
00765   ConstVertexOHalfedgeIterT& operator=(const VertexOHalfedgeIterT<Mesh>& _rhs)
00766   {
00767     mesh_   = _rhs.mesh_;
00768     start_  = _rhs.start_;
00769     heh_    = _rhs.heh_;
00770     lap_counter_ = _rhs.lap_counter_;
00771     return *this;
00772   }
00773 #else
00774   friend class ConstVertexOHalfedgeIterT<Mesh>;
00775 #endif  
00776 
00777 
00779   bool operator==(const ConstVertexOHalfedgeIterT& _rhs) const {
00780     return ((mesh_   == _rhs.mesh_) &&
00781             (start_  == _rhs.start_) &&
00782             (heh_    == _rhs.heh_) &&
00783             (lap_counter_ == _rhs.lap_counter_));
00784   }
00785 
00786 
00788   bool operator!=(const ConstVertexOHalfedgeIterT& _rhs) const {
00789     return !operator==(_rhs);
00790   }
00791 
00792 
00794   ConstVertexOHalfedgeIterT& operator++() { 
00795     assert(mesh_);
00796     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
00797     if(heh_ == start_) lap_counter_++;
00798     return *this;
00799   }
00800 
00801 
00803   ConstVertexOHalfedgeIterT& operator--() { 
00804     assert(mesh_);
00805     if(heh_ == start_) lap_counter_--;
00806     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
00807     return *this;
00808   }
00809 
00810 
00815   HalfedgeHandle current_halfedge_handle() const {
00816     return heh_;
00817   }
00818 
00819 
00821   typename Mesh::HalfedgeHandle handle() const {
00822     assert(mesh_);
00823     return heh_; 
00824   }
00825 
00826 
00828   operator typename Mesh::HalfedgeHandle() const {
00829     assert(mesh_);
00830     return heh_; 
00831   }
00832     
00833 
00835   reference operator*() const { 
00836     assert(mesh_);
00837     return mesh_->deref(handle());
00838   }
00839 
00840 
00842   pointer operator->() const { 
00843     assert(mesh_);
00844     return &mesh_->deref(handle());
00845   }
00846 
00847 
00854   operator bool() const { 
00855     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
00856   }
00857 
00858 
00859 protected:
00860 
00861   mesh_ptr         mesh_;
00862   HalfedgeHandle   start_, heh_;
00863   int              lap_counter_;
00864 };
00865 
00866 
00867 
00868 //== CLASS DEFINITION =========================================================
00869 
00870               
00875 template <class Mesh>
00876 class VertexIHalfedgeIterT
00877 {
00878  public:
00879 
00880 
00881   //--- Typedefs ---
00882 
00883   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
00884 
00885   typedef typename Mesh::Halfedge           value_type;
00886   typedef typename Mesh::HalfedgeHandle     value_handle;
00887 
00888 #if 0
00889   typedef std::bidirectional_iterator_tag   iterator_category;
00890   typedef std::ptrdiff_t                    difference_type;
00891   typedef const Mesh&                       mesh_ref;
00892   typedef const Mesh*                       mesh_ptr;
00893   typedef const typename Mesh::Halfedge&    reference;
00894   typedef const typename Mesh::Halfedge*    pointer;
00895 #else
00896   typedef std::bidirectional_iterator_tag   iterator_category;
00897   typedef std::ptrdiff_t                    difference_type;
00898   typedef Mesh&                             mesh_ref;
00899   typedef Mesh*                             mesh_ptr;
00900   typedef typename Mesh::Halfedge&          reference;
00901   typedef typename Mesh::Halfedge*          pointer;
00902 #endif
00903 
00904 
00905 
00907   VertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
00908 
00909 
00911   VertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
00912     mesh_(&_mesh), 
00913     start_(_mesh.halfedge_handle(_start)),
00914     heh_(start_),
00915     lap_counter_(_end)
00916   {  ; }
00917 
00918 
00920   VertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
00921     mesh_(&_mesh),
00922     start_(_heh),
00923     heh_(_heh),
00924     lap_counter_(_end)
00925   {  ; }
00926 
00927 
00929   VertexIHalfedgeIterT(const VertexIHalfedgeIterT& _rhs) :
00930     mesh_(_rhs.mesh_),
00931     start_(_rhs.start_),
00932     heh_(_rhs.heh_),
00933     lap_counter_(_rhs.lap_counter_)
00934   {  ; }
00935 
00936 
00938   VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
00939   {
00940     mesh_   = _rhs.mesh_;
00941     start_  = _rhs.start_;
00942     heh_    = _rhs.heh_;
00943     lap_counter_ = _rhs.lap_counter_;
00944     return *this;
00945   }
00946 
00947 
00948 #if 0
00949 
00950   VertexIHalfedgeIterT(const VertexIHalfedgeIterT<Mesh>& _rhs) :
00951     mesh_(_rhs.mesh_),
00952     start_(_rhs.start_),
00953     heh_(_rhs.heh_),
00954     lap_counter_(_rhs.lap_counter_)
00955   {  ; }
00956 
00957 
00959   VertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
00960   {
00961     mesh_   = _rhs.mesh_;
00962     start_  = _rhs.start_;
00963     heh_    = _rhs.heh_;
00964     lap_counter_ = _rhs.lap_counter_;
00965     return *this;
00966   }
00967 #else
00968   friend class ConstVertexIHalfedgeIterT<Mesh>;
00969 #endif  
00970 
00971 
00973   bool operator==(const VertexIHalfedgeIterT& _rhs) const {
00974     return ((mesh_   == _rhs.mesh_) &&
00975             (start_  == _rhs.start_) &&
00976             (heh_    == _rhs.heh_) &&
00977             (lap_counter_ == _rhs.lap_counter_));
00978   }
00979 
00980 
00982   bool operator!=(const VertexIHalfedgeIterT& _rhs) const {
00983     return !operator==(_rhs);
00984   }
00985 
00986 
00988   VertexIHalfedgeIterT& operator++() { 
00989     assert(mesh_);
00990     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
00991     if(heh_ == start_) lap_counter_++;
00992     return *this;
00993   }
00994 
00995 
00997   VertexIHalfedgeIterT& operator--() { 
00998     assert(mesh_);
00999     if(heh_ == start_) lap_counter_--;
01000     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
01001     return *this;
01002   }
01003 
01004 
01009   HalfedgeHandle current_halfedge_handle() const {
01010     return heh_;
01011   }
01012 
01013 
01015   typename Mesh::HalfedgeHandle handle() const {
01016     assert(mesh_);
01017     return mesh_->opposite_halfedge_handle(heh_); 
01018   }
01019 
01020 
01022   operator typename Mesh::HalfedgeHandle() const {
01023     assert(mesh_);
01024     return mesh_->opposite_halfedge_handle(heh_); 
01025   }
01026     
01027 
01029   reference operator*() const { 
01030     assert(mesh_);
01031     return mesh_->deref(handle());
01032   }
01033 
01034 
01036   pointer operator->() const { 
01037     assert(mesh_);
01038     return &mesh_->deref(handle());
01039   }
01040 
01041 
01048   operator bool() const { 
01049     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
01050   }
01051 
01052 
01053 protected:
01054 
01055   mesh_ptr         mesh_;
01056   HalfedgeHandle   start_, heh_;
01057   int              lap_counter_;
01058 };
01059 
01060 
01061 
01062 //== CLASS DEFINITION =========================================================
01063 
01064 
01069 template <class Mesh>
01070 class ConstVertexIHalfedgeIterT
01071 {
01072  public:
01073 
01074 
01075   //--- Typedefs ---
01076 
01077   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
01078 
01079   typedef typename Mesh::Halfedge           value_type;
01080   typedef typename Mesh::HalfedgeHandle     value_handle;
01081 
01082 #if 1
01083   typedef std::bidirectional_iterator_tag   iterator_category;
01084   typedef std::ptrdiff_t                    difference_type;
01085   typedef const Mesh&                       mesh_ref;
01086   typedef const Mesh*                       mesh_ptr;
01087   typedef const typename Mesh::Halfedge&    reference;
01088   typedef const typename Mesh::Halfedge*    pointer;
01089 #else
01090   typedef std::bidirectional_iterator_tag   iterator_category;
01091   typedef std::ptrdiff_t                    difference_type;
01092   typedef Mesh&                             mesh_ref;
01093   typedef Mesh*                             mesh_ptr;
01094   typedef typename Mesh::Halfedge&          reference;
01095   typedef typename Mesh::Halfedge*          pointer;
01096 #endif
01097 
01098 
01099 
01101   ConstVertexIHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
01102 
01103 
01105   ConstVertexIHalfedgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
01106     mesh_(&_mesh), 
01107     start_(_mesh.halfedge_handle(_start)),
01108     heh_(start_),
01109     lap_counter_(_end)
01110   {  ; }
01111 
01112 
01114   ConstVertexIHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
01115     mesh_(&_mesh),
01116     start_(_heh),
01117     heh_(_heh),
01118     lap_counter_(_end)
01119   {  ; }
01120 
01121 
01123   ConstVertexIHalfedgeIterT(const ConstVertexIHalfedgeIterT& _rhs) :
01124     mesh_(_rhs.mesh_),
01125     start_(_rhs.start_),
01126     heh_(_rhs.heh_),
01127     lap_counter_(_rhs.lap_counter_)
01128   {  ; }
01129 
01130 
01132   ConstVertexIHalfedgeIterT& operator=(const ConstVertexIHalfedgeIterT<Mesh>& _rhs)
01133   {
01134     mesh_   = _rhs.mesh_;
01135     start_  = _rhs.start_;
01136     heh_    = _rhs.heh_;
01137     lap_counter_ = _rhs.lap_counter_;
01138     return *this;
01139   }
01140 
01141 
01142 #if 1
01143 
01144   ConstVertexIHalfedgeIterT(const VertexIHalfedgeIterT<Mesh>& _rhs) :
01145     mesh_(_rhs.mesh_),
01146     start_(_rhs.start_),
01147     heh_(_rhs.heh_),
01148     lap_counter_(_rhs.lap_counter_)
01149   {  ; }
01150 
01151 
01153   ConstVertexIHalfedgeIterT& operator=(const VertexIHalfedgeIterT<Mesh>& _rhs)
01154   {
01155     mesh_   = _rhs.mesh_;
01156     start_  = _rhs.start_;
01157     heh_    = _rhs.heh_;
01158     lap_counter_ = _rhs.lap_counter_;
01159     return *this;
01160   }
01161 #else
01162   friend class ConstVertexIHalfedgeIterT<Mesh>;
01163 #endif  
01164 
01165 
01167   bool operator==(const ConstVertexIHalfedgeIterT& _rhs) const {
01168     return ((mesh_   == _rhs.mesh_) &&
01169             (start_  == _rhs.start_) &&
01170             (heh_    == _rhs.heh_) &&
01171             (lap_counter_ == _rhs.lap_counter_));
01172   }
01173 
01174 
01176   bool operator!=(const ConstVertexIHalfedgeIterT& _rhs) const {
01177     return !operator==(_rhs);
01178   }
01179 
01180 
01182   ConstVertexIHalfedgeIterT& operator++() { 
01183     assert(mesh_);
01184     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
01185     if(heh_ == start_) lap_counter_++;
01186     return *this;
01187   }
01188 
01189 
01191   ConstVertexIHalfedgeIterT& operator--() { 
01192     assert(mesh_);
01193     if(heh_ == start_) lap_counter_--;
01194     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
01195     return *this;
01196   }
01197 
01198 
01203   HalfedgeHandle current_halfedge_handle() const {
01204     return heh_;
01205   }
01206 
01207 
01209   typename Mesh::HalfedgeHandle handle() const {
01210     assert(mesh_);
01211     return mesh_->opposite_halfedge_handle(heh_); 
01212   }
01213 
01214 
01216   operator typename Mesh::HalfedgeHandle() const {
01217     assert(mesh_);
01218     return mesh_->opposite_halfedge_handle(heh_); 
01219   }
01220     
01221 
01223   reference operator*() const { 
01224     assert(mesh_);
01225     return mesh_->deref(handle());
01226   }
01227 
01228 
01230   pointer operator->() const { 
01231     assert(mesh_);
01232     return &mesh_->deref(handle());
01233   }
01234 
01235 
01242   operator bool() const { 
01243     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
01244   }
01245 
01246 
01247 protected:
01248 
01249   mesh_ptr         mesh_;
01250   HalfedgeHandle   start_, heh_;
01251   int              lap_counter_;
01252 };
01253 
01254 
01255 
01256 //== CLASS DEFINITION =========================================================
01257 
01258               
01263 template <class Mesh>
01264 class VertexEdgeIterT
01265 {
01266  public:
01267 
01268 
01269   //--- Typedefs ---
01270 
01271   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
01272 
01273   typedef typename Mesh::Edge               value_type;
01274   typedef typename Mesh::EdgeHandle         value_handle;
01275 
01276 #if 0
01277   typedef std::bidirectional_iterator_tag   iterator_category;
01278   typedef std::ptrdiff_t                    difference_type;
01279   typedef const Mesh&                       mesh_ref;
01280   typedef const Mesh*                       mesh_ptr;
01281   typedef const typename Mesh::Edge&        reference;
01282   typedef const typename Mesh::Edge*        pointer;
01283 #else
01284   typedef std::bidirectional_iterator_tag   iterator_category;
01285   typedef std::ptrdiff_t                    difference_type;
01286   typedef Mesh&                             mesh_ref;
01287   typedef Mesh*                             mesh_ptr;
01288   typedef typename Mesh::Edge&              reference;
01289   typedef typename Mesh::Edge*              pointer;
01290 #endif
01291 
01292 
01293 
01295   VertexEdgeIterT() : mesh_(0), lap_counter_(false) {}
01296 
01297 
01299   VertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
01300     mesh_(&_mesh), 
01301     start_(_mesh.halfedge_handle(_start)),
01302     heh_(start_),
01303     lap_counter_(_end)
01304   {  ; }
01305 
01306 
01308   VertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
01309     mesh_(&_mesh),
01310     start_(_heh),
01311     heh_(_heh),
01312     lap_counter_(_end)
01313   {  ; }
01314 
01315 
01317   VertexEdgeIterT(const VertexEdgeIterT& _rhs) :
01318     mesh_(_rhs.mesh_),
01319     start_(_rhs.start_),
01320     heh_(_rhs.heh_),
01321     lap_counter_(_rhs.lap_counter_)
01322   {  ; }
01323 
01324 
01326   VertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
01327   {
01328     mesh_   = _rhs.mesh_;
01329     start_  = _rhs.start_;
01330     heh_    = _rhs.heh_;
01331     lap_counter_ = _rhs.lap_counter_;
01332     return *this;
01333   }
01334 
01335 
01336 #if 0
01337 
01338   VertexEdgeIterT(const VertexEdgeIterT<Mesh>& _rhs) :
01339     mesh_(_rhs.mesh_),
01340     start_(_rhs.start_),
01341     heh_(_rhs.heh_),
01342     lap_counter_(_rhs.lap_counter_)
01343   {  ; }
01344 
01345 
01347   VertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
01348   {
01349     mesh_   = _rhs.mesh_;
01350     start_  = _rhs.start_;
01351     heh_    = _rhs.heh_;
01352     lap_counter_ = _rhs.lap_counter_;
01353     return *this;
01354   }
01355 #else
01356   friend class ConstVertexEdgeIterT<Mesh>;
01357 #endif  
01358 
01359 
01361   bool operator==(const VertexEdgeIterT& _rhs) const {
01362     return ((mesh_   == _rhs.mesh_) &&
01363             (start_  == _rhs.start_) &&
01364             (heh_    == _rhs.heh_) &&
01365             (lap_counter_ == _rhs.lap_counter_));
01366   }
01367 
01368 
01370   bool operator!=(const VertexEdgeIterT& _rhs) const {
01371     return !operator==(_rhs);
01372   }
01373 
01374 
01376   VertexEdgeIterT& operator++() { 
01377     assert(mesh_);
01378     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
01379     if(heh_ == start_) lap_counter_++;
01380     return *this;
01381   }
01382 
01383 
01385   VertexEdgeIterT& operator--() { 
01386     assert(mesh_);
01387     if(heh_ == start_) lap_counter_--;
01388     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
01389     return *this;
01390   }
01391 
01392 
01397   HalfedgeHandle current_halfedge_handle() const {
01398     return heh_;
01399   }
01400 
01401 
01403   typename Mesh::EdgeHandle handle() const {
01404     assert(mesh_);
01405     return mesh_->edge_handle(heh_); 
01406   }
01407 
01408 
01410   operator typename Mesh::EdgeHandle() const {
01411     assert(mesh_);
01412     return mesh_->edge_handle(heh_); 
01413   }
01414     
01415 
01417   reference operator*() const { 
01418     assert(mesh_);
01419     return mesh_->deref(handle());
01420   }
01421 
01422 
01424   pointer operator->() const { 
01425     assert(mesh_);
01426     return &mesh_->deref(handle());
01427   }
01428 
01429 
01436   operator bool() const { 
01437     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
01438   }
01439 
01440 
01441 protected:
01442 
01443   mesh_ptr         mesh_;
01444   HalfedgeHandle   start_, heh_;
01445   int              lap_counter_;
01446 };
01447 
01448 
01449 
01450 //== CLASS DEFINITION =========================================================
01451 
01452               
01457 template <class Mesh>
01458 class ConstVertexEdgeIterT
01459 {
01460  public:
01461 
01462 
01463   //--- Typedefs ---
01464 
01465   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
01466 
01467   typedef typename Mesh::Edge               value_type;
01468   typedef typename Mesh::EdgeHandle         value_handle;
01469 
01470 #if 1
01471   typedef std::bidirectional_iterator_tag   iterator_category;
01472   typedef std::ptrdiff_t                    difference_type;
01473   typedef const Mesh&                       mesh_ref;
01474   typedef const Mesh*                       mesh_ptr;
01475   typedef const typename Mesh::Edge&        reference;
01476   typedef const typename Mesh::Edge*        pointer;
01477 #else
01478   typedef std::bidirectional_iterator_tag   iterator_category;
01479   typedef std::ptrdiff_t                    difference_type;
01480   typedef Mesh&                             mesh_ref;
01481   typedef Mesh*                             mesh_ptr;
01482   typedef typename Mesh::Edge&              reference;
01483   typedef typename Mesh::Edge*              pointer;
01484 #endif
01485 
01486 
01487 
01489   ConstVertexEdgeIterT() : mesh_(0), lap_counter_(false) {}
01490 
01491 
01493   ConstVertexEdgeIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
01494     mesh_(&_mesh), 
01495     start_(_mesh.halfedge_handle(_start)),
01496     heh_(start_),
01497     lap_counter_(_end)
01498   {  ; }
01499 
01500 
01502   ConstVertexEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
01503     mesh_(&_mesh),
01504     start_(_heh),
01505     heh_(_heh),
01506     lap_counter_(_end)
01507   {  ; }
01508 
01509 
01511   ConstVertexEdgeIterT(const ConstVertexEdgeIterT& _rhs) :
01512     mesh_(_rhs.mesh_),
01513     start_(_rhs.start_),
01514     heh_(_rhs.heh_),
01515     lap_counter_(_rhs.lap_counter_)
01516   {  ; }
01517 
01518 
01520   ConstVertexEdgeIterT& operator=(const ConstVertexEdgeIterT<Mesh>& _rhs)
01521   {
01522     mesh_   = _rhs.mesh_;
01523     start_  = _rhs.start_;
01524     heh_    = _rhs.heh_;
01525     lap_counter_ = _rhs.lap_counter_;
01526     return *this;
01527   }
01528 
01529 
01530 #if 1
01531 
01532   ConstVertexEdgeIterT(const VertexEdgeIterT<Mesh>& _rhs) :
01533     mesh_(_rhs.mesh_),
01534     start_(_rhs.start_),
01535     heh_(_rhs.heh_),
01536     lap_counter_(_rhs.lap_counter_)
01537   {  ; }
01538 
01539 
01541   ConstVertexEdgeIterT& operator=(const VertexEdgeIterT<Mesh>& _rhs)
01542   {
01543     mesh_   = _rhs.mesh_;
01544     start_  = _rhs.start_;
01545     heh_    = _rhs.heh_;
01546     lap_counter_ = _rhs.lap_counter_;
01547     return *this;
01548   }
01549 #else
01550   friend class ConstVertexEdgeIterT<Mesh>;
01551 #endif  
01552 
01553 
01555   bool operator==(const ConstVertexEdgeIterT& _rhs) const {
01556     return ((mesh_   == _rhs.mesh_) &&
01557             (start_  == _rhs.start_) &&
01558             (heh_    == _rhs.heh_) &&
01559             (lap_counter_ == _rhs.lap_counter_));
01560   }
01561 
01562 
01564   bool operator!=(const ConstVertexEdgeIterT& _rhs) const {
01565     return !operator==(_rhs);
01566   }
01567 
01568 
01570   ConstVertexEdgeIterT& operator++() { 
01571     assert(mesh_);
01572     heh_=mesh_->cw_rotated_halfedge_handle(heh_);
01573     if(heh_ == start_) lap_counter_++;
01574     return *this;
01575   }
01576 
01577 
01579   ConstVertexEdgeIterT& operator--() { 
01580     assert(mesh_);
01581     if(heh_ == start_) lap_counter_--;
01582     heh_=mesh_->ccw_rotated_halfedge_handle(heh_);
01583     return *this;
01584   }
01585 
01586 
01591   HalfedgeHandle current_halfedge_handle() const {
01592     return heh_;
01593   }
01594 
01595 
01597   typename Mesh::EdgeHandle handle() const {
01598     assert(mesh_);
01599     return mesh_->edge_handle(heh_); 
01600   }
01601 
01602 
01604   operator typename Mesh::EdgeHandle() const {
01605     assert(mesh_);
01606     return mesh_->edge_handle(heh_); 
01607   }
01608     
01609 
01611   reference operator*() const { 
01612     assert(mesh_);
01613     return mesh_->deref(handle());
01614   }
01615 
01616 
01618   pointer operator->() const { 
01619     assert(mesh_);
01620     return &mesh_->deref(handle());
01621   }
01622 
01623 
01630   operator bool() const { 
01631     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
01632   }
01633 
01634 
01635 protected:
01636 
01637   mesh_ptr         mesh_;
01638   HalfedgeHandle   start_, heh_;
01639   int              lap_counter_;
01640 };
01641 
01642 
01643 
01644 //== CLASS DEFINITION =========================================================
01645 
01646               
01651 template <class Mesh>
01652 class VertexFaceIterT
01653 {
01654  public:
01655 
01656 
01657   //--- Typedefs ---
01658 
01659   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
01660 
01661   typedef typename Mesh::Face               value_type;
01662   typedef typename Mesh::FaceHandle         value_handle;
01663 
01664 #if 0
01665   typedef std::bidirectional_iterator_tag   iterator_category;
01666   typedef std::ptrdiff_t                    difference_type;
01667   typedef const Mesh&                       mesh_ref;
01668   typedef const Mesh*                       mesh_ptr;
01669   typedef const typename Mesh::Face&        reference;
01670   typedef const typename Mesh::Face*        pointer;
01671 #else
01672   typedef std::bidirectional_iterator_tag   iterator_category;
01673   typedef std::ptrdiff_t                    difference_type;
01674   typedef Mesh&                             mesh_ref;
01675   typedef Mesh*                             mesh_ptr;
01676   typedef typename Mesh::Face&              reference;
01677   typedef typename Mesh::Face*              pointer;
01678 #endif
01679 
01680 
01681 
01683   VertexFaceIterT() : mesh_(0), lap_counter_(false) {}
01684 
01685 
01687   VertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
01688     mesh_(&_mesh), 
01689     start_(_mesh.halfedge_handle(_start)),
01690     heh_(start_),
01691     lap_counter_(_end)
01692   { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; }
01693 
01694 
01696   VertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
01697     mesh_(&_mesh),
01698     start_(_heh),
01699     heh_(_heh),
01700     lap_counter_(_end)
01701   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01702 
01703 
01705   VertexFaceIterT(const VertexFaceIterT& _rhs) :
01706     mesh_(_rhs.mesh_),
01707     start_(_rhs.start_),
01708     heh_(_rhs.heh_),
01709     lap_counter_(_rhs.lap_counter_)
01710   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01711 
01712 
01714   VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
01715   {
01716     mesh_   = _rhs.mesh_;
01717     start_  = _rhs.start_;
01718     heh_    = _rhs.heh_;
01719     lap_counter_ = _rhs.lap_counter_;
01720     return *this;
01721   }
01722 
01723 
01724 #if 0
01725 
01726   VertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) :
01727     mesh_(_rhs.mesh_),
01728     start_(_rhs.start_),
01729     heh_(_rhs.heh_),
01730     lap_counter_(_rhs.lap_counter_)
01731   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01732 
01733 
01735   VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
01736   {
01737     mesh_   = _rhs.mesh_;
01738     start_  = _rhs.start_;
01739     heh_    = _rhs.heh_;
01740     lap_counter_ = _rhs.lap_counter_;
01741     return *this;
01742   }
01743 #else
01744   friend class ConstVertexFaceIterT<Mesh>;
01745 #endif  
01746 
01747 
01749   bool operator==(const VertexFaceIterT& _rhs) const {
01750     return ((mesh_   == _rhs.mesh_) &&
01751             (start_  == _rhs.start_) &&
01752             (heh_    == _rhs.heh_) &&
01753             (lap_counter_ == _rhs.lap_counter_));
01754   }
01755 
01756 
01758   bool operator!=(const VertexFaceIterT& _rhs) const {
01759     return !operator==(_rhs);
01760   }
01761 
01762 
01764   VertexFaceIterT& operator++() { 
01765     assert(mesh_);
01766     do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));;
01767     return *this;
01768   }
01769 
01770 
01772   VertexFaceIterT& operator--() { 
01773     assert(mesh_);
01774     do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
01775     return *this;
01776   }
01777 
01778 
01783   HalfedgeHandle current_halfedge_handle() const {
01784     return heh_;
01785   }
01786 
01787 
01789   typename Mesh::FaceHandle handle() const {
01790     assert(mesh_);
01791     return mesh_->face_handle(heh_); 
01792   }
01793 
01794 
01796   operator typename Mesh::FaceHandle() const {
01797     assert(mesh_);
01798     return mesh_->face_handle(heh_); 
01799   }
01800     
01801 
01803   reference operator*() const { 
01804     assert(mesh_);
01805     return mesh_->deref(handle());
01806   }
01807 
01808 
01810   pointer operator->() const { 
01811     assert(mesh_);
01812     return &mesh_->deref(handle());
01813   }
01814 
01815 
01822   operator bool() const { 
01823     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
01824   }
01825 
01826 
01827 protected:
01828 
01829   mesh_ptr         mesh_;
01830   HalfedgeHandle   start_, heh_;
01831   int              lap_counter_;
01832 };
01833 
01834 
01835 
01836 //== CLASS DEFINITION =========================================================
01837 
01838               
01843 template <class Mesh>
01844 class ConstVertexFaceIterT
01845 {
01846  public:
01847 
01848 
01849   //--- Typedefs ---
01850 
01851   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
01852 
01853   typedef typename Mesh::Face               value_type;
01854   typedef typename Mesh::FaceHandle         value_handle;
01855 
01856 #if 1
01857   typedef std::bidirectional_iterator_tag   iterator_category;
01858   typedef std::ptrdiff_t                    difference_type;
01859   typedef const Mesh&                       mesh_ref;
01860   typedef const Mesh*                       mesh_ptr;
01861   typedef const typename Mesh::Face&        reference;
01862   typedef const typename Mesh::Face*        pointer;
01863 #else
01864   typedef std::bidirectional_iterator_tag   iterator_category;
01865   typedef std::ptrdiff_t                    difference_type;
01866   typedef Mesh&                             mesh_ref;
01867   typedef Mesh*                             mesh_ptr;
01868   typedef typename Mesh::Face&              reference;
01869   typedef typename Mesh::Face*              pointer;
01870 #endif
01871 
01872 
01873 
01875   ConstVertexFaceIterT() : mesh_(0), lap_counter_(false) {}
01876 
01877 
01879   ConstVertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start, bool _end = false) :
01880     mesh_(&_mesh), 
01881     start_(_mesh.halfedge_handle(_start)),
01882     heh_(start_),
01883     lap_counter_(_end)
01884   { if (heh_.is_valid() && !handle().is_valid() && !_end) operator++();; }
01885 
01886 
01888   ConstVertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
01889     mesh_(&_mesh),
01890     start_(_heh),
01891     heh_(_heh),
01892     lap_counter_(_end)
01893   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01894 
01895 
01897   ConstVertexFaceIterT(const ConstVertexFaceIterT& _rhs) :
01898     mesh_(_rhs.mesh_),
01899     start_(_rhs.start_),
01900     heh_(_rhs.heh_),
01901     lap_counter_(_rhs.lap_counter_)
01902   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01903 
01904 
01906   ConstVertexFaceIterT& operator=(const ConstVertexFaceIterT<Mesh>& _rhs)
01907   {
01908     mesh_   = _rhs.mesh_;
01909     start_  = _rhs.start_;
01910     heh_    = _rhs.heh_;
01911     lap_counter_ = _rhs.lap_counter_;
01912     return *this;
01913   }
01914 
01915 
01916 #if 1
01917 
01918   ConstVertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) :
01919     mesh_(_rhs.mesh_),
01920     start_(_rhs.start_),
01921     heh_(_rhs.heh_),
01922     lap_counter_(_rhs.lap_counter_)
01923   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
01924 
01925 
01927   ConstVertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs)
01928   {
01929     mesh_   = _rhs.mesh_;
01930     start_  = _rhs.start_;
01931     heh_    = _rhs.heh_;
01932     lap_counter_ = _rhs.lap_counter_;
01933     return *this;
01934   }
01935 #else
01936   friend class ConstVertexFaceIterT<Mesh>;
01937 #endif  
01938 
01939 
01941   bool operator==(const ConstVertexFaceIterT& _rhs) const {
01942     return ((mesh_   == _rhs.mesh_) &&
01943             (start_  == _rhs.start_) &&
01944             (heh_    == _rhs.heh_) &&
01945             (lap_counter_ == _rhs.lap_counter_));
01946   }
01947 
01948 
01950   bool operator!=(const ConstVertexFaceIterT& _rhs) const {
01951     return !operator==(_rhs);
01952   }
01953 
01954 
01956   ConstVertexFaceIterT& operator++() { 
01957     assert(mesh_);
01958     do { heh_=mesh_->cw_rotated_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; }  while ((*this) && (!handle().is_valid()));;
01959     return *this;
01960   }
01961 
01962 
01964   ConstVertexFaceIterT& operator--() { 
01965     assert(mesh_);
01966     do { if(heh_ == start_) lap_counter_--; heh_=mesh_->ccw_rotated_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
01967     return *this;
01968   }
01969 
01970 
01975   HalfedgeHandle current_halfedge_handle() const {
01976     return heh_;
01977   }
01978 
01979 
01981   typename Mesh::FaceHandle handle() const {
01982     assert(mesh_);
01983     return mesh_->face_handle(heh_); 
01984   }
01985 
01986 
01988   operator typename Mesh::FaceHandle() const {
01989     assert(mesh_);
01990     return mesh_->face_handle(heh_); 
01991   }
01992     
01993 
01995   reference operator*() const { 
01996     assert(mesh_);
01997     return mesh_->deref(handle());
01998   }
01999 
02000 
02002   pointer operator->() const { 
02003     assert(mesh_);
02004     return &mesh_->deref(handle());
02005   }
02006 
02007 
02014   operator bool() const { 
02015     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02016   }
02017 
02018 
02019 protected:
02020 
02021   mesh_ptr         mesh_;
02022   HalfedgeHandle   start_, heh_;
02023   int              lap_counter_;
02024 };
02025 
02026 
02027 
02028 //== CLASS DEFINITION =========================================================
02029 
02030 
02035 template <class Mesh>
02036 class FaceVertexIterT
02037 {
02038  public:
02039 
02040 
02041   //--- Typedefs ---
02042 
02043   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
02044 
02045   typedef typename Mesh::Vertex             value_type;
02046   typedef typename Mesh::VertexHandle       value_handle;
02047 
02048 #if 0
02049   typedef std::bidirectional_iterator_tag   iterator_category;
02050   typedef std::ptrdiff_t                    difference_type;
02051   typedef const Mesh&                       mesh_ref;
02052   typedef const Mesh*                       mesh_ptr;
02053   typedef const typename Mesh::Vertex&      reference;
02054   typedef const typename Mesh::Vertex*      pointer;
02055 #else
02056   typedef std::bidirectional_iterator_tag   iterator_category;
02057   typedef std::ptrdiff_t                    difference_type;
02058   typedef Mesh&                             mesh_ref;
02059   typedef Mesh*                             mesh_ptr;
02060   typedef typename Mesh::Vertex&            reference;
02061   typedef typename Mesh::Vertex*            pointer;
02062 #endif
02063 
02064 
02065 
02067   FaceVertexIterT() : mesh_(0), lap_counter_(false) {}
02068 
02069 
02071   FaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
02072     mesh_(&_mesh), 
02073     start_(_mesh.halfedge_handle(_start)),
02074     heh_(start_),
02075     lap_counter_(_end)
02076   {  ; }
02077 
02078 
02080   FaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
02081     mesh_(&_mesh),
02082     start_(_heh),
02083     heh_(_heh),
02084     lap_counter_(_end)
02085   {  ; }
02086 
02087 
02089   FaceVertexIterT(const FaceVertexIterT& _rhs) :
02090     mesh_(_rhs.mesh_),
02091     start_(_rhs.start_),
02092     heh_(_rhs.heh_),
02093     lap_counter_(_rhs.lap_counter_)
02094   {  ; }
02095 
02096 
02098   FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
02099   {
02100     mesh_   = _rhs.mesh_;
02101     start_  = _rhs.start_;
02102     heh_    = _rhs.heh_;
02103     lap_counter_ = _rhs.lap_counter_;
02104     return *this;
02105   }
02106 
02107 
02108 #if 0
02109 
02110   FaceVertexIterT(const FaceVertexIterT<Mesh>& _rhs) :
02111     mesh_(_rhs.mesh_),
02112     start_(_rhs.start_),
02113     heh_(_rhs.heh_),
02114     lap_counter_(_rhs.lap_counter_)
02115   {  ; }
02116 
02117 
02119   FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
02120   {
02121     mesh_   = _rhs.mesh_;
02122     start_  = _rhs.start_;
02123     heh_    = _rhs.heh_;
02124     lap_counter_ = _rhs.lap_counter_;
02125     return *this;
02126   }
02127 #else
02128   friend class ConstFaceVertexIterT<Mesh>;
02129 #endif  
02130 
02131 
02133   bool operator==(const FaceVertexIterT& _rhs) const {
02134     return ((mesh_   == _rhs.mesh_) &&
02135             (start_  == _rhs.start_) &&
02136             (heh_    == _rhs.heh_) &&
02137             (lap_counter_ == _rhs.lap_counter_));
02138   }
02139 
02140 
02142   bool operator!=(const FaceVertexIterT& _rhs) const {
02143     return !operator==(_rhs);
02144   }
02145 
02146 
02148   FaceVertexIterT& operator++() { 
02149     assert(mesh_);
02150     heh_=mesh_->next_halfedge_handle(heh_);
02151     if(heh_ == start_) lap_counter_++;
02152     return *this;
02153   }
02154 
02155 
02157   FaceVertexIterT& operator--() {
02158     assert(mesh_);
02159     if(heh_ == start_) lap_counter_--;
02160     heh_=mesh_->prev_halfedge_handle(heh_);
02161     return *this;
02162   }
02163 
02164 
02169   HalfedgeHandle current_halfedge_handle() const {
02170     return heh_;
02171   }
02172 
02173 
02175   typename Mesh::VertexHandle handle() const {
02176     assert(mesh_);
02177     return mesh_->to_vertex_handle(heh_); 
02178   }
02179 
02180 
02182   operator typename Mesh::VertexHandle() const {
02183     assert(mesh_);
02184     return mesh_->to_vertex_handle(heh_); 
02185   }
02186     
02187 
02189   reference operator*() const { 
02190     assert(mesh_);
02191     return mesh_->deref(handle());
02192   }
02193 
02194 
02196   pointer operator->() const { 
02197     assert(mesh_);
02198     return &mesh_->deref(handle());
02199   }
02200 
02201 
02208   operator bool() const { 
02209     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02210   }
02211 
02212 
02213 protected:
02214 
02215   mesh_ptr         mesh_;
02216   HalfedgeHandle   start_, heh_;
02217   int              lap_counter_;
02218 };
02219 
02220 
02221 
02222 //== CLASS DEFINITION =========================================================
02223 
02224               
02229 template <class Mesh>
02230 class ConstFaceVertexIterT
02231 {
02232  public:
02233 
02234 
02235   //--- Typedefs ---
02236 
02237   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
02238 
02239   typedef typename Mesh::Vertex             value_type;
02240   typedef typename Mesh::VertexHandle       value_handle;
02241 
02242 #if 1
02243   typedef std::bidirectional_iterator_tag   iterator_category;
02244   typedef std::ptrdiff_t                    difference_type;
02245   typedef const Mesh&                       mesh_ref;
02246   typedef const Mesh*                       mesh_ptr;
02247   typedef const typename Mesh::Vertex&      reference;
02248   typedef const typename Mesh::Vertex*      pointer;
02249 #else
02250   typedef std::bidirectional_iterator_tag   iterator_category;
02251   typedef std::ptrdiff_t                    difference_type;
02252   typedef Mesh&                             mesh_ref;
02253   typedef Mesh*                             mesh_ptr;
02254   typedef typename Mesh::Vertex&            reference;
02255   typedef typename Mesh::Vertex*            pointer;
02256 #endif
02257 
02258 
02259 
02261   ConstFaceVertexIterT() : mesh_(0), lap_counter_(false) {}
02262 
02263 
02265   ConstFaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
02266     mesh_(&_mesh), 
02267     start_(_mesh.halfedge_handle(_start)),
02268     heh_(start_),
02269     lap_counter_(_end)
02270   {  ; }
02271 
02272 
02274   ConstFaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
02275     mesh_(&_mesh),
02276     start_(_heh),
02277     heh_(_heh),
02278     lap_counter_(_end)
02279   {  ; }
02280 
02281 
02283   ConstFaceVertexIterT(const ConstFaceVertexIterT& _rhs) :
02284     mesh_(_rhs.mesh_),
02285     start_(_rhs.start_),
02286     heh_(_rhs.heh_),
02287     lap_counter_(_rhs.lap_counter_)
02288   {  ; }
02289 
02290 
02292   ConstFaceVertexIterT& operator=(const ConstFaceVertexIterT<Mesh>& _rhs)
02293   {
02294     mesh_   = _rhs.mesh_;
02295     start_  = _rhs.start_;
02296     heh_    = _rhs.heh_;
02297     lap_counter_ = _rhs.lap_counter_;
02298     return *this;
02299   }
02300 
02301 
02302 #if 1
02303 
02304   ConstFaceVertexIterT(const FaceVertexIterT<Mesh>& _rhs) :
02305     mesh_(_rhs.mesh_),
02306     start_(_rhs.start_),
02307     heh_(_rhs.heh_),
02308     lap_counter_(_rhs.lap_counter_)
02309   {  ; }
02310 
02311 
02313   ConstFaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs)
02314   {
02315     mesh_   = _rhs.mesh_;
02316     start_  = _rhs.start_;
02317     heh_    = _rhs.heh_;
02318     lap_counter_ = _rhs.lap_counter_;
02319     return *this;
02320   }
02321 #else
02322   friend class ConstFaceVertexIterT<Mesh>;
02323 #endif  
02324 
02325 
02327   bool operator==(const ConstFaceVertexIterT& _rhs) const {
02328     return ((mesh_   == _rhs.mesh_) &&
02329             (start_  == _rhs.start_) &&
02330             (heh_    == _rhs.heh_) &&
02331             (lap_counter_ == _rhs.lap_counter_));
02332   }
02333 
02334 
02336   bool operator!=(const ConstFaceVertexIterT& _rhs) const {
02337     return !operator==(_rhs);
02338   }
02339 
02340 
02342   ConstFaceVertexIterT& operator++() { 
02343     assert(mesh_);
02344     heh_=mesh_->next_halfedge_handle(heh_);
02345     if(heh_ == start_) lap_counter_++;
02346     return *this;
02347   }
02348 
02349 
02351   ConstFaceVertexIterT& operator--() { 
02352     assert(mesh_);
02353     if(heh_ == start_) lap_counter_--;
02354     heh_=mesh_->prev_halfedge_handle(heh_);
02355     return *this;
02356   }
02357 
02358 
02363   HalfedgeHandle current_halfedge_handle() const {
02364     return heh_;
02365   }
02366 
02367 
02369   typename Mesh::VertexHandle handle() const {
02370     assert(mesh_);
02371     return mesh_->to_vertex_handle(heh_); 
02372   }
02373 
02374 
02376   operator typename Mesh::VertexHandle() const {
02377     assert(mesh_);
02378     return mesh_->to_vertex_handle(heh_); 
02379   }
02380     
02381 
02383   reference operator*() const { 
02384     assert(mesh_);
02385     return mesh_->deref(handle());
02386   }
02387 
02388 
02390   pointer operator->() const { 
02391     assert(mesh_);
02392     return &mesh_->deref(handle());
02393   }
02394 
02395 
02402   operator bool() const { 
02403     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02404   }
02405 
02406 
02407 protected:
02408 
02409   mesh_ptr         mesh_;
02410   HalfedgeHandle   start_, heh_;
02411   int              lap_counter_;
02412 };
02413 
02414 
02415 
02416 //== CLASS DEFINITION =========================================================
02417 
02418               
02423 template <class Mesh>
02424 class FaceHalfedgeIterT
02425 {
02426  public:
02427 
02428 
02429   //--- Typedefs ---
02430 
02431   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
02432 
02433   typedef typename Mesh::Halfedge           value_type;
02434   typedef typename Mesh::HalfedgeHandle     value_handle;
02435 
02436 #if 0
02437   typedef std::bidirectional_iterator_tag   iterator_category;
02438   typedef std::ptrdiff_t                    difference_type;
02439   typedef const Mesh&                       mesh_ref;
02440   typedef const Mesh*                       mesh_ptr;
02441   typedef const typename Mesh::Halfedge&    reference;
02442   typedef const typename Mesh::Halfedge*    pointer;
02443 #else
02444   typedef std::bidirectional_iterator_tag   iterator_category;
02445   typedef std::ptrdiff_t                    difference_type;
02446   typedef Mesh&                             mesh_ref;
02447   typedef Mesh*                             mesh_ptr;
02448   typedef typename Mesh::Halfedge&          reference;
02449   typedef typename Mesh::Halfedge*          pointer;
02450 #endif
02451 
02452 
02453 
02455   FaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
02456 
02457 
02459   FaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
02460     mesh_(&_mesh), 
02461     start_(_mesh.halfedge_handle(_start)),
02462     heh_(start_),
02463     lap_counter_(_end)
02464   {  ; }
02465 
02466 
02468   FaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
02469     mesh_(&_mesh),
02470     start_(_heh),
02471     heh_(_heh),
02472     lap_counter_(_end)
02473   {  ; }
02474 
02475 
02477   FaceHalfedgeIterT(const FaceHalfedgeIterT& _rhs) :
02478     mesh_(_rhs.mesh_),
02479     start_(_rhs.start_),
02480     heh_(_rhs.heh_),
02481     lap_counter_(_rhs.lap_counter_)
02482   {  ; }
02483 
02484 
02486   FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
02487   {
02488     mesh_   = _rhs.mesh_;
02489     start_  = _rhs.start_;
02490     heh_    = _rhs.heh_;
02491     lap_counter_ = _rhs.lap_counter_;
02492     return *this;
02493   }
02494 
02495 
02496 #if 0
02497 
02498   FaceHalfedgeIterT(const FaceHalfedgeIterT<Mesh>& _rhs) :
02499     mesh_(_rhs.mesh_),
02500     start_(_rhs.start_),
02501     heh_(_rhs.heh_),
02502     lap_counter_(_rhs.lap_counter_)
02503   {  ; }
02504 
02505 
02507   FaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
02508   {
02509     mesh_   = _rhs.mesh_;
02510     start_  = _rhs.start_;
02511     heh_    = _rhs.heh_;
02512     lap_counter_ = _rhs.lap_counter_;
02513     return *this;
02514   }
02515 #else
02516   friend class ConstFaceHalfedgeIterT<Mesh>;
02517 #endif  
02518 
02519 
02521   bool operator==(const FaceHalfedgeIterT& _rhs) const {
02522     return ((mesh_   == _rhs.mesh_) &&
02523             (start_  == _rhs.start_) &&
02524             (heh_    == _rhs.heh_) &&
02525             (lap_counter_ == _rhs.lap_counter_));
02526   }
02527 
02528 
02530   bool operator!=(const FaceHalfedgeIterT& _rhs) const {
02531     return !operator==(_rhs);
02532   }
02533 
02534 
02536   FaceHalfedgeIterT& operator++() { 
02537     assert(mesh_);
02538     heh_=mesh_->next_halfedge_handle(heh_);
02539     if(heh_ == start_) lap_counter_++;
02540     return *this;
02541   }
02542 
02543 
02545   FaceHalfedgeIterT& operator--() { 
02546     assert(mesh_);
02547     if(heh_ == start_) lap_counter_--;
02548     heh_=mesh_->prev_halfedge_handle(heh_);
02549     return *this;
02550   }
02551 
02552 
02557   HalfedgeHandle current_halfedge_handle() const {
02558     return heh_;
02559   }
02560 
02561 
02563   typename Mesh::HalfedgeHandle handle() const {
02564     assert(mesh_);
02565     return heh_; 
02566   }
02567 
02568 
02570   operator typename Mesh::HalfedgeHandle() const {
02571     assert(mesh_);
02572     return heh_; 
02573   }
02574     
02575 
02577   reference operator*() const { 
02578     assert(mesh_);
02579     return mesh_->deref(handle());
02580   }
02581 
02582 
02584   pointer operator->() const { 
02585     assert(mesh_);
02586     return &mesh_->deref(handle());
02587   }
02588 
02589 
02596   operator bool() const { 
02597     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02598   }
02599 
02600 
02601 protected:
02602 
02603   mesh_ptr         mesh_;
02604   HalfedgeHandle   start_, heh_;
02605   int              lap_counter_;
02606 };
02607 
02608 
02609 
02610 //== CLASS DEFINITION =========================================================
02611 
02612               
02617 template <class Mesh>
02618 class ConstFaceHalfedgeIterT
02619 {
02620  public:
02621 
02622 
02623   //--- Typedefs ---
02624 
02625   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
02626 
02627   typedef typename Mesh::Halfedge           value_type;
02628   typedef typename Mesh::HalfedgeHandle     value_handle;
02629 
02630 #if 1
02631   typedef std::bidirectional_iterator_tag   iterator_category;
02632   typedef std::ptrdiff_t                    difference_type;
02633   typedef const Mesh&                       mesh_ref;
02634   typedef const Mesh*                       mesh_ptr;
02635   typedef const typename Mesh::Halfedge&    reference;
02636   typedef const typename Mesh::Halfedge*    pointer;
02637 #else
02638   typedef std::bidirectional_iterator_tag   iterator_category;
02639   typedef std::ptrdiff_t                    difference_type;
02640   typedef Mesh&                             mesh_ref;
02641   typedef Mesh*                             mesh_ptr;
02642   typedef typename Mesh::Halfedge&          reference;
02643   typedef typename Mesh::Halfedge*          pointer;
02644 #endif
02645 
02646 
02647 
02649   ConstFaceHalfedgeIterT() : mesh_(0), lap_counter_(false) {}
02650 
02651 
02653   ConstFaceHalfedgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
02654     mesh_(&_mesh), 
02655     start_(_mesh.halfedge_handle(_start)),
02656     heh_(start_),
02657     lap_counter_(_end)
02658   {  ; }
02659 
02660 
02662   ConstFaceHalfedgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
02663     mesh_(&_mesh),
02664     start_(_heh),
02665     heh_(_heh),
02666     lap_counter_(_end)
02667   {  ; }
02668 
02669 
02671   ConstFaceHalfedgeIterT(const ConstFaceHalfedgeIterT& _rhs) :
02672     mesh_(_rhs.mesh_),
02673     start_(_rhs.start_),
02674     heh_(_rhs.heh_),
02675     lap_counter_(_rhs.lap_counter_)
02676   {  ; }
02677 
02678 
02680   ConstFaceHalfedgeIterT& operator=(const ConstFaceHalfedgeIterT<Mesh>& _rhs)
02681   {
02682     mesh_   = _rhs.mesh_;
02683     start_  = _rhs.start_;
02684     heh_    = _rhs.heh_;
02685     lap_counter_ = _rhs.lap_counter_;
02686     return *this;
02687   }
02688 
02689 
02690 #if 1
02691 
02692   ConstFaceHalfedgeIterT(const FaceHalfedgeIterT<Mesh>& _rhs) :
02693     mesh_(_rhs.mesh_),
02694     start_(_rhs.start_),
02695     heh_(_rhs.heh_),
02696     lap_counter_(_rhs.lap_counter_)
02697   {  ; }
02698 
02699 
02701   ConstFaceHalfedgeIterT& operator=(const FaceHalfedgeIterT<Mesh>& _rhs)
02702   {
02703     mesh_   = _rhs.mesh_;
02704     start_  = _rhs.start_;
02705     heh_    = _rhs.heh_;
02706     lap_counter_ = _rhs.lap_counter_;
02707     return *this;
02708   }
02709 #else
02710   friend class ConstFaceHalfedgeIterT<Mesh>;
02711 #endif  
02712 
02713 
02715   bool operator==(const ConstFaceHalfedgeIterT& _rhs) const {
02716     return ((mesh_   == _rhs.mesh_) &&
02717             (start_  == _rhs.start_) &&
02718             (heh_    == _rhs.heh_) &&
02719             (lap_counter_ == _rhs.lap_counter_));
02720   }
02721 
02722 
02724   bool operator!=(const ConstFaceHalfedgeIterT& _rhs) const {
02725     return !operator==(_rhs);
02726   }
02727 
02728 
02730   ConstFaceHalfedgeIterT& operator++() { 
02731     assert(mesh_);
02732     heh_=mesh_->next_halfedge_handle(heh_);
02733     if(heh_ == start_) lap_counter_++;
02734     return *this;
02735   }
02736 
02737 
02739   ConstFaceHalfedgeIterT& operator--() { 
02740     assert(mesh_);
02741     if(heh_ == start_) lap_counter_--;
02742     heh_=mesh_->prev_halfedge_handle(heh_);
02743     return *this;
02744   }
02745 
02746 
02751   HalfedgeHandle current_halfedge_handle() const {
02752     return heh_;
02753   }
02754 
02755 
02757   typename Mesh::HalfedgeHandle handle() const {
02758     assert(mesh_);
02759     return heh_; 
02760   }
02761 
02762 
02764   operator typename Mesh::HalfedgeHandle() const {
02765     assert(mesh_);
02766     return heh_; 
02767   }
02768     
02769 
02771   reference operator*() const { 
02772     assert(mesh_);
02773     return mesh_->deref(handle());
02774   }
02775 
02776 
02778   pointer operator->() const { 
02779     assert(mesh_);
02780     return &mesh_->deref(handle());
02781   }
02782 
02783 
02790   operator bool() const { 
02791     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02792   }
02793 
02794 
02795 protected:
02796 
02797   mesh_ptr         mesh_;
02798   HalfedgeHandle   start_, heh_;
02799   int              lap_counter_;
02800 };
02801 
02802 
02803 
02804 //== CLASS DEFINITION =========================================================
02805 
02806               
02811 template <class Mesh>
02812 class FaceEdgeIterT
02813 {
02814  public:
02815 
02816 
02817   //--- Typedefs ---
02818 
02819   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
02820 
02821   typedef typename Mesh::Edge               value_type;
02822   typedef typename Mesh::EdgeHandle         value_handle;
02823 
02824 #if 0
02825   typedef std::bidirectional_iterator_tag   iterator_category;
02826   typedef std::ptrdiff_t                    difference_type;
02827   typedef const Mesh&                       mesh_ref;
02828   typedef const Mesh*                       mesh_ptr;
02829   typedef const typename Mesh::Edge&        reference;
02830   typedef const typename Mesh::Edge*        pointer;
02831 #else
02832   typedef std::bidirectional_iterator_tag   iterator_category;
02833   typedef std::ptrdiff_t                    difference_type;
02834   typedef Mesh&                             mesh_ref;
02835   typedef Mesh*                             mesh_ptr;
02836   typedef typename Mesh::Edge&              reference;
02837   typedef typename Mesh::Edge*              pointer;
02838 #endif
02839 
02840 
02841 
02843   FaceEdgeIterT() : mesh_(0), lap_counter_(false) {}
02844 
02845 
02847   FaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
02848     mesh_(&_mesh), 
02849     start_(_mesh.halfedge_handle(_start)),
02850     heh_(start_),
02851     lap_counter_(_end)
02852   {  ; }
02853 
02854 
02856   FaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
02857     mesh_(&_mesh),
02858     start_(_heh),
02859     heh_(_heh),
02860     lap_counter_(_end)
02861   {  ; }
02862 
02863 
02865   FaceEdgeIterT(const FaceEdgeIterT& _rhs) :
02866     mesh_(_rhs.mesh_),
02867     start_(_rhs.start_),
02868     heh_(_rhs.heh_),
02869     lap_counter_(_rhs.lap_counter_)
02870   {  ; }
02871 
02872 
02874   FaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
02875   {
02876     mesh_   = _rhs.mesh_;
02877     start_  = _rhs.start_;
02878     heh_    = _rhs.heh_;
02879     lap_counter_ = _rhs.lap_counter_;
02880     return *this;
02881   }
02882 
02883 
02884 #if 0
02885 
02886   FaceEdgeIterT(const FaceEdgeIterT<Mesh>& _rhs) :
02887     mesh_(_rhs.mesh_),
02888     start_(_rhs.start_),
02889     heh_(_rhs.heh_),
02890     lap_counter_(_rhs.lap_counter_)
02891   {  ; }
02892 
02893 
02895   FaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
02896   {
02897     mesh_   = _rhs.mesh_;
02898     start_  = _rhs.start_;
02899     heh_    = _rhs.heh_;
02900     lap_counter_ = _rhs.lap_counter_;
02901     return *this;
02902   }
02903 #else
02904   friend class ConstFaceEdgeIterT<Mesh>;
02905 #endif  
02906 
02907 
02909   bool operator==(const FaceEdgeIterT& _rhs) const {
02910     return ((mesh_   == _rhs.mesh_) &&
02911             (start_  == _rhs.start_) &&
02912             (heh_    == _rhs.heh_) &&
02913             (lap_counter_ == _rhs.lap_counter_));
02914   }
02915 
02916 
02918   bool operator!=(const FaceEdgeIterT& _rhs) const {
02919     return !operator==(_rhs);
02920   }
02921 
02922 
02924   FaceEdgeIterT& operator++() { 
02925     assert(mesh_);
02926     heh_=mesh_->next_halfedge_handle(heh_);
02927     if(heh_ == start_) lap_counter_++;
02928     return *this;
02929   }
02930 
02931 
02933   FaceEdgeIterT& operator--() { 
02934     assert(mesh_);
02935     if(heh_ == start_) lap_counter_--;
02936     heh_=mesh_->prev_halfedge_handle(heh_);
02937     return *this;
02938   }
02939 
02940 
02945   HalfedgeHandle current_halfedge_handle() const {
02946     return heh_;
02947   }
02948 
02949 
02951   typename Mesh::EdgeHandle handle() const {
02952     assert(mesh_);
02953     return mesh_->edge_handle(heh_); 
02954   }
02955 
02956 
02958   operator typename Mesh::EdgeHandle() const {
02959     assert(mesh_);
02960     return mesh_->edge_handle(heh_); 
02961   }
02962     
02963 
02965   reference operator*() const { 
02966     assert(mesh_);
02967     return mesh_->deref(handle());
02968   }
02969 
02970 
02972   pointer operator->() const { 
02973     assert(mesh_);
02974     return &mesh_->deref(handle());
02975   }
02976 
02977 
02984   operator bool() const { 
02985     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
02986   }
02987 
02988 
02989 protected:
02990 
02991   mesh_ptr         mesh_;
02992   HalfedgeHandle   start_, heh_;
02993   int              lap_counter_;
02994 };
02995 
02996 
02997 
02998 //== CLASS DEFINITION =========================================================
02999 
03000               
03005 template <class Mesh>
03006 class ConstFaceEdgeIterT
03007 {
03008  public:
03009 
03010 
03011   //--- Typedefs ---
03012 
03013   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
03014 
03015   typedef typename Mesh::Edge               value_type;
03016   typedef typename Mesh::EdgeHandle         value_handle;
03017 
03018 #if 1
03019   typedef std::bidirectional_iterator_tag   iterator_category;
03020   typedef std::ptrdiff_t                    difference_type;
03021   typedef const Mesh&                       mesh_ref;
03022   typedef const Mesh*                       mesh_ptr;
03023   typedef const typename Mesh::Edge&        reference;
03024   typedef const typename Mesh::Edge*        pointer;
03025 #else
03026   typedef std::bidirectional_iterator_tag   iterator_category;
03027   typedef std::ptrdiff_t                    difference_type;
03028   typedef Mesh&                             mesh_ref;
03029   typedef Mesh*                             mesh_ptr;
03030   typedef typename Mesh::Edge&              reference;
03031   typedef typename Mesh::Edge*              pointer;
03032 #endif
03033 
03034 
03035 
03037   ConstFaceEdgeIterT() : mesh_(0), lap_counter_(false) {}
03038 
03039 
03041   ConstFaceEdgeIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
03042     mesh_(&_mesh), 
03043     start_(_mesh.halfedge_handle(_start)),
03044     heh_(start_),
03045     lap_counter_(_end)
03046   {  ; }
03047 
03048 
03050   ConstFaceEdgeIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
03051     mesh_(&_mesh),
03052     start_(_heh),
03053     heh_(_heh),
03054     lap_counter_(_end)
03055   {  ; }
03056 
03057 
03059   ConstFaceEdgeIterT(const ConstFaceEdgeIterT& _rhs) :
03060     mesh_(_rhs.mesh_),
03061     start_(_rhs.start_),
03062     heh_(_rhs.heh_),
03063     lap_counter_(_rhs.lap_counter_)
03064   {  ; }
03065 
03066 
03068   ConstFaceEdgeIterT& operator=(const ConstFaceEdgeIterT<Mesh>& _rhs)
03069   {
03070     mesh_   = _rhs.mesh_;
03071     start_  = _rhs.start_;
03072     heh_    = _rhs.heh_;
03073     lap_counter_ = _rhs.lap_counter_;
03074     return *this;
03075   }
03076 
03077 
03078 #if 1
03079 
03080   ConstFaceEdgeIterT(const FaceEdgeIterT<Mesh>& _rhs) :
03081     mesh_(_rhs.mesh_),
03082     start_(_rhs.start_),
03083     heh_(_rhs.heh_),
03084     lap_counter_(_rhs.lap_counter_)
03085   {  ; }
03086 
03087 
03089   ConstFaceEdgeIterT& operator=(const FaceEdgeIterT<Mesh>& _rhs)
03090   {
03091     mesh_   = _rhs.mesh_;
03092     start_  = _rhs.start_;
03093     heh_    = _rhs.heh_;
03094     lap_counter_ = _rhs.lap_counter_;
03095     return *this;
03096   }
03097 #else
03098   friend class ConstFaceEdgeIterT<Mesh>;
03099 #endif  
03100 
03101 
03103   bool operator==(const ConstFaceEdgeIterT& _rhs) const {
03104     return ((mesh_   == _rhs.mesh_) &&
03105             (start_  == _rhs.start_) &&
03106             (heh_    == _rhs.heh_) &&
03107             (lap_counter_ == _rhs.lap_counter_));
03108   }
03109 
03110 
03112   bool operator!=(const ConstFaceEdgeIterT& _rhs) const {
03113     return !operator==(_rhs);
03114   }
03115 
03116 
03118   ConstFaceEdgeIterT& operator++() { 
03119     assert(mesh_);
03120     heh_=mesh_->next_halfedge_handle(heh_);
03121     if(heh_ == start_) lap_counter_++;
03122     return *this;
03123   }
03124 
03125 
03127   ConstFaceEdgeIterT& operator--() { 
03128     assert(mesh_);
03129     if(heh_ == start_) lap_counter_--;
03130     heh_=mesh_->prev_halfedge_handle(heh_);
03131     return *this;
03132   }
03133 
03134 
03139   HalfedgeHandle current_halfedge_handle() const {
03140     return heh_;
03141   }
03142 
03143 
03145   typename Mesh::EdgeHandle handle() const {
03146     assert(mesh_);
03147     return mesh_->edge_handle(heh_); 
03148   }
03149 
03150 
03152   operator typename Mesh::EdgeHandle() const {
03153     assert(mesh_);
03154     return mesh_->edge_handle(heh_); 
03155   }
03156     
03157 
03159   reference operator*() const { 
03160     assert(mesh_);
03161     return mesh_->deref(handle());
03162   }
03163 
03164 
03166   pointer operator->() const { 
03167     assert(mesh_);
03168     return &mesh_->deref(handle());
03169   }
03170 
03171 
03178   operator bool() const { 
03179     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
03180   }
03181 
03182 
03183 protected:
03184 
03185   mesh_ptr         mesh_;
03186   HalfedgeHandle   start_, heh_;
03187   int              lap_counter_;
03188 };
03189 
03190 
03191 
03192 //== CLASS DEFINITION =========================================================
03193 
03194               
03199 template <class Mesh>
03200 class FaceFaceIterT
03201 {
03202  public:
03203 
03204 
03205   //--- Typedefs ---
03206 
03207   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
03208 
03209   typedef typename Mesh::Face               value_type;
03210   typedef typename Mesh::FaceHandle         value_handle;
03211 
03212 #if 0
03213   typedef std::bidirectional_iterator_tag   iterator_category;
03214   typedef std::ptrdiff_t                    difference_type;
03215   typedef const Mesh&                       mesh_ref;
03216   typedef const Mesh*                       mesh_ptr;
03217   typedef const typename Mesh::Face&        reference;
03218   typedef const typename Mesh::Face*        pointer;
03219 #else
03220   typedef std::bidirectional_iterator_tag   iterator_category;
03221   typedef std::ptrdiff_t                    difference_type;
03222   typedef Mesh&                             mesh_ref;
03223   typedef Mesh*                             mesh_ptr;
03224   typedef typename Mesh::Face&              reference;
03225   typedef typename Mesh::Face*              pointer;
03226 #endif
03227 
03228 
03229 
03231   FaceFaceIterT() : mesh_(0), lap_counter_(false) {}
03232 
03233 
03235   FaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
03236     mesh_(&_mesh), 
03237     start_(_mesh.halfedge_handle(_start)),
03238     heh_(start_),
03239     lap_counter_(_end)
03240   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03241 
03242 
03244   FaceFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
03245     mesh_(&_mesh),
03246     start_(_heh),
03247     heh_(_heh),
03248     lap_counter_(_end)
03249   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03250 
03251 
03253   FaceFaceIterT(const FaceFaceIterT& _rhs) :
03254     mesh_(_rhs.mesh_),
03255     start_(_rhs.start_),
03256     heh_(_rhs.heh_),
03257     lap_counter_(_rhs.lap_counter_)
03258   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03259 
03260 
03262   FaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
03263   {
03264     mesh_   = _rhs.mesh_;
03265     start_  = _rhs.start_;
03266     heh_    = _rhs.heh_;
03267     lap_counter_ = _rhs.lap_counter_;
03268     return *this;
03269   }
03270 
03271 
03272 #if 0
03273 
03274   FaceFaceIterT(const FaceFaceIterT<Mesh>& _rhs) :
03275     mesh_(_rhs.mesh_),
03276     start_(_rhs.start_),
03277     heh_(_rhs.heh_),
03278     lap_counter_(_rhs.lap_counter_)
03279   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03280 
03281 
03283   FaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
03284   {
03285     mesh_   = _rhs.mesh_;
03286     start_  = _rhs.start_;
03287     heh_    = _rhs.heh_;
03288     lap_counter_ = _rhs.lap_counter_;
03289     return *this;
03290   }
03291 #else
03292   friend class ConstFaceFaceIterT<Mesh>;
03293 #endif  
03294 
03295 
03297   bool operator==(const FaceFaceIterT& _rhs) const {
03298     return ((mesh_   == _rhs.mesh_) &&
03299             (start_  == _rhs.start_) &&
03300             (heh_    == _rhs.heh_) &&
03301             (lap_counter_ == _rhs.lap_counter_));
03302   }
03303 
03304 
03306   bool operator!=(const FaceFaceIterT& _rhs) const {
03307     return !operator==(_rhs);
03308   }
03309 
03310 
03312   FaceFaceIterT& operator++() { 
03313     assert(mesh_);
03314     do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));
03315     return *this;
03316   }
03317 
03318 
03320   FaceFaceIterT& operator--() { 
03321     assert(mesh_);
03322     do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));
03323     return *this;
03324   }
03325 
03326 
03331   HalfedgeHandle current_halfedge_handle() const {
03332     return heh_;
03333   }
03334 
03335 
03337   typename Mesh::FaceHandle handle() const {
03338     assert(mesh_);
03339     return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_)); 
03340   }
03341 
03342 
03344   operator typename Mesh::FaceHandle() const {
03345     assert(mesh_);
03346     return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_)); 
03347   }
03348     
03349 
03351   reference operator*() const { 
03352     assert(mesh_);
03353     return mesh_->deref(handle());
03354   }
03355 
03356 
03358   pointer operator->() const {
03359     assert(mesh_);
03360     return &mesh_->deref(handle());
03361   }
03362 
03363 
03370   operator bool() const { 
03371     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
03372   }
03373 
03374 
03375 protected:
03376 
03377   mesh_ptr         mesh_;
03378   HalfedgeHandle   start_, heh_;
03379   int              lap_counter_;
03380 };
03381 
03382 
03383 
03384 //== CLASS DEFINITION =========================================================
03385 
03386               
03391 template <class Mesh>
03392 class ConstFaceFaceIterT
03393 {
03394  public:
03395 
03396 
03397   //--- Typedefs ---
03398 
03399   typedef typename Mesh::HalfedgeHandle     HalfedgeHandle;
03400 
03401   typedef typename Mesh::Face               value_type;
03402   typedef typename Mesh::FaceHandle         value_handle;
03403 
03404 #if 1
03405   typedef std::bidirectional_iterator_tag   iterator_category;
03406   typedef std::ptrdiff_t                    difference_type;
03407   typedef const Mesh&                       mesh_ref;
03408   typedef const Mesh*                       mesh_ptr;
03409   typedef const typename Mesh::Face&        reference;
03410   typedef const typename Mesh::Face*        pointer;
03411 #else
03412   typedef std::bidirectional_iterator_tag   iterator_category;
03413   typedef std::ptrdiff_t                    difference_type;
03414   typedef Mesh&                             mesh_ref;
03415   typedef Mesh*                             mesh_ptr;
03416   typedef typename Mesh::Face&              reference;
03417   typedef typename Mesh::Face*              pointer;
03418 #endif
03419 
03420 
03421 
03423   ConstFaceFaceIterT() : mesh_(0), lap_counter_(false) {}
03424 
03425 
03427   ConstFaceFaceIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start, bool _end = false) :
03428     mesh_(&_mesh), 
03429     start_(_mesh.halfedge_handle(_start)),
03430     heh_(start_),
03431     lap_counter_(_end)
03432   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03433 
03434 
03436   ConstFaceFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh, bool _end = false) :
03437     mesh_(&_mesh),
03438     start_(_heh),
03439     heh_(_heh),
03440     lap_counter_(_end)
03441   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03442 
03443 
03445   ConstFaceFaceIterT(const ConstFaceFaceIterT& _rhs) :
03446     mesh_(_rhs.mesh_),
03447     start_(_rhs.start_),
03448     heh_(_rhs.heh_),
03449     lap_counter_(_rhs.lap_counter_)
03450   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03451 
03452 
03454   ConstFaceFaceIterT& operator=(const ConstFaceFaceIterT<Mesh>& _rhs)
03455   {
03456     mesh_   = _rhs.mesh_;
03457     start_  = _rhs.start_;
03458     heh_    = _rhs.heh_;
03459     lap_counter_ = _rhs.lap_counter_;
03460     return *this;
03461   }
03462 
03463 
03464 #if 1
03465 
03466   ConstFaceFaceIterT(const FaceFaceIterT<Mesh>& _rhs) :
03467     mesh_(_rhs.mesh_),
03468     start_(_rhs.start_),
03469     heh_(_rhs.heh_),
03470     lap_counter_(_rhs.lap_counter_)
03471   { if (heh_.is_valid() && !handle().is_valid()) operator++();; }
03472 
03473 
03475   ConstFaceFaceIterT& operator=(const FaceFaceIterT<Mesh>& _rhs)
03476   {
03477     mesh_   = _rhs.mesh_;
03478     start_  = _rhs.start_;
03479     heh_    = _rhs.heh_;
03480     lap_counter_ = _rhs.lap_counter_;
03481     return *this;
03482   }
03483 #else
03484   friend class ConstFaceFaceIterT<Mesh>;
03485 #endif  
03486 
03487 
03489   bool operator==(const ConstFaceFaceIterT& _rhs) const {
03490     return ((mesh_   == _rhs.mesh_) &&
03491             (start_  == _rhs.start_) &&
03492             (heh_    == _rhs.heh_) &&
03493             (lap_counter_ == _rhs.lap_counter_));
03494   }
03495 
03496 
03498   bool operator!=(const ConstFaceFaceIterT& _rhs) const {
03499     return !operator==(_rhs);
03500   }
03501 
03502 
03504   ConstFaceFaceIterT& operator++() { 
03505     assert(mesh_);
03506     do { heh_=mesh_->next_halfedge_handle(heh_); if(heh_ == start_) lap_counter_++; } while ((*this) && (!handle().is_valid()));;
03507     return *this;
03508   }
03509 
03510 
03512   ConstFaceFaceIterT& operator--() { 
03513     assert(mesh_);
03514     do { if(heh_ == start_) lap_counter_--; heh_=mesh_->prev_halfedge_handle(heh_); } while ((*this) && (!handle().is_valid()));;
03515     return *this;
03516   }
03517 
03518 
03523   HalfedgeHandle current_halfedge_handle() const {
03524     return heh_;
03525   }
03526 
03527 
03529   typename Mesh::FaceHandle handle() const {
03530     assert(mesh_);
03531     return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_)); 
03532   }
03533 
03534 
03536   operator typename Mesh::FaceHandle() const {
03537     assert(mesh_);
03538     return mesh_->face_handle(mesh_->opposite_halfedge_handle(heh_)); 
03539   }
03540     
03541 
03543   reference operator*() const { 
03544     assert(mesh_);
03545     return mesh_->deref(handle());
03546   }
03547 
03548 
03550   pointer operator->() const { 
03551     assert(mesh_);
03552     return &mesh_->deref(handle());
03553   }
03554 
03555 
03562   operator bool() const { 
03563     return heh_.is_valid() && ((start_ != heh_) || (lap_counter_ == 0));
03564   }
03565 
03566 
03567 protected:
03568 
03569   mesh_ptr         mesh_;
03570   HalfedgeHandle   start_, heh_;
03571   int              lap_counter_;
03572 };
03573 
03574 
03575 
03576 //=============================================================================
03577 } // namespace Iterators
03578 } // namespace OpenMesh
03579 //=============================================================================
03580 #endif
03581 //=============================================================================
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines