📄 circulatorst.hh
字号:
/// Construct with mesh and start halfedge VertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh) : mesh_(&_mesh), start_(_heh), heh_(_heh), active_(false) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// Copy constructor VertexFaceIterT(const VertexFaceIterT& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// Assignment operator VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#if 0 /// construct from non-const circulator type VertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// assign from non-const circulator VertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#else friend class ConstVertexFaceIterT<Mesh>;#endif /// Equal ? bool operator==(const VertexFaceIterT& _rhs) const { return ((mesh_ == _rhs.mesh_) && (start_ == _rhs.start_) && (heh_ == _rhs.heh_) && (active_ == _rhs.active_)); } /// Not equal ? bool operator!=(const VertexFaceIterT& _rhs) const { return !operator==(_rhs); } /// Pre-Increment (next cw target) VertexFaceIterT& operator++() { assert(mesh_); active_ = true; do heh_=mesh_->cw_rotated_halfedge_handle(heh_); while ((*this) && (!handle().is_valid()));; return *this; } /// Pre-Decrement (next ccw target) VertexFaceIterT& operator--() { assert(mesh_); active_ = true; do heh_=mesh_->ccw_rotated_halfedge_handle(heh_); while ((*this) && (!handle().is_valid()));; return *this; } /** Get the current halfedge. There are \c Vertex*Iters and \c Face*Iters. For both the current state is defined by the current halfedge. This is what this method returns. */ HalfedgeHandle current_halfedge_handle() const { return heh_; } /// Return the handle of the current target. typename Mesh::FaceHandle handle() const { assert(mesh_); return mesh_->face_handle(heh_); } /// Cast to the handle of the current target. operator typename Mesh::FaceHandle() const { assert(mesh_); return mesh_->face_handle(heh_); } /// Return a reference to the current target. reference operator*() const { assert(mesh_); return mesh_->deref(handle()); } /// Return a pointer to the current target. pointer operator->() const { assert(mesh_); return &mesh_->deref(handle()); } /** Returns whether the circulator is still valid. After one complete round around a vertex/face the circulator becomes invalid, i.e. this function will return \c false. Nevertheless you can continue circulating. This method just tells you whether you have completed the first round. */ operator bool() const { return heh_.is_valid() && ((start_ != heh_) || (!active_)); }private: mesh_ptr mesh_; HalfedgeHandle start_, heh_; bool active_;};//== CLASS DEFINITION ========================================================= /** \class ConstVertexFaceIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh> Circulator.*/template <class Mesh>class ConstVertexFaceIterT{ public: //--- Typedefs --- typedef typename Mesh::HalfedgeHandle HalfedgeHandle; typedef typename Mesh::Face value_type; typedef typename Mesh::FaceHandle value_handle;#if 1 typedef const Mesh& mesh_ref; typedef const Mesh* mesh_ptr; typedef const typename Mesh::Face& reference; typedef const typename Mesh::Face* pointer;#else typedef Mesh& mesh_ref; typedef Mesh* mesh_ptr; typedef typename Mesh::Face& reference; typedef typename Mesh::Face* pointer;#endif /// Default constructor ConstVertexFaceIterT() : mesh_(0), active_(false) {} /// Construct with mesh and a typename Mesh::VertexHandle ConstVertexFaceIterT(mesh_ref _mesh, typename Mesh::VertexHandle _start) : mesh_(&_mesh), start_(_mesh.halfedge_handle(_start)), heh_(start_), active_(false) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// Construct with mesh and start halfedge ConstVertexFaceIterT(mesh_ref _mesh, HalfedgeHandle _heh) : mesh_(&_mesh), start_(_heh), heh_(_heh), active_(false) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// Copy constructor ConstVertexFaceIterT(const ConstVertexFaceIterT& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// Assignment operator ConstVertexFaceIterT& operator=(const ConstVertexFaceIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#if 1 /// construct from non-const circulator type ConstVertexFaceIterT(const VertexFaceIterT<Mesh>& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { if (heh_.is_valid() && !handle().is_valid()) operator++();; } /// assign from non-const circulator ConstVertexFaceIterT& operator=(const VertexFaceIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#else friend class ConstVertexFaceIterT<Mesh>;#endif /// Equal ? bool operator==(const ConstVertexFaceIterT& _rhs) const { return ((mesh_ == _rhs.mesh_) && (start_ == _rhs.start_) && (heh_ == _rhs.heh_) && (active_ == _rhs.active_)); } /// Not equal ? bool operator!=(const ConstVertexFaceIterT& _rhs) const { return !operator==(_rhs); } /// Pre-Increment (next cw target) ConstVertexFaceIterT& operator++() { assert(mesh_); active_ = true; do heh_=mesh_->cw_rotated_halfedge_handle(heh_); while ((*this) && (!handle().is_valid()));; return *this; } /// Pre-Decrement (next ccw target) ConstVertexFaceIterT& operator--() { assert(mesh_); active_ = true; do heh_=mesh_->ccw_rotated_halfedge_handle(heh_); while ((*this) && (!handle().is_valid()));; return *this; } /** Get the current halfedge. There are \c Vertex*Iters and \c Face*Iters. For both the current state is defined by the current halfedge. This is what this method returns. */ HalfedgeHandle current_halfedge_handle() const { return heh_; } /// Return the handle of the current target. typename Mesh::FaceHandle handle() const { assert(mesh_); return mesh_->face_handle(heh_); } /// Cast to the handle of the current target. operator typename Mesh::FaceHandle() const { assert(mesh_); return mesh_->face_handle(heh_); } /// Return a reference to the current target. reference operator*() const { assert(mesh_); return mesh_->deref(handle()); } /// Return a pointer to the current target. pointer operator->() const { assert(mesh_); return &mesh_->deref(handle()); } /** Returns whether the circulator is still valid. After one complete round around a vertex/face the circulator becomes invalid, i.e. this function will return \c false. Nevertheless you can continue circulating. This method just tells you whether you have completed the first round. */ operator bool() const { return heh_.is_valid() && ((start_ != heh_) || (!active_)); }private: mesh_ptr mesh_; HalfedgeHandle start_, heh_; bool active_;};//== CLASS DEFINITION ========================================================= /** \class FaceVertexIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh> Circulator.*/template <class Mesh>class FaceVertexIterT{ public: //--- Typedefs --- typedef typename Mesh::HalfedgeHandle HalfedgeHandle; typedef typename Mesh::Vertex value_type; typedef typename Mesh::VertexHandle value_handle;#if 0 typedef const Mesh& mesh_ref; typedef const Mesh* mesh_ptr; typedef const typename Mesh::Vertex& reference; typedef const typename Mesh::Vertex* pointer;#else typedef Mesh& mesh_ref; typedef Mesh* mesh_ptr; typedef typename Mesh::Vertex& reference; typedef typename Mesh::Vertex* pointer;#endif /// Default constructor FaceVertexIterT() : mesh_(0), active_(false) {} /// Construct with mesh and a typename Mesh::FaceHandle FaceVertexIterT(mesh_ref _mesh, typename Mesh::FaceHandle _start) : mesh_(&_mesh), start_(_mesh.halfedge_handle(_start)), heh_(start_), active_(false) { ; } /// Construct with mesh and start halfedge FaceVertexIterT(mesh_ref _mesh, HalfedgeHandle _heh) : mesh_(&_mesh), start_(_heh), heh_(_heh), active_(false) { ; } /// Copy constructor FaceVertexIterT(const FaceVertexIterT& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { ; } /// Assignment operator FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#if 0 /// construct from non-const circulator type FaceVertexIterT(const FaceVertexIterT<Mesh>& _rhs) : mesh_(_rhs.mesh_), start_(_rhs.start_), heh_(_rhs.heh_), active_(_rhs.active_) { ; } /// assign from non-const circulator FaceVertexIterT& operator=(const FaceVertexIterT<Mesh>& _rhs) { mesh_ = _rhs.mesh_; start_ = _rhs.start_; heh_ = _rhs.heh_; active_ = _rhs.active_; return *this; }#else friend class ConstFaceVertexIterT<Mesh>;#endif /// Equal ? bool operator==(const FaceVertexIterT& _rhs) const { return ((mesh_ == _rhs.mesh_) && (start_ == _rhs.start_) && (heh_ == _rhs.heh_) && (active_ == _rhs.active_)); } /// Not equal ? bool operator!=(const FaceVertexIterT& _rhs) const { return !operator==(_rhs); } /// Pre-Increment (next ccw target) FaceVertexIterT& operator++() { assert(mesh_); active_ = true; heh_=mesh_->next_halfedge_handle(heh_);; return *this; } /// Pre-Decrement (next cw target) FaceVertexIterT& operator--() { assert(mesh_); active_ = true; heh_=mesh_->prev_halfedge_handle(heh_);; return *this; } /** Get the current halfedge. There are \c Vertex*Iters and \c Face*Iters. For both the current state is defined by the current halfedge. This is what this method returns. */ HalfedgeHandle current_halfedge_handle() const { return heh_; } /// Return the handle of the current target. typename Mesh::VertexHandle handle() const { assert(mesh_); return mesh_->to_vertex_handle(heh_); } /// Cast to the handle of the current target. operator typename Mesh::VertexHandle() const { assert(mesh_); return mesh_->to_vertex_handle(heh_); } /// Return a reference to the current target. reference operator*() const { assert(mesh_); return mesh_->deref(handle()); } /// Return a pointer to the current target. pointer operator->() const { assert(mesh_); return &mesh_->deref(handle()); } /** Returns whether the circulator is still valid. After one complete round around a vertex/face the circulator becomes invalid, i.e. this function will return \c false. Nevertheless you can continue circulating. This method just tells you whether you have completed the first round. */ operator bool() const { return heh_.is_valid() && ((start_ != heh_) || (!active_)); }private: mesh_ptr mesh_; HalfedgeHandle start_, heh_; bool active_;};//== CLASS DEFINITION ========================================================= /** \class ConstFaceVertexIterT CirculatorsT.hh <OpenMesh/Mesh/Iterators/CirculatorsT.hh> Circulator.*/template <class Mesh>class ConstFaceVertexIterT{ public: //--- Typedefs --- typedef typename Mesh::HalfedgeHandle HalfedgeHandle; typedef typename Mesh::Vertex value_type; typedef typename Mesh::VertexHandle value_handle;#if 1
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -