我对某些点进行了 Delaunay 三角剖分,并希望按长度升序遍历其中的所有边,以构建最小跨度线程。
我尝试了以下方法,但无法编译:
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Delaunay_triangulation_2<K> T;
typedef K::Point_2 P;
typedef T::Vertex_handle Vh;
typedef T::Vertex_iterator Vi;
typedef T::Edge_iterator Ei;
bool sortFunction (Ei a, Ei b) {
K::FT la, lb;
la = CGAL::squared_distance(a.source().point(), a.target().point());
lb = CGAL::squared_distance(b.source().point(), b.target().point());
return la < lb;
}
...
T g;
...
std::vector<Ei> edges;
for (Ei ei = g.edges_begin(); ei != g.edges_end(); ei++) {
edges.push_back(ei);
}
std::sort(edges.begin(), edges.end(), sortFunction);
...
在 中编译失败sortFunction
,说source
是没有成员Edge_iterator
。但是,文档在这里让我感到困惑。
CGAL 文档说边迭代器的值类型是半边。
据说我可以使用和source()
访问target()
积分。
然而,情况似乎并非如此。我在这里搞砸了什么?