Subversion Repositories gelsvn

Rev

Blame | Last modification | View Log | RSS feed

#ifndef __HMESH_FACEHANDLE_H__
#define __HMESH_FACEHANDLE_H__

#include "HMesh.h"

namespace CGLA
{
    // forward declaration
    class Vec3f;
}

namespace HMesh
{
    // forward declarations
    class Manifold;
    class HalfEdgeHandle;
    struct Face;

    class FaceHandle
    {
    public:
        /// constructor
        FaceHandle(Manifold& _m, Fidx _idx);

        /// Get a const handle to the last halfedge visiting this face
        const HalfEdgeHandle last() const;
        HalfEdgeHandle last();

        const Face& get() const;
        Face& get();

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

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

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

        /// get face index
        Fidx get_idx() const;
        /// get manifold pointer
        Manifold* get_manifold() const;
    private:
        /// id of face
        Fidx idx;
        /// pointer to manifold storing the face
        Manifold* m;
    };
    /// true if ID of halfedge != NULL_HALFEDGE
    //bool is_used(const FaceHandle& f);

    /// Compute the number of edges of a face
    uint no_edges(const FaceHandle& f);

    /** Compute the normal of a face. If the face is not a triangle,
    the normal is not defined, but computed using the first three
    vertices of the face. */
    CGLA::Vec3f normal(const FaceHandle& f);

    /// Compute the area of a face. 
    float area(const FaceHandle& f);

    /// Compute the centre of a face
    CGLA::Vec3f centre(const FaceHandle& f);
}

#endif __HMESH_FACEHANDLE_H__