【发布时间】:2016-04-05 12:44:24
【问题描述】:
我试图理解边界表示 (B-rep),但我找不到半边数据结构与翼边数据结构相比有何优势。我在this book 中发现有翼边不能代表空间中存在顶点但不存在边的状态。但是没有样本。
Another book 表示边缘方向存在歧义。
最后,在 this web page 上,会调用性能原因。
【问题讨论】:
我试图理解边界表示 (B-rep),但我找不到半边数据结构与翼边数据结构相比有何优势。我在this book 中发现有翼边不能代表空间中存在顶点但不存在边的状态。但是没有样本。
Another book 表示边缘方向存在歧义。
最后,在 this web page 上,会调用性能原因。
【问题讨论】:
我在this paper找到了解决方案。
有了winged-edge,你就得到了这个数据结构:
C#代码如下:
public class WingedEdge
{
public Curve3d Curve { get; set; }
/// <summary>
/// Edge of the left loop starting on the end vertex of this edge.
/// </summary>
public Edge EndLeftEdge { get; set; }
/// <summary>
/// Edge of the right loop starting on the end vertex of this edge.
/// </summary>
public Edge EndRightEdge { get; set; }
/// <summary>
/// Vertex on the end point of the edge.
/// </summary>
public Vertex EndVertex { get; set; }
/// <summary>
/// Face on the left side of the edge.
/// </summary>
public Face LeftFace { get; set; }
/// <summary>
/// Face on the right side of the edge.
/// </summary>
public Face RightFace { get; set; }
/// <summary>
/// Edge of the left loop ending on the start vertex of this edge.
/// </summary>
public Edge StartLeftEdge { get; set; }
/// <summary>
/// Edge of the right loop ending on the start vertex of this edge.
/// </summary>
public Edge StartRightEdge { get; set; }
/// <summary>
/// Vertex on the start point of the edge.
/// </summary>
public Vertex StartVertex { get; set; }
}
在人脸上,只需要存储一个边界边,由于结构形成一个双链表,你可以检索其他边:
public class Face
{
/// <summary>
/// One of the edges bounding this face.
/// </summary>
public WingedEdge FirstEdge { get; set; }
}
但如果您需要遍历人脸的边缘,您将使用以下代码:
WingedEdge edge = face.FirstEdge;
do {
// Do something with the edge
WingedEdge edge = edge.LeftFace == face ? edge.LeftNextEdge : edge.RightNextEdge;
} while (edge != face.FirstEdge)
我们必须在循环中使用条件表达式 (? :) 来查找下一条边。在现代处理器上,这会导致性能下降,如 in this post 所述。
半边数据结构就没有这个问题(但是占用内存更大)。
【讨论】: