CGAL 3.4:如何从 Finite_edges_iterator 获取结束顶点坐标?
这是一些代码:
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_triangulation_2<K, TDS, Itag> CT;
typedef CT::Point Point;
for (CT::Finite_edges_iterator eit = ct.finite_edges_begin();
eit != ct.finite_edges_end(); ++eit){
// TODO: list vertex co-ordinates here
}
来自 手册:
“边没有显式表示,它们只是通过两个面的邻接关系隐式表示。每条边有两个隐式表示:与索引 i 的顶点相对的面 f 的边,可以表示为以及 f 的邻居(i) 的边。”
这对我来说没问题......但是如何在上面给出的代码中使用 CT::Finite_edges_iterator
获取边缘的末端顶点?
更新: 我设法想出了这个解决方案:
Segment s = ct.segment(eit);
const Point& p1 = s.point(0);
const Point& p2 = s.point(1);
我仍在寻找更好的方法来做到这一点。
Here is some code:
struct K : CGAL::Exact_predicates_inexact_constructions_kernel {};
typedef CGAL::Triangulation_vertex_base_2<K> Vb;
typedef CGAL::Constrained_triangulation_face_base_2<K> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb,Fb> TDS;
typedef CGAL::Exact_predicates_tag Itag;
typedef CGAL::Constrained_triangulation_2<K, TDS, Itag> CT;
typedef CT::Point Point;
for (CT::Finite_edges_iterator eit = ct.finite_edges_begin();
eit != ct.finite_edges_end(); ++eit){
// TODO: list vertex co-ordinates here
}
From the manual:
"The edges are not explicitly represented, they are only implicitly represented through the adjacency relations of two faces. Each edge has two implicit representations: the edge of a face f which is opposed to the vertex indexed i, can be represented as well as an edge of the neighbor(i) of f."
That's fine by me... but how do I get the end vertices of the edge using a CT::Finite_edges_iterator
in the code given above?
Update:
I managed to come up with this solution:
Segment s = ct.segment(eit);
const Point& p1 = s.point(0);
const Point& p2 = s.point(1);
I am still looking for a better way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我设法想出了这个解决方案:
我仍在寻找更好的方法来做到这一点。
I managed to come up with this solution:
I am still looking for a better way to do this.
我使用类似
Triangulation::Vertex_handle fVertex = eit->first->vertex(Triangulation::ccw(eit->second)); 的
东西Triangulation::Vertex_handle sVertex = eit->first->vertex(Triangulation::cw(eit->second));
I have using something like
Triangulation::Vertex_handle fVertex = eit->first->vertex(Triangulation::ccw(eit->second));
Triangulation::Vertex_handle sVertex = eit->first->vertex(Triangulation::cw(eit->second));
边提供面上顶点的索引。在 CGAL 中,三角剖分的面只有 3 个顶点。边是三元组; (脸,i,j)。您可以 获取第 i 个(0、1 ,或 2) 使用 vertex(i) 方法获取面的顶点。。因此,要获取顶点,请使用:
The edges provide the indices of the vertices on the face. The face of a triangulation has only 3 vertices in CGAL. Edges are a triplet; (face, i, j). You can get the i-th (either 0, 1, or 2) vertex of a face using the vertex(i) method.. So, to get the vertices, use: