【问题标题】:How to access the facets in a CGAL 3D triangulation?如何访问 CGAL 3D 三角剖分中的构面?
【发布时间】:2018-12-22 08:11:08
【问题描述】:

我正在使用CGAL 来计算一组点的 3D 三角剖分:

typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_3<K>   CGALTriangulation;
typedef CGALTriangulation::Point            Point;

// Construction from a list of points
std::list<Point> points;
points.push_front(Point(0, 0, 0));
points.push_front(Point(2, 0, 0));
points.push_front(Point(0, 2, 0));
points.push_front(Point(2, 2, 0));
points.push_front(Point(1, 1, 1));

// Perform triangulation
CGALTriangulation T(points.begin(), points.end());

访问三角形(面)

我需要在 Unity 中创建一个网格,所以我使用 CGAL,因为它有很多算法可以处理这个复杂的问题。问题是在 API 中很难找到一种方法来访问构成三角剖分的不同三角形(以及它们的顶点)我还没有找到一种方法:(强>

注意请注意,仅访问顶点对我来说是不够的:

for (CGALTriangulation::Finite_vertices_iterator it = T.finite_vertices_begin(); 
    it != T.finite_vertices_end(); 
    it++) 
{
    CGALTriangulation::Triangulation_data_structure::Vertex v = *it;
    // Do something with the vertex
}

因为我没有得到任何关于每个顶点属于哪个面(三角形)的信息。而三角形正是我所需要的!

如何访问三角剖分的三角形(面)?如何从每个 facet 中取出顶点?

【问题讨论】:

  • 如果你不解释拒绝投票或提议关闭的原因,我应该如何解决这个问题?
  • 似乎人们抱怨问题不清楚。我已经编辑了,希望它更好。如果不清楚,请不要只投票支持关闭,请在评论中稍微处理一下,以便我采取行动解决它

标签: c++ unity3d cgal triangulation delaunay


【解决方案1】:

我不知道你能达到什么目标。 3D Delaunay 三角剖分是将点的凸包分解为四面体。无论如何,如果您想访问三角剖分的各个方面,请使用 Finite_facets_iterator。

类似:

for (CGALTriangulation::Finite_facets_iterator it = T.finite_facets_begin(); 
    it != T.finite_facets_end(); 
    it++) 
{
    std::pair<CGALTriangulation::Cell_handle, int> facet = *it;
    CGALTriangulation::Vertex_handle v1 = facet.first->vertex( (facet.second+1)%4 );
    CGALTriangulation::Vertex_handle v2 = facet.first->vertex( (facet.second+2)%4 );
    CGALTriangulation::Vertex_handle v3 = facet.first->vertex( (facet.second+3)%4 );
}

如果您对表面网格感兴趣,您可能希望查看重构算法,例如 Poisson surface reconstructionAdvancing Front Reconstruction

【讨论】:

  • 谢谢。我已经发现需要迭代器,但我完全不知道如何获取顶点。你能解释一下你是怎么知道这对的第一个和第二个项目是单元格句柄和索引吗?为什么%3?伙计,文档很糟糕,我花了几天时间试图通过浏览文档来了解如何获取这些信息,但到目前为止还没有任何线索......
  • 不过你的 cmets 很有趣。我寻找三角剖分的原因是因为我有这个问题:我有一组点,我想用它们创建一个曲面。我不太关心最终的形状,只要它是一个凸包我就可以了。我曾认为三角测量是执行此操作的算法,但您向我指出了这些链接,现在我不确定。那么,你能解释一下三角测量和表面重建算法之间的区别吗?谢谢
  • 如果您需要凸形,那么只需使用convex hull
  • 应该是% 4,而不是% 3
  • @StéphaneLaurent 确实。刚刚做了编辑。谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-06-23
  • 2019-12-31
  • 2020-05-06
  • 2014-06-28
  • 2015-07-09
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多