【发布时间】:2014-05-15 12:03:34
【问题描述】:
我正在尝试使交叉函数在继承自 CGAL 多边形的自定义多边形上工作。这是一个无法编译的示例
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
#include <CGAL/Point_2.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/Polygon_with_holes_2.h>
#include <CGAL/Boolean_set_operations_2.h>
#include <iostream>
#include <vector>
typedef CGAL::Exact_predicates_exact_constructions_kernel Kernel;
typedef CGAL::Polygon_2<Kernel> SimplePolygon;
typedef CGAL::Polygon_with_holes_2<Kernel> Polygon;
typedef CGAL::Point_2<Kernel> Point;
class MyPolygon : public SimplePolygon {
};
int main( ) {
MyPolygon polygon1, polygon2; // This doesn't work!
//SimplePolygon polygon1, polygon2; // This works!
// Populate the polygons...
std::vector<Polygon> intersections;
CGAL::intersection(polygon1, polygon2, std::back_inserter(intersections));
return 0;
}
显然,使用SimplePolygon 行可以正常工作。但是当我尝试使用MyPolygon 行编译时,出现以下错误
In file included from main.cpp:25:
/opt/local/include/CGAL/Boolean_set_operations_2.h:839:57: error: no type named 'value_type' in 'std::__1::iterator_traits<MyPolygon>'
typedef typename std::iterator_traits<InputIterator>::value_type InputPolygon;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
/opt/local/include/CGAL/Boolean_set_operations_2.h:907:12: note: in instantiation of template class 'CGAL::map_iterator_to_traits<MyPolygon>' requested here
typename map_iterator_to_traits<InputIterator>::Traits tr;
^
main.cpp:62:9: note: in instantiation of function template specialization 'CGAL::intersection<MyPolygon, std::__1::back_insert_iterator<std::__1::vector<CGAL::Polygon_with_holes_2<CGAL::Epeck, std::__1::vector<CGAL::Point_2<CGAL::Epeck>, std::__1::allocator<CGAL::Point_2<CGAL::Epeck> > > >, std::__1::allocator<CGAL::Polygon_with_holes_2<CGAL::Epeck, std::__1::vector<CGAL::Point_2<CGAL::Epeck>, std::__1::allocator<CGAL::Point_2<CGAL::Epeck> > > > > > > >' requested here
CGAL::intersection(polygon1, polygon2, std::back_inserter(intersections));
^
In file included from main.cpp:25:
/opt/local/include/CGAL/Boolean_set_operations_2.h:840:54: error: no type named 'Traits' in 'CGAL::Gps_default_traits<int>'
typedef typename Gps_default_traits<InputPolygon>::Traits Traits;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~
我错过了什么?
【问题讨论】:
标签: intersection cgal