我正在尝试CGAL库。特别是直骨架包。 我在执行文档中的一个简单示例时遇到了分段错误,我不知道这是一个可能的错误还是我做错了什么。我感谢任何帮助。提前谢谢。
这是一个例子:
#include <vector>
#include <boost/shared_ptr.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/Polygon_2.h>
#include <CGAL/create_offset_polygons_2.h>
//#include "print.h"
typedef CGAL::Exact_predicates_inexact_constructions_kernel K ;
typedef K::Point_2 Point ;
typedef CGAL::Polygon_2<K> Polygon_2 ;
typedef CGAL::Straight_skeleton_2<K> Ss ;
typedef boost::shared_ptr<Polygon_2> PolygonPtr ;
typedef boost::shared_ptr<Ss> SsPtr ;
typedef std::vector<PolygonPtr> PolygonPtrVector ;
int main()
{
Polygon_2 poly ;
poly.push_back( Point(-1,-1) ) ;
poly.push_back( Point(0,-12) ) ;
poly.push_back( Point(1,-1) ) ;
poly.push_back( Point(12,0) ) ;
poly.push_back( Point(1,1) ) ;
poly.push_back( Point(0,12) ) ;
poly.push_back( Point(-1,1) ) ;
poly.push_back( Point(-12,0) ) ;
SsPtr ss = CGAL::create_interior_straight_skeleton_2(poly);
double lOffset = 1 ;
PolygonPtrVector offset_polygons = CGAL::create_offset_polygons_2<Polygon_2>(lOffset,*ss);
//print_polygons(offset_polygons);
return 0;
}
根据调试器,在程序结束时,在其中一个析构函数中发生分段错误。
如果我用create_offset_polygons_2
注释该行,程序将正常退出。
调试器说错误发生在第62行的文件Handle.h
中:
60 ~Handle()
61 {
62 if ( PTR && (--PTR->count == 0))
63 delete PTR;
64 }
这是堆栈跟踪:
1 CGAL::Handle::~Handle Handle.h 62 0x41d3c4
2 CGAL::Lazy<CGAL::Line_2<CGAL::Simple_cartesian<CGAL::Interval_nt<false>>>, CGAL::Line_2<CGAL::Simple_cartesian<CGAL::Gmpq>>, CGAL::Gmpq, CGAL::Cartesian_converter<CGAL::Simple_cartesian<CGAL::Gmpq>, CGAL::Simple_cartesian<CGAL::Interval_nt<false>>, CGAL::NT_converter<CGAL::Gmpq, CGAL::Interval_nt<false>>>>::~Lazy Lazy.h 712 0x41ccbf
3 libstdc++-6!_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_ 0x6fe5a72a
4 libstdc++-6!_ZN11__gnu_debug30_Safe_unordered_container_base7_M_swapERS0_ 0x6fe5a780
5 ?? 0x6fe411b4
6 ?? 0x6fe41325
7 ?? 0x6fe41433
8 ntdll!RtlDecompressBuffer 0x77eae58e
9 ntdll!LdrShutdownThread 0x77e80e46
10 ?? 0x6fe41410
11 ntdll!LdrShutdownProcess 0x77e6a862
12 ??
我正在使用: