The Half-Edge Data Structure

 

此文记录总结半边结构 以三角多面体为例,本文参考: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);

 

 

 

 

 

 

 

转载于:https://www.cnblogs.com/wiw-vv/p/7002082.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值