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

时间:2019-02-11 01:48:16

标签: c++ cgal delaunay

我想创建一个约束的Delaunay三角剖分,并将自定义信息附加到每个顶点(在下面的示例中为unsigned值)。

我已阅读the official example,将信息添加到“正常”三角剖分中,效果很好。我还创建了一个没有信息的约束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>        ]

1 个答案:

答案 0 :(得分:3)

人脸类型(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;