多边形网格 数据结构_网格数据结构

多边形网格 数据结构

For surface networks, the important feature is the topology, rather than the location of its vertices. Different topologies have created different data structures and standards. Different topologies have different performances for grid query and editing.

对于地面网络,重要的功能是拓扑,而不是其顶点的位置。 不同的拓扑创建了不同的数据结构和标准。 不同的拓扑对于网格查询和编辑具有不同的性能。

For digital media, games, real-time interaction, etc., models are usually irregular curved geometry, which requires aesthetics and short enough calculation time. Therefore, the model is usually a discretized surface mesh. The so-called discretization is a mesh that is spliced ​​by a series of patches, which seems to be rough, but it can be made smooth through texture and rendering technology.

对于数字媒体,游戏,实时交互等,模型通常是不规则的弯曲几何形状,这需要美观并且需要足够短的计算时间。 因此,模型通常是离散的表面网格。 所谓离散化是一种由一系列补丁拼接而成的网格,看似粗糙,但可以通过纹理和渲染技术使其变得平滑。

The half-edge data structure is a slightly complicated edge representation method and all proximity queries can be done in constant time. Even better if the adjacency information of faces, vertices and edges is included, the size of the data structure is fixed and compact.

半边数据结构是一种稍微复杂的边表示方法,所有邻近查询都可以在恒定时间内完成。 如果包括面,顶点和边的邻接信息,则更好,数据结构的大小是固定且紧凑的。

The basic elements of the half-edge data structure are vertices, faces and half-edges.

半边数据结构的基本元素是顶点,面和半边。

Each edge is divided into two halves, and each half-edge is a directed edge with opposite directions. If an edge is shared by two faces, each face can have a half. It can be seen that for a half-edge mesh, three structures need to be implemented:

每个边缘均分为两半,每个半边缘是方向相反的有向边缘。 如果一条边由两个面共享,则每个面可以有一半。 可以看出,对于半边网格,需要实现三个结构:

  • Vertex that stores the (x, y, z) coordinates.

    存储(x,y,z)坐标的顶点。
  • Face that contains all the indexes of the vertices that make up the face.

    包含组成面的所有顶点索引的面。
  • Half-edge that Contains the index of the end point , the adjacent face , the next half edge , and the opposite edge

    包含端点,相邻面,下一个半边和相对边的索引的半边
class HalfEdge( object ):
def __init__( self ):
self.to_vertex = -1
self.face = -1
self.edge = -1
self.opposite_he = -1
self.next_he = -1

The implementation here simplifies some content, such as the texture coordinates of the vertices, normals, etc.

这里的实现简化了一些内容,例如顶点的纹理坐标,法线等。

Most answers to proximity queries are stored in data structures of edges, points, and faces. For example, the faces or points surrounding the half can be easily found.

邻近查询的大多数答案都存储在边,点和面的数据结构中。 例如,可以轻松找到围绕一半的面或点。

def vertex_face_neighbors( self, vertex_index ):
halfedges = self.halfedges
result = []
start_he = halfedges[ self.vertex_halfedges[ vertex_index ] ]
he = start_he
while True:
if -1 != he.face:
result.append( he.face )
he = halfedges[ halfedges[ he.opposite_he ].next_he ]
if he is start_he:
break
return resultdef vertex_vertex_neighbors( self, vertex_index ): halfedges = self.halfedges
result = []
start_he = halfedges[ self.vertex_halfedges[ vertex_index ] ]
he = start_he
while True:
result.append( he.to_vertex )
he = halfedges[ halfedges[ he.opposite_he ].next_he ]
if he is start_he:
break
return result

To be able to calculate the neighboring faces the neighboring vertices needs to be found first.

为了能够计算相邻面,首先需要找到相邻顶点。

Image for post
Image By Author.
图片作者。

We start from the current vertex (V_0), we step ahead with the halfedge next pointer to the ring surrounding the current vertex.

我们从当前顶点(V_0)开始,然后向前移动半边沿的下一个指针,指向当前顶点周围的环。

Once out in the ring the only thing that needs to be done is to store the vertex index and step ahead with the half-edge next pointer until it points to the starting vertex in the ring.

一旦进入环中,唯一要做的就是存储顶点索引并向前移动半边的下一个指针,直到它指向环中的起始顶点为止。

The neighboring faces is done by using this ring of surrounding vertices and check their corresponding faces. Because every half-edge stores the left face it is easily retrieved by looping through the neighboring vertices and putting all neigboring faces indices into a vector.

相邻的面是通过使用此环的周围顶点完成的,并检查它们对应的面。 由于每个半边都存储左脸,因此可以通过遍历相邻顶点并将所有相邻的脸索引放入向量中来轻松检索。

We can implements a simple Half-Edge based on a triangular mesh from OBJ file Format OFF that contains :

我们可以基于OBJ文件Format OFF中的三角形网格实现一个简单的Half-Edge,该三角形网格包含:

  • Number of vertices s

    顶点数s
  • Number of faces c

    面数c
  • Description of the faces (sequence of the indices of the vertices of the face, preceded by its number of vertices).

    面的描述(面顶点索引的顺序,其顶点数量开头)。

First we read all the vertex coordinate information,then we read the surface information to create the surface.

首先,我们读取所有顶点坐标信息,然后读取表面信息以创建表面。

def TriMesh_FromOBJ( path ):
result = TriMesh()
obj_lines = open( path )
n_v,n_f,_=[int(u) for u in next(obj_lines).split()]
for i in range(n_v):
result.vs.append([float(u) for u in next(obj_lines).split()])
for i in range(n_f):
result.faces.append([float(u) for u in next(obj_lines).split()[1:]]) obj_lines.close()
result.vs=np.array(result.vs)
result.faces=np.array(result.faces,dtype=int)
return result

Perhaps the biggest difficulty encountered in realizing half-edge structure is how to efficiently realize the link relationship between an edge and its dual edge.

实现半边结构时可能遇到的最大困难是如何有效地实现边和其

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值