Subversion Repositories gelsvn

Rev

Blame | Last modification | View Log | RSS feed

#ifndef __HMESH_HALFEDGEHANDLE_H__
#define __HMESH_HALFEDGEHANDLE_H__

#include "HMesh.h"

namespace HMesh
{
    // forward declarations
    class Manifold;
    class VertexHandle;
    class FaceHandle;
    struct HalfEdge;

    class HalfEdgeHandle
    {
    public:
        /// Constructor
        HalfEdgeHandle(Manifold& _m, Hidx _idx);

        /// Get a handle to vertex pointed to by this halfedge
        const VertexHandle vert() const;
        /// Get a handle to the next halfedge in face loop
        const HalfEdgeHandle next() const;
        /// Get a handle to the previous halfedge in face loop
        const HalfEdgeHandle prev() const;
        /// Get a handle to the opposite halfedge
        const HalfEdgeHandle opp() const;
        /// Get a handle to the face this halfedge belongs to
        const FaceHandle face() const; 

        /// Get a handle to vertex pointed to by this halfedge
        VertexHandle vert();
        /// Get a handle to the next halfedge in face loop
        HalfEdgeHandle next();
        /// Get a handle to the previous halfedge in face loop
        HalfEdgeHandle prev();
        /// Get a handle to the opposite halfedge
        HalfEdgeHandle opp();
        /// Get a handle to the face this halfedge belongs to
        FaceHandle face();

        /// Get a const reference to the halfedge
        const HalfEdge& get() const;
        /// Get a reference to the halfedge
        HalfEdge& get();

        bool operator==(const HalfEdgeHandle& f) const;
        bool operator!=(const HalfEdgeHandle& f) const;

        void operator++();
        void operator++(int);
        void operator--();
        void operator--(int);

        bool is_valid() const;
        bool in_use() const;

        /// Get index of halfedge
        Hidx get_idx() const;
        /// Get manifold pointer
        Manifold* get_manifold() const;

    private:
        /// ID of halfedge
        Hidx idx;
        /// pointer to manifold storing the halfege
        Manifold* m;
    };

    /// true if ID of vertex != NULL_VERTEX
    //bool is_used(const HalfEdgeHandle& h);

    /// Returns true if the halfedge is a boundary halfedge.
    bool is_boundary(const HalfEdgeHandle& h);

    /// Return the geometric length of a halfedge.
    float length(const HalfEdgeHandle& h);

    /// Set the next and prev indices of the first and second argument respectively.
    void link(HalfEdgeHandle& h0, HalfEdgeHandle& h1);

    /// Glue halfedges by letting the opp indices point to each other.
    void glue(HalfEdgeHandle& h0, HalfEdgeHandle& h1);

        /** \brief Flip an edge h. 
        Returns false if flipping cannot be performed. This is due to one of following: 
        1.  one of the two adjacent faces is not a triangle. 
        2.  Either end point has valency three.
        3.  The vertices that will be connected already are. */
    bool flip(HalfEdgeHandle& h);
}

#endif __HMESH_HALFEDGEHANDLE_H__