# 图形学之Half Edge数据结构

2022/11/11 13:57

• 哪些面使用此顶点？
• 哪些边使用此顶点？
• 哪些面与这条边相邻？
• 哪些边与这个面相邻？
• 哪些面与此面相邻？

## 2、Half Edge数据结构

 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

};


## 3、邻接查询

    HE_vert* vert1 = edge->vert;
HE_vert* vert2 = edge->pair->vert;

HE_face* face1 = edge->face;
HE_face* face2 = edge->pair->face;


     HE_edge* edge = face->edge;

do {

// do something with edge
edge = edge->next;

} while (edge != face->edge);


    HE_edge* edge = vert->edge;

do {

// do something with edge, edge->pair or edge->face
edge = edge->pair->next;

} while (edge != vert->edge);


## 4、结束语

The Harvard Graphics Archive Mesh库包含半边数据结构的完整实现。源代码可在线获取。

0 评论
0 收藏
0