CGAL:帮助从 Delaunay 三角测量获取三角形坐标
我是 CGAL 的新手,我确信我的问题很简单。
我正在尝试使用 CGAL 进行一些 Delaunay 三角测量。我有一个球体上有 N 个 3D 点的网格,我想使用这些点作为三角形的顶点对球体进行三角测量。我只需要获取生成的三角形的顶点列表,如下所示:
id_triangle1 vertex_1 vertex_2 vertex_3 id_triangle2 顶点_1 顶点_2 顶点_3 ......
我已经这样做来执行三角测量:
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,但我不知道从那里做什么:
Delaunay::Finite_faces_iterator it;
for (it = dt.finite_faces_begin(); it != dt.finite_faces_end(); it++){
std::cout << dt.triangle(it) << std::endl;
}
我不确定迭代三角形是否正确,如果是...... 一个三角形=面??¿,我的意思是,每个迭代器位置只有一个三角形?? 我怎样才能正确地得到每个三角形的x、y和z?????
I'm new with CGAL, i'm sure my question is very simple.
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
.......
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());
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;
}
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¿?¿
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
正如此处所述,一个 Facet 是一对 (Cell_handle ,整数)。整数表示与构面相对的单元格的索引。因此,可以像这样访问面的点:
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.
如果你用谷歌搜索finite_faces_begin(),你可以得到很多CGAL提示。
faces 迭代器将允许您以不同的方式获取底层数据。这是一个来自“tesis”的很好的例子,它使用“vertex()”函数。
http://mati-repa-repo.googlecode.com/ svn/trunk/tesis/impl/HODTs/
祝你好运。
If you google for finite_faces_begin() you can get a lot of CGAL hints.
The faces iterator will allow you to get at the underlying data in different ways. Here is a nice example from something called "tesis" that uses the 'vertex()' function.
http://mati-repa-repo.googlecode.com/svn/trunk/tesis/impl/HODTs/
Good luck.