在CGAL Voronoi图中插入带有信息的点范围

时间:2017-02-10 22:26:01

标签: c++ cgal voronoi

earlier question中,我询问在CGAL中构建Voronoi图时如何将非几何信息(例如权重)与网站相关联。 我的解决方案涉及#include-ing CGAL/Triangulation_vertex_base_with_info_2.h并使用了一个循环形式:

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
}

循环的灵感来自this question的答案。但它有一个主要缺点。点一次一个地添加到Voronoi图中,这非常慢。一次插入一系列点数要快得多。

CGAL文档提供了如何在Delaunay三角测量的上下文中执行此操作here的示例,但这些解决方案似乎不适用于Voronoi图。例如,这是我尝试使用boost zip迭代器,如CGAL示例Triangulation_2/info_insert_with_zip_iterator_2.cpp中所建议的那样。我的例子是对CGAL示例代码Voronoi_diagram_2/vd_2_point_location.cpp

的一个小修改
// 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;
}

此代码无法编译,错误来自boost::make_zip_iterator()行。这是来自g ++的错误:

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);

由于模板错误很长,但似乎Voronoi_diagram_2::insert()不知道如何处理boost::zip_iterator

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

0 个答案:

没有答案