我想使用 Point_set_2 找到一系列周期点的k个最近邻点,下面的一段代码是头文件和相关的typedef,其中我使用了delaunay三角测量的周期版本: / p>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Periodic_2_Delaunay_triangulation_2.h>
#include <CGAL/Periodic_2_triangulation_traits_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Point_set_2.h>
#include <vector>
//******************************************************************
using namespace std;
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
typedef CGAL::Periodic_2_triangulation_traits_2<K> Gt;
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, 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> Delaunay;
typedef Delaunay::Iso_rectangle Iso_rectangle;
CGAL::Point_set_2<K,Tds> PSet;
typedef CGAL::Point_set_2<K,Tds>::Edge_iterator Edge_iterator;
typedef CGAL::Point_set_2<K,Tds>::Vertex_handle Vertex_handle;
typedef K::Point_2 Point_2;
typedef vector<pair<Point_2,unsigned> > Vector;
这些来自该计划的主要部分,根据CGAL manual,我使用了Delaunay&amp;函数最近邻居()的参数中的T:
Vector points;
for(int iat = 0; iat < N_b; iat++)
{
points.push_back(make_pair(Point_2(r_b[iat][0],r_b[iat][1]),iat));
}
Iso_rectangle domain(0,0,L[0],L[1]);
Delaunay T(points.begin(), points.end(), domain);
PSet.insert(points.begin(),points.end());
vector<Vertex_handle>::const_iterator it;
vector<Vertex_handle> LV;
for(int iat = 0; iat < N_b; iat++)
{
Point_2 focal(r_b[iat][0], r_b[iat][1]);
PSet.nearest_neighbors(T, focal, nei_top+1, back_inserter(LV));
vector<Vertex_handle>::const_iterator it_begin = LV.begin()+1;
vector<Vertex_handle>::const_iterator it_end = LV.end();
for (it = it_begin; it != it_end; it++)
{
int jat = (*it)->info();
array1[iat]+= sin(theta[jat]-theta[iat]);
}
LV.clear();
}
points.clear();
但是它会出现一堆错误,包括这个错误:
OutputIterator nearest_neighbors(Point p, size_type k, OutputIterator res)
^
/usr/include/CGAL/Point_set_2.h:180:20: note: template argument deduction/substitution failed:
在手册中,我将Dt视为参数,但根据错误,此参数不存在!