如何使用每个顶点的自定义信息创建 CGAL 约束 delaunay 三角剖分?

How to create CGAL constrained delaunay triangulation with custom info per vertex?

我想创建一个受约束的 delaunay 三角剖分并将一条自定义信息附加到每个顶点(下例中的 unsigned 值)。

我已阅读 the official example 以将信息添加到 "normal" 三角测量,这非常有效。我还创建了一个没有信息的约束 delaunay 三角剖分,它也可以工作。

但是,如果我调整示例以使用带信息的受限 delaunay 三角剖分,这仅意味着更改下面代码中标记的两行,我会收到大量构建错误(见下文)。

我现在已经花了几个小时试图弄清楚错误或找到另一种方法来向每个顶点添加信息。有谁知道我做错了什么或者我该如何继续解决这个问题?

#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Constrained_Delaunay_triangulation_2.h>                        // change 1
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <vector>
typedef CGAL::Exact_predicates_inexact_constructions_kernel         K;
typedef CGAL::Triangulation_vertex_base_with_info_2<unsigned, K>    Vb;
typedef CGAL::Triangulation_data_structure_2<Vb>                    Tds;
typedef CGAL::Constrained_Delaunay_triangulation_2<K, Tds>          Delaunay; // change 2
typedef Delaunay::Point                                             Point;
int main()
{
  std::vector< std::pair<Point,unsigned> > points;
  points.push_back( std::make_pair(Point(0,0),0)   );
  points.push_back( std::make_pair(Point(1,0),1)   );
  points.push_back( std::make_pair(Point(0,1),2)   );
  points.push_back( std::make_pair(Point(14,4),3)  );
  points.push_back( std::make_pair(Point(2,2),4)   );
  points.push_back( std::make_pair(Point(-4,0),5)  );

  Delaunay T;
  T.insert( points.begin(),points.end() );
  CGAL_assertion( T.number_of_vertices() == 6 );
  // check that the info was correctly set.
  Delaunay::Finite_vertices_iterator vit;
  for (vit = T.finite_vertices_begin(); vit != T.finite_vertices_end(); ++vit)
    if( points[ vit->info() ].first != vit->point() ){
      std::cerr << "Error different info" << std::endl;
      exit(EXIT_FAILURE);
    }
  std::cout << "OK" << std::endl;
  return 0;
}
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(653): error C2039: 'is_constrained': is not a member of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Triangulation_ds_face_base_2.h(356): note: see declaration of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(648): note: while compiling class template member function 'CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int,GT,CGAL::Triangulation_vertex_base_2<GT,CGAL::Triangulation_ds_vertex_base_2<TDS2>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false> CGAL::Constrained_triangulation_2<Gt,Tds_,Itag_>::insert(const CGAL::Point_2<Kernel_> &,CGAL::Triangulation_2<Gt,CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>::Locate_type,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int)'
1>        with
1>        [
1>            GT=K,
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>,
1>            Gt=K,
1>            Tds_=Tds,
1>            Itag_=CGAL::Default,
1>            Kernel_=CGAL::Epick
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(622): note: see reference to function template instantiation 'CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_vertex_base_with_info_2<unsigned int,GT,CGAL::Triangulation_vertex_base_2<GT,CGAL::Triangulation_ds_vertex_base_2<TDS2>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false> CGAL::Constrained_triangulation_2<Gt,Tds_,Itag_>::insert(const CGAL::Point_2<Kernel_> &,CGAL::Triangulation_2<Gt,CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>::Locate_type,CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int)' being compiled
1>        with
1>        [
1>            GT=K,
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>,
1>            Gt=K,
1>            Tds_=Tds,
1>            Itag_=CGAL::Default,
1>            Kernel_=CGAL::Epick
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_Delaunay_triangulation_2.h(888): note: while compiling class template member function 'void CGAL::Constrained_Delaunay_triangulation_2<K,Tds,CGAL::Default>::triangulate_hole(std::list<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,std::allocator<_Kty>> &,std::list<std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>,std::allocator<_Ty>> &,std::list<_Ty,std::allocator<_Ty>> &)'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>,
1>            _Kty=CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,
1>            _Ty=std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>
1>        ]
1>C:\Users\Albert\Documents\projects\TestEnv_CGAL\main.cpp(9): note: see reference to class template instantiation 'CGAL::Constrained_Delaunay_triangulation_2<K,Tds,CGAL::Default>' being compiled
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(1142): error C2039: 'set_constraint': is not a member of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Triangulation_ds_face_base_2.h(356): note: see declaration of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(1130): note: while compiling class template member function 'void CGAL::Constrained_triangulation_2<Gt,Tds_,Itag_>::triangulate_hole(std::list<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,std::allocator<_Kty>> &,std::list<std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>,std::allocator<_Ty>> &,std::list<_Ty,std::allocator<_Ty>> &,std::list<_Ty,std::allocator<_Ty>> &)'
1>        with
1>        [
1>            Gt=K,
1>            Tds_=Tds,
1>            Itag_=CGAL::Default,
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>,
1>            _Kty=CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,
1>            _Ty=std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_Delaunay_triangulation_2.h(890): note: see reference to function template instantiation 'void CGAL::Constrained_triangulation_2<Gt,Tds_,Itag_>::triangulate_hole(std::list<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,std::allocator<_Kty>> &,std::list<std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<TDS2>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>,std::allocator<_Ty>> &,std::list<_Ty,std::allocator<_Ty>> &,std::list<_Ty,std::allocator<_Ty>> &)' being compiled
1>        with
1>        [
1>            Gt=K,
1>            Tds_=Tds,
1>            Itag_=CGAL::Default,
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>,
1>            _Kty=CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,
1>            _Ty=std::pair<CGAL::internal::CC_iterator<CGAL::Compact_container<CGAL::Triangulation_ds_face_base_2<CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>>,CGAL::Default,CGAL::Default,CGAL::Default>,false>,int>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Constrained_triangulation_2.h(1143): error C2039: 'set_constraint': is not a member of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]
1>C:\Users\Albert\Documents\libs\cgal_4_13\include\CGAL/Triangulation_ds_face_base_2.h(356): note: see declaration of 'CGAL::Triangulation_ds_face_base_2<TDS2>'
1>        with
1>        [
1>            TDS2=CGAL::Triangulation_data_structure_2<Vb,CGAL::Triangulation_ds_face_base_2<void>>
1>        ]

面部类型(TDS 中的第二个模板参数)必须是 ConstrainedTriangulationFaceBase_2 的模型,例如您的 CGAL::Constrained_triangulation_face_base_2<K>

替换:

typedef CGAL::Triangulation_data_structure_2<Vb>                    Tds;

来自

typedef CGAL::Constrained_triangulation_face_base_2<K>  Fb;
typedef CGAL::Triangulation_data_structure_2<Vb, Fb> Tds;