此文记录总结半边结构 以三角多面体为例,本文参考:http://www.flipcode.com/archives/The_Half-Edge_Data_Structure.shtml
结构图如下:
The diagram below shows a small section of a half-edge representation of a triangle mesh. The yellow dots are the vertices of the mesh and the light blue bars are the half-edges. The arrows in the diagram represent pointers, although in order to keep the diagram from getting too cluttered, some of them have been ommited.
C语言实现:
//半边
struct HE_edge
{
HE_vert* vert; // vertex at the end of the half-edge
HE_edge* pair; // oppositely oriented adjacent half-edge
HE_face* face; // face the half-edge borders
HE_edge* next; // next half-edge around the face
};
//顶点
struct HE_vert
{
float x;
float y;
float z;
HE_edge* edge; // one of the half-edges emantating from the vertex
};
//面
struct HE_face
{
HE_edge* edge; // one of the half-edges bordering the face
};
领接查询:
1.the faces or vertices which border a half-edge can easily be found like this:
HE_vert* vert1 = edge->vert;
HE_vert* vert2 = edge->pair->vert;
HE_face* face1 = edge->face;
HE_face* face2 = edge->pair->face;
2.iterating over the half edges adjacent to a face
HE_edge* edge = face->edge;
do {
// do something with edge
edge = edge->next;
} while (edge != face->edge);
3.interested in iterating over the edges or faces which are adjacent to a particular vertex.
HE_edge* edge = vert->edge;
do {
// do something with edge, edge->pair or edge->face
edge = edge->pair->next;
} while (edge != vert->edge);