C++ 在CGAL Voronoi图中插入包含信息的点范围

C++ 在CGAL Voronoi图中插入包含信息的点范围,c++,cgal,voronoi,C++,Cgal,Voronoi,在一篇文章中,我问了在CGAL中构建Voronoi图时如何将非几何信息(例如权重)与站点关联。 我的解决方案涉及#包括使用_info_2.h对CGAL/三角测量_顶点_基础_进行加密,并使用以下形式的循环: std::ifstream ifs("data/data1.dt.cin"); // Input file for points VoronoiDiagram vd; // CGAL Voronoi diagram data structure Si

在一篇文章中,我问了在CGAL中构建Voronoi图时如何将非几何信息(例如权重)与站点关联。
我的解决方案涉及
#包括使用_info_2.h
对CGAL/三角测量_顶点_基础_进行加密,并使用以下形式的循环:

std::ifstream ifs("data/data1.dt.cin");  // Input file for points
VoronoiDiagram vd;                     // CGAL Voronoi diagram data structure
Site t;
int ctr=0;
while ( ifs >> t ) {                  // Read a site from the file...
    Face_handle fh = vd.insert(t);     // ...add the site...
    fh->dual()->info() = ctr++;       // ...and attach some info to it
}
这个循环的灵感来自于这个问题的答案。但它有一个主要缺点。一次向Voronoi图中添加一个点,这非常缓慢。一次插入一系列点要快得多

CGAL文档给出了如何在Delaunay三角剖分环境中实现这一点的示例,但这些解决方案似乎不适用于Voronoi图。例如,下面是我尝试使用boostzip迭代器的例子,如CGAL示例中所建议的。我的示例是对CGAL示例代码的一个小修改

由于模板的原因,错误很长,但似乎相当于
Voronoi\u diagram\u 2::insert()
不知道如何使用
boost::zip\u迭代器


我错过什么了吗?向CGAL Voronoi图中添加一系列具有信息的点的正确方法是什么?

请注意,插入一系列点时,CGAL首先对它们进行排序(空间排序包),然后逐个插入。如果缺少一个接口,则始终可以执行相同的操作。如果避免使用缓存策略,还可以使用
dual()
,const_cast访问delaunay三角剖分,以获得写访问权,然后插入其中。通过在github上提交问题来请求Voronoi_图的with_info接口是有意义的。
// standard includes
#include <iostream>
#include <fstream>
#include <cassert>
#include <list>
#include <boost/iterator/zip_iterator.hpp>
// includes for defining the Voronoi diagram adaptor
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Delaunay_triangulation_2.h>
#include <CGAL/Triangulation_vertex_base_with_info_2.h>
#include <CGAL/Voronoi_diagram_2.h>
#include <CGAL/Delaunay_triangulation_adaptation_traits_2.h>
#include <CGAL/Delaunay_triangulation_adaptation_policies_2.h>
// typedefs for defining the adaptor
typedef CGAL::Exact_predicates_inexact_constructions_kernel                  K;
typedef CGAL::Triangulation_vertex_base_with_info_2<int, K>                  VB;
typedef CGAL::Triangulation_data_structure_2<VB>                             TDS;
typedef CGAL::Delaunay_triangulation_2<K,TDS>                                DT;
typedef CGAL::Delaunay_triangulation_adaptation_traits_2<DT>                 AT;
typedef CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<DT> AP;
typedef CGAL::Voronoi_diagram_2<DT,AT,AP>                                    VD;
// typedef for the result type of the point location
typedef AT::Site_2                    Site_2;
typedef AT::Point_2                   Point_2;
typedef VD::Locate_result             Locate_result;
typedef VD::Vertex_handle             Vertex_handle;
typedef VD::Face_handle               Face_handle;
typedef VD::Halfedge_handle           Halfedge_handle;
typedef VD::Ccb_halfedge_circulator   Ccb_halfedge_circulator;
int main()
{
  std::ifstream ifs("data/data1.dt.cin");
  VD vd;
  Site_2 t;
  std::list<Site_2> sites;
  std::list<int>    site_info;
  int ctr=0;
  while ( ifs >> t ) { 
      sites.push_back(t);         // Add the site...
      site_info.push_back(ctr++); // ...attach some info to it
  }
  ifs.close();
  vd.insert(
      boost::make_zip_iterator(boost::make_tuple(sites.begin(), 
                                                 site_info.begin())),
      boost::make_zip_iterator(boost::make_tuple(sites.end(), 
                                                 site_info.end())));
  return 0;
}
In file included from vdtst3.cxx:11:0:
/usr/local/include/CGAL/Voronoi_diagram_2.h: In instantiation of ‘CGAL::Voronoi_diagram_2<DG, AT, AP>::size_type CGAL::Voronoi_diagram_2<DG, AT, AP>::insert(Iterator, Iterator) [with Iterator = boost::zip_iterator<boost::tuples::tuple<std::_List_iterator<CGAL::Point_2<CGAL::Epick> >, std::_List_iterator<int>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >; DG = CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >; AT = CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; AP = CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::size_type = long unsigned int]’:
vdtst3.cxx:47:71:   required from here
/usr/local/include/CGAL/Voronoi_diagram_2.h:769:17: error: no matching function for call to ‘CGAL::Voronoi_diagram_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >, CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > > >::insert(boost::iterator_facade<boost::zip_iterator<boost::tuples::tuple<std::_List_iterator<CGAL::Point_2<CGAL::Epick> >, std::_List_iterator<int>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >, boost::tuples::cons<CGAL::Point_2<CGAL::Epick>&, boost::tuples::cons<int&, boost::tuples::null_type> >, boost::bidirectional_traversal_tag, boost::tuples::cons<CGAL::Point_2<CGAL::Epick>&, boost::tuples::cons<int&, boost::tuples::null_type> >, long int>::reference)’
       insert(*it);
                 ^
