如何访问CGAL三维三角测量中的面

How to access the facets in a CGAL 3D triangulation?

本文关键字:测量 三角 三维 CGAL 何访问 访问      更新时间:2023-10-16

我正在使用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
}

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

如何访问三角测量的三角形(小平面(?如何从每个面中提取顶点?

我不知道你能实现什么。三维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 );
}

如果你对曲面网格感兴趣,你可能想看看重建算法,比如泊松曲面重建或推进前重建。