从edge_iterator获取vertex_handle
我在获取 Delaunay 三角剖分中边的每个端点的 vertex_handle 时遇到了相当大的困难。由于我为此苦苦挣扎了几个小时,我想也许你们中的一个人可以帮助我解决这个看似微不足道的问题:
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
using namespace std;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex;
int main(){
Point p;
Triangulation t;
while(cin >> p)
t.insert(p);
// Iterate over edges
for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
// Get a vertex from the edge
Vertex vs = ei->source();
}
}
根据取消引用 Edge_iterator 的文档,我应该得到一个 Edge_handle ,而 Edge_handle 应该有成员 source() 和 target( )来简单地获取端点,但它不会编译并且似乎是错误的。像上面那样取消引用会给我一对<>它没有这些成员函数。
知道我做错了什么吗?
I'm having quite some difficulty getting a vertex_handle for each of the end points of an edge in a Delaunay triangulation. Since I hammered my head against this for several hours I thought maybe one of you guys could help me out with this apparently trivial problem:
#include <iostream>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
using namespace std;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> Triangulation;
typedef Triangulation::Point Point;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex;
int main(){
Point p;
Triangulation t;
while(cin >> p)
t.insert(p);
// Iterate over edges
for(Edge_iterator ei=t.finite_edges_begin();ei!=t.finite_edges_end(); ei++){
// Get a vertex from the edge
Vertex vs = ei->source();
}
}
According to the documentation dereferencing an Edge_iterator I should get an Edge_handle and Edge_handle should have members source() and target() to simply get the endpoints, but it won't compile and seems to be wrong. Derefencing like above will give me a pair<> which doesn't have those member functions.
Any idea what I'm doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取消引用
Edge_iterator
将根据 文档。Edge
定义如下:typedef std::pair; Edge;
取消引用
Face_handle
将为您提供一个 脸。边连接的两个顶点可以通过以下方式访问:
我不知道这对您的任务是否有帮助,但可以访问这样的点:
CGAL 文档让我感到困惑...我很好奇您在哪里找到了
eh->source()
和eh->target()
调用,我找不到它:-)Dereferencing an
Edge_iterator
will give you anEdge
according to the documentation.Edge
is definded as follows:typedef std::pair<Face_handle,int> Edge;
Dereferencing the
Face_handle
will give you a Face.The two vertices that the edge joins can be accessed by:
I don't know if it is helpful for you quest, but is access the points like this:
The CGAL documentation is confusing to me... I am curious where you found the
eh->source()
andeh->target()
calls, I could not find it :-)