CGAL:帮助从Delaunay Triangulation获取三角形坐标 [英] CGAL: Help getting triangles coordinates from Delaunay Triangulation

查看:311
本文介绍了CGAL:帮助从Delaunay Triangulation获取三角形坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是CGAL的新手,我敢肯定我的问题很简单。

I'm new with CGAL, i'm sure my question is very simple.

我正在尝试使用CGAL进行一些Delaunay三角剖分。我有一个球体上具有N个3D点的网格,我想使用这些点作为三角形的顶点对球体进行三角剖分。我只需要得到这样一个三角形的顶点列表:

I am trying to use CGAL to do some Delaunay triangulation. I have a grid with N 3D points over a sphere and I want to triangulate the sphere using those points as the vertex of the triangles. I just need to get a list of the vertex of the resulting triangles like that:

id_triangle1 vertex_1 vertex_2 vertex_3
id_triangle2 vertex_1 vertex_2 vertex_3
.. .....

id_triangle1 vertex_1 vertex_2 vertex_3 id_triangle2 vertex_1 vertex_2 vertex_3 .......

我这样做是为了执行三角剖分:

I have done that to perform the triangulation:

    std::vector<Point> P; 
    for(i=0;i<NSPOINTS;i++) 
            P.push_back(Point(GRID[i].x,GRID[i].y,GRID[i].z)); 

    // building Delaunay triangulation. 
    Delaunay dt(P.begin(), P.end()); 

我的问题是我不知道如何得到结果三角剖分。我想出了如何获取face_iterator,但我不知道该怎么做:

The problem I have is that I have no idea how to get the resulting triangulation. I figured out how to get the face_iterator, but I don't know what to do from there:

    Delaunay::Finite_faces_iterator it; 
    for (it = dt.finite_faces_begin(); it != dt.finite_faces_end(); it++){ 
            std::cout << dt.triangle(it) << std::endl; 
    } 

我不确定在三角形上进行迭代是否正确,并且如果它是...
a三角形=面??¿,我的意思是,每个迭代器位置只有一个三角形?
如何正确获得每个三角形的x,y和z ??

I'm not sure if that is correct to iterate over the triangles, and if it is... a triangle = face ??¿ , i mean , each iterator position have only a triangle¿? How can I get correctly the x,y and z of each triangle¿?¿

推荐答案

如所记载的此处中,构面是一对(Cell_handle,int)。整数表示与构面相反的像元的索引。因此可以像这样完成对构面点的访问: it-> first-> vertex((it-> second + k)%4)-> point()且k = 1-> 3。

As documented here, a Facet is a pair (Cell_handle,int). The integer indicate the index of the cell opposite to the facet. So getting access to the points of the facet can be done like this: it->first->vertex( (it->second+k)%4 )->point() with k=1->3.

请注意,如果您对球的三角剖分(即表面三角剖分)感兴趣,则需要仅考虑入射到无限单元的多个方面。
另外,使用凸包可以解决此问题,请参见此示例

Note that if you are interested in a triangulation of a sphere (i.e. a surface triangulation), you need to consider only facets incident to an infinite cell. Also, using the convex-hull solves this problem, see this example.

这篇关于CGAL:帮助从Delaunay Triangulation获取三角形坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