我對某些點有Delaunay三角剖分,並且想要按長度遞增順序遍歷其中的所有邊,以便構建最小跨度線程。如何從CGAL中的Edge_iterator獲取源點和目標點
我試着用下面的方法,但不能讓它編譯:
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 documentation表示邊緣迭代器的值類型是halfedge。 There據說我可以用source()
和target()
來獲得積分。
但是,這似乎並非如此。我在這裏搞什麼?
沒有工作:( – Etan 2011-01-28 19:06:09