I have got polygon-data which I processed. Now I want to see how well my processed data fits my original data. For this task I want to use BOOST's polygon set-operators.
The following code gives me a segfault though:
#include <iostream>
#include <boost/polygon/polygon.hpp>
using namespace boost::polygon::operators;
using namespace std;
typedef boost::polygon::polygon_data<double> BPolygon;
typedef boost::polygon::polygon_traits<BPolygon>::point_type BPoint;
typedef boost::polygon::polygon_set_data<double> BPolygonSet;
typedef std::vector<BPolygon> BPolygonVec;
double meassureError(BPolygonVec &polys1, BPolygonVec &polys2)
{
BPolygonSet set1;
BPolygonSet set2;
assign(set1, polys1);
assign(set2, polys2);
return area(set1 ^ set2);
}
int main(int argc, char *argv[])
{
BPolygonVec polys1;
BPolygonVec polys2;
loadPolysFromFile(polys1);
loadPolysFromFile(polys2);
cout << meassureError(polys1, polys2) << endl;
return 0;
}
gdb-output:
Program received signal SIGSEGV, Segmentation fault.
0x08156ce7 in std::list<boost::polygon::point_data<double>, std::allocator<boost::polygon::point_data<double> > >::begin (this=0x0) at /usr/include/c++/4.8.2/bits/stl_list.h:759
759 { return iterator(this->_M_impl._M_node._M_next); }
My data consists of about 2000 polygons with roughly 10 vertices each and I would expect to have enough memory in order to process that. What am I doing wrong? Thanks for your help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…