【发布时间】:2019-09-21 03:07:09
【问题描述】:
我在我的代码中使用 CGAL 中的周期性 Delaunay 三角剖分,并为每个顶点生成所有相邻顶点。为此,我使用 Edge 迭代器,因为在我的情况下它会比 Vertex 迭代器快得多。 这里是代码sn-p,
typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Periodic_2_triangulation_traits_2<Kernel> Gt;
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned int, Gt> Vb;
typedef CGAL::Periodic_2_triangulation_face_base_2<Gt> Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;
typedef CGAL::Periodic_2_Delaunay_triangulation_2<Gt, Tds> Triangulation;
typedef Triangulation::Iso_rectangle Iso_rectangle;
typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Point Point;
typedef vector<pair<Point, unsigned> > Vector_Paired;
Vector_Paired points;
Iso_rectangle domain(0,0,L,L);
for(int iat = 0; iat < N; iat++)
{
points.push_back(make_pair(Point(r_tot[iat][0],r_tot[iat][1]),iat));
}
Triangulation T(points.begin(), points.end(), domain);
for(Edge_iterator ei=T.finite_edges_begin(); ei!=T.finite_edges_end(); ei++)
{
Triangulation::Face& f = *(ei->first);
int ii = ei->second;
Vertex_handle vi = f.vertex(f.cw(ii));
Vertex_handle vj = f.vertex(f.ccw(ii));
int iat = vi->info();
int jat = vj->info();
VecInd[iat].push_back(jat);
VecInd[jat].push_back(iat);
}
但是,有时我得到的不是每个顶点的一个特殊邻居,而是 8 或 9 或......同一个邻居的副本。 例如,在 VecInd 中,它是一个包含相邻索引的 2D 向量,我得到如下信息: VecInd[0]=[2,2,2,2,4,4,4,...]
我在 CGAL 网站中找不到使用边缘迭代器的示例,并且在 stackoverflow 中没有任何相关内容。 我想知道这个实现是否正确?我应该在我的代码中添加什么以便为每个邻居获取一份副本,我可以使用 STL::sets,但我想知道问题的根源。
【问题讨论】:
-
这个问题已经在您发布相同问题的邮件列表中有一个很好的答案:cgal-discuss.949826.n4.nabble.com/…