/usr/local/include/CGAL/Voronoi_diagram_2.h:769:17: note: candidates are:
/usr/local/include/CGAL/Voronoi_diagram_2.h:744:22: note: CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle CGAL::Voronoi_diagram_2<DG, AT, AP>::insert(const Site_2&, const Tag_true&) [with DG = CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >; AT = CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; AP = CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle = CGAL::VoronoiDiagram_2::Internal::Handle_adaptor<CGAL::VoronoiDiagram_2::Internal::Face<CGAL::Voronoi_diagram_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >, CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > > > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Site_2 = CGAL::Point_2<CGAL::Epick>; CGAL::Tag_true = CGAL::Boolean_tag<true>]
   inline Face_handle insert(const Site_2& t, const Tag_true&) {
                      ^
/usr/local/include/CGAL/Voronoi_diagram_2.h:744:22: note:   candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/Voronoi_diagram_2.h:751:22: note: CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle CGAL::Voronoi_diagram_2<DG, AT, AP>::insert(const Site_2&, const Tag_false&) [with DG = CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >; AT = CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; AP = CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle = CGAL::VoronoiDiagram_2::Internal::Handle_adaptor<CGAL::VoronoiDiagram_2::Internal::Face<CGAL::Voronoi_diagram_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >, CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > > > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Site_2 = CGAL::Point_2<CGAL::Epick>; CGAL::Tag_false = CGAL::Boolean_tag<false>]
   inline Face_handle insert(const Site_2& t, const Tag_false&) {
                      ^
/usr/local/include/CGAL/Voronoi_diagram_2.h:751:22: note:   candidate expects 2 arguments, 1 provided
/usr/local/include/CGAL/Voronoi_diagram_2.h:757:22: note: CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle CGAL::Voronoi_diagram_2<DG, AT, AP>::insert(const Site_2&) [with DG = CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >; AT = CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; AP = CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Face_handle = CGAL::VoronoiDiagram_2::Internal::Handle_adaptor<CGAL::VoronoiDiagram_2::Internal::Face<CGAL::Voronoi_diagram_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >, CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >, CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > > > > >; CGAL::Voronoi_diagram_2<DG, AT, AP>::Site_2 = CGAL::Point_2<CGAL::Epick>]
   inline Face_handle insert(const Site_2& t) {
                      ^
/usr/local/include/CGAL/Voronoi_diagram_2.h:757:22: note:   no known conversion for argument 1 from ‘boost::iterator_facade<boost::zip_iterator<boost::tuples::tuple<std::_List_iterator<CGAL::Point_2<CGAL::Epick> >, std::_List_iterator<int>, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type, boost::tuples::null_type> >, boost::tuples::cons<CGAL::Point_2<CGAL::Epick>&, boost::tuples::cons<int&, boost::tuples::null_type> >, boost::bidirectional_traversal_tag, boost::tuples::cons<CGAL::Point_2<CGAL::Epick>&, boost::tuples::cons<int&, boost::tuples::null_type> >, long int>::reference {aka boost::tuples::cons<CGAL::Point_2<CGAL::Epick>&, boost::tuples::cons<int&, boost::tuples::null_type> >}’ to ‘const Site_2& {aka const CGAL::Point_2<CGAL::Epick>&}’
/usr/local/include/CGAL/Voronoi_diagram_2.h:766:20: note: template<class Iterator> CGAL::Voronoi_diagram_2<DG, AT, AP>::size_type CGAL::Voronoi_diagram_2<DG, AT, AP>::insert(Iterator, Iterator) [with Iterator = Iterator; DG = CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > >; AT = CGAL::Delaunay_triangulation_adaptation_traits_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >; AP = CGAL::Delaunay_triangulation_caching_degeneracy_removal_policy_2<CGAL::Delaunay_triangulation_2<CGAL::Epick, CGAL::Triangulation_data_structure_2<CGAL::Triangulation_vertex_base_with_info_2<int, CGAL::Epick> > > >]
   inline size_type insert(Iterator first, Iterator beyond) {
                    ^
/usr/local/include/CGAL/Voronoi_diagram_2.h:766:20: note:   template argument deduction/substitution failed:
/usr/local/include/CGAL/Voronoi_diagram_2.h:769:17: note:   candidate expects 2 arguments, 1 provided
       insert(*it);