简体   繁体   English

查找四面体网格边的算法

[英]Algorithm to find the edges of tetrahedra meshes

I have a few thousands of tetrahedra meshes that is generated for modelling. 我有成千上万的用于建模的四面体网格。 I have the vertices and surfaces information which are indexed into two matrices which some are related. 我有顶点和曲面信息,它们被索引为两个与之相关的矩阵。 The nodes of surfaces are linked to the vertices' matrix. 曲面的节点链接到顶点的矩阵。 I want to find which vertices are connected to each other to form a tetrahedra. 我想找到哪些顶点相互连接以形成四面体。 Is there an algorithm to detect the connectivity of the vertices that formed edges of a tetrahedra? 是否有一种算法可以检测形成四面体边缘的顶点的连通性?

If your node matrix is an adjacency matrix, ie nearest neighbors, then choosing any vertex, the other three remaining vertices of some tetrahedron it forms must satisfy: 如果您的节点矩阵是邻接矩阵,即最近的邻居,则选择任何顶点,它形成的某些四面体的其他三个剩余顶点必须满足:

(i) They are immediate neighbors of the chosen vertex, (i)他们是所选顶点的直接邻居,

(ii) They are are immediate neighbors of each other . (二)它们是互为近邻。 If this is not true then you'll end up with tetrahedra crossing each other. 如果这不是真的,那么您将最终遇到四面体彼此交叉的情况。


If I misunderstood your statement, ie it's not an adjacency matrix, then you'll have to do the 3D-version of Delaunay Triangulation , ie calculating the 3D Voronoi cell graph for your point cloud. 如果我误解了您的陈述,即它不是邻接矩阵,那么您将必须进行Delaunay三角剖分的3D版本,即为您的点云计算3D Voronoi细胞图。 https://en.wikipedia.org/wiki/Voronoi_diagram https://zh.wikipedia.org/wiki/Voronoi_diagram

Starting from a list of possibly duplicated edges: 从可能重复的边的列表开始:

Suppose you got an ASCII file with possibly duplicate edges. 假设您有一个ASCII文件,其边缘可能重复。 On a Unix system, here is a simple way of extracting from it the list of unique edges: 在Unix系统上,这是从中提取唯一边缘列表的简单方法:

cat edges.txt | awk '{printf "%d %d\n",  ($1 < $2 ? $1 : $2),  ($1 > $2 ? $1 : $2)}' | sort | uniq > unique_edges.txt

What it does: 它能做什么:

  1. The 'awk' command ensures that in each edge, the vertex of lower id comes first (thus, there will be a single way of representing the same edge in the file) “ awk”命令可确保在每个边缘中,较低ID的顶点在前(因此,将有一种方法来表示文件中相同的边缘)
  2. the 'sort' command sorts all the lines. 'sort'命令对所有行进行排序。 This will ensure that all duplicated edges are together 这将确保所有重复的边在一起
  3. the 'uniq' command suppresses the duplicated lines 'uniq'命令禁止重复的行

If you are under Windows, you can install cygwin (to have awk,sort and uniq). 如果您使用Windows,则可以安装cygwin(具有awk,sort和uniq)。 It is also quite easy to do something similar in other scripting languages (eg perl). 用其他脚本语言(例如perl)做类似的事情也很容易。

Starting from a list of tetrahedra: 从四面体列表开始:

Now if you start with a file with the tetrahedra, you can generate a (duplicated) list of edges as follows (then you can run the command above to remove duplicates): 现在,如果您从一个带有四面体的文件开始,您可以生成一个(重复的)边列表,如下所示(然后您可以运行上面的命令来删除重复项):

cat tetrahedra.txt | awk '{printf "%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n", $1, $2, $1, $3, $1, $4, $2, $3, $2, $4, $3, $4}' > edges.txt

What it does: it generates for each tetrahedron its 6 edges, one edge per line. 它的作用:为每个四面体生成6条边,每行一条边。

Clearly, you can combine both commands, to directly extract a unique list of edges from the tetrahedra file. 显然,您可以组合使用这两个命令,以直接从四面体文件中提取边的唯一列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM