三角网格拓扑

发布于 2024-07-19 04:46:43 字数 188 浏览 9 评论 0原文

我有一个三角形网格类,其中包含节点列表(在我的例子中是 2d,但这不重要)和面列表。 每个面都是一个三角形,它只包含节点数组的索引。 网格来自 Delaunay 算法,因此非常干净。

对于网格中的每个节点,我需要找到哪些节点通过单边连接到它。 构建和搜索该拓扑数据库的快速方法是什么?

多谢, 大卫·鲁顿

I've got a triangular mesh class which contains a list of nodes (2d in my case but that shouldn't matter) and a list of faces. Each face is a triangle and it only contains the indices into the node array. The mesh comes out of a Delaunay algorithm so it's very clean.

For every node in the mesh I need to find which nodes are connected to it with a single edge. What would be a fast way to construct and search this topology database?

Much obliged,
David Rutten

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撑一把青伞 2024-07-26 04:46:43

有两种有点标准的数据结构可以促进网格拓扑查询。 一种是Winged Edges(通常也称为half-edge),另一个是 有向边。 谷歌一下,你会得到大量的细节,以及每个细节的不同级别的介绍。

对您的场景了解不够,无法推荐其中之一。 例如,有向边经过存储优化,最适合非常大的网格。 翼边被认为是“经典”,是更高级口味的良好起点。

实际上,如果您确定这是您需要的唯一查询,那么两者都太过分了,您只需使用单个哈希就可以了。 但是,如果您发现自己需要有效回答诸如“

  • 哪些面使用此顶点?”
  • 之类的问题。 哪些边使用这个顶点?
  • 哪些面与该边缘接壤?
  • 哪些边与该面接壤?
  • 哪些面与此相邻
    脸?

您应该考虑深入研究其中之一。

There are two somewhat-standard data structs that facilitate mesh topology-queries. One is Winged Edges (commonly referred to also as half-edge), and the other is Directed Edges. Google around and you'd get kajillions of details, and various-level intros into each one.

Don't know enough about your scenario to recommend one of them. E.g., directed edges is storage-optimized, and best suited for very large meshes. Winged edges is considered a 'classic', and is a good starting point for more advanced flavours.

Actually if you're certain that's the only query you'd need, then both are an overkill and you'd do just fine with a single hash. If, however, you find yourself in need of efficient answers to queries like -

  • Which faces use this vertex?
  • Which edges use this vertex?
  • Which faces border this edge?
  • Which edges border this face?
  • Which faces are adjacent to this
    face?

You should consider diving into one of them.

睫毛上残留的泪 2024-07-26 04:46:43

我想我已经对哈希表、字典和排序列表视而不见了......以下可能是最简单和最快的:

Public Sub SolveConnectivity(ByVal nodes As Node2List, ByVal faces As List(Of Face))
  m_map = New List(Of List(Of Int32))(nodes.Count)

  'Create blank lists
  For i As Int32 = 0 To nodes.Count - 1
    m_map.Add(New List(Of Int32)(6))
  Next

  'Populate connectivity diagram
  For i As Int32 = 0 To faces.Count - 1
    Dim F As Face = faces(i)
    m_map(F.A).Add(F.B)
    m_map(F.A).Add(F.C)

    m_map(F.B).Add(F.A)
    m_map(F.B).Add(F.C)

    m_map(F.C).Add(F.A)
    m_map(F.C).Add(F.B)
  Next
End Sub

I think I've stared myself blind on HashTables, Dictionaries and Sorted Lists... The following is probably the easiest and fastest:

Public Sub SolveConnectivity(ByVal nodes As Node2List, ByVal faces As List(Of Face))
  m_map = New List(Of List(Of Int32))(nodes.Count)

  'Create blank lists
  For i As Int32 = 0 To nodes.Count - 1
    m_map.Add(New List(Of Int32)(6))
  Next

  'Populate connectivity diagram
  For i As Int32 = 0 To faces.Count - 1
    Dim F As Face = faces(i)
    m_map(F.A).Add(F.B)
    m_map(F.A).Add(F.C)

    m_map(F.B).Add(F.A)
    m_map(F.B).Add(F.C)

    m_map(F.C).Add(F.A)
    m_map(F.C).Add(F.B)
  Next
End Sub
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文