检索CGAL

时间:2016-05-25 14:59:12

标签: indexing cgal triangulation

在下面的代码中,delaunay三角剖分是由名为 points 的N维数组构成的。此数组的每个元素都有一个与之关联的索引。对于三角剖分的每个顶点,可以正确找到最近的顶点(不使用图书馆: CGAL / Triangulation_vertex_base ... )。现在,我想用 - > info()检索每个邻居点的索引,但是我实现的方式会导致错误!我怎么能这样做?

#include <vector>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>

using namespace std();

typedef CGAL::Exact_predicates_inexact_constructions_kernel Kernel;
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned int, Kernel> Vb;
typedef CGAL::Triangulation_data_structure_2<Vb> Tds;
typedef CGAL::Delaunay_triangulation_2<Kernel, Tds> Triangulation;

typedef Triangulation::Edge_iterator Edge_iterator;
typedef Triangulation::Point Point;
typedef Triangulation::Vertex_handle Vertex_handle;
typedef Triangulation::Vertex_circulator Vertex_circulator;
typedef Kernel::Point_2 Point_2;

typedef std::vector<std::pair<Point_2, unsigned> > Vector;

const int N = 16;

int main(){

Vector points;
points.reserve(N);

.... {Some part of code which assignes values to dir[N][2]}
for (int i = 0; i < N; i++)
     points.push_back(make_pair(Point_2(dir[i][0], dir[i][1]), i));\\ I want each point to have an index



Triangulation T;

T.insert(points.begin(), points.end());
cout << T.number_of_vertices() <<endl;

for(int i = 0; i < N; i++){

Vertex_handle handle = T.nearest_vertex(points[i]);
cout<<"incidents: \n" <<endl;
cout << handle->point() <<endl<<endl;
Vertex_circulator circulator = T.incident_vertices(handle), done(circulator);
do
   {
    if( !T.is_infinite ( circulator))

    cout << circulator->point() << endl;
    cout << circulator->point()->info()<<endl;
      } while(++circulator != done);
                            }
return 0;}

编辑:似乎错误的起源主要是因为使用了以下内核: typedef CGAL :: Delaunay_triangulation_2三角测量;

错误:没有匹配函数来调用CGAL :: Delaunay_triangulation_2&gt; &gt; :: nearest_vertex(std :: pair,unsigned int&gt;&amp;)'

编辑2:当我用两条不同的行打印输出时,会出现所需的数字(96):

The code:
cout<<circulator->point()<<endl;
cout<<circulator->info()<<endl;

output(total number of points, 4): 

3.26675 0.733887
2
96
2.02307 0.718587
1
2.33861 1.68862
3

当我在一行中打印信息时,数字96消失;

cout<<circulator->point()<<"\t"<<circulator->info()<<endl;

3.26675 0.733887    2
2.02307 0.718587    1
2.33861 1.68862 3

0 个答案:

没有答案