Rev 506 | Blame | Last modification | View Log | RSS feed
#ifndef __HMESH_VERTEXHANDLE_H__
#define __HMESH_VERTEXHANDLE_H__
#include "entities.h"
#include "Manifold.h"
namespace CGLA
{
// Forward declaration
class Vec3f;
}
namespace HMesh
{
// Forward declarations
class HalfEdgeHandle;
class ConstHalfEdgeHandle;
class FaceHandle;
class ConstFaceHandle;
class ConstVertexHandle;
class Vertexhandle;
/************************************
* VertexHandle + functions
************************************/
class VertexHandle
{
public:
VertexHandle();
VertexHandle(Manifold& _m, VertexIndex _idx);
HalfEdgeHandle out();
Vertex& get();
bool operator==(const VertexHandle& v) const;
bool operator!=(const VertexHandle& v) const;
void operator++();
void operator++(int);
VertexIndex get_idx() const;
private:
friend class ConstVertexHandle;
/// Vertex index
VertexIndex idx;
/// Pointer to manifold storing the vertex
Manifold* m;
};
#define NULL_VHANDLE VertexHandle()
inline VertexHandle::VertexHandle()
: m(NULL), idx(NULL_VIDX)
{}
inline VertexHandle::VertexHandle(Manifold& _m, VertexIndex _idx)
: m(&_m), idx(_idx)
{}
inline Vertex& VertexHandle::get()
{
return m->vertices[idx];
}
inline bool VertexHandle::operator==(const VertexHandle& v) const
{
return idx == v.get_idx();
}
inline bool VertexHandle::operator!=(const VertexHandle& v) const
{
return idx != v.get_idx();
}
inline VertexIndex VertexHandle::get_idx() const
{
return idx;
}
/************************************
* ConstFaceHandle + functions
*************************************/
class ConstVertexHandle
{
public:
ConstVertexHandle();
ConstVertexHandle(const Manifold& _m, VertexIndex _idx);
ConstVertexHandle(const ConstVertexHandle& cvh);
ConstVertexHandle(const VertexHandle& vh);
ConstVertexHandle& operator=(const ConstVertexHandle& cvh);
ConstVertexHandle& operator=(const VertexHandle& vh);
ConstHalfEdgeHandle out() const;
const Vertex& get() const;
bool operator==(const ConstVertexHandle& v) const;
bool operator!=(const ConstVertexHandle& v) const;
void operator++();
void operator++(int);
VertexIndex get_idx() const;
private:
/// Vertex index
VertexIndex idx;
/// const pointer to manifold storing the vertex
const Manifold* m;
};
#define NULL_CVHANDLE ConstVertexHandle()
inline ConstVertexHandle::ConstVertexHandle()
: m(NULL), idx(NULL_VIDX)
{}
inline ConstVertexHandle::ConstVertexHandle(const Manifold& _m, VertexIndex _idx)
: m(&_m), idx(_idx)
{}
inline ConstVertexHandle::ConstVertexHandle(const ConstVertexHandle& cvh)
: m(cvh.m), idx(cvh.idx)
{}
inline ConstVertexHandle::ConstVertexHandle(const VertexHandle& vh)
: m(vh.m), idx(vh.idx)
{}
inline ConstVertexHandle& ConstVertexHandle::operator=(const ConstVertexHandle& cvh)
{
m = cvh.m;
idx = cvh.idx;
return *this;
}
inline ConstVertexHandle& ConstVertexHandle::operator=(const VertexHandle& vh)
{
m = vh.m;
idx = vh.idx;
return *this;
}
inline const Vertex& ConstVertexHandle::get() const
{
return m->vertices[idx];
}
inline bool ConstVertexHandle::operator==(const ConstVertexHandle& v) const
{
return idx == v.get_idx();
}
inline bool ConstVertexHandle::operator!=(const ConstVertexHandle& v) const
{
return idx != v.get_idx();
}
inline VertexIndex ConstVertexHandle::get_idx() const
{
return idx;
}
/// Returns true if the vertex is a boundary vertex.
bool boundary(ConstVertexHandle v);
/// Compute valency, i.e. number of incident edges.
IndexType valency(ConstVertexHandle v);
/// Compute the vertex normal. This function computes the angle weighted sum of incident face normals.
CGLA::Vec3f normal(ConstVertexHandle v);
/// Returns true if the two argument vertices are in each other's one-rings.
bool connected(ConstVertexHandle v0, ConstVertexHandle v1);
}
#endif __HMESH_VERTEXHANDLE_H__