#include #include #include #include #include #include #include #include #include #include namespace bg = boost::geometry; namespace bgi = boost::geometry::index; using namespace std; /*! Coordinate point definition */ typedef bg::model::point boost_pnt; /*! Bounding box definition */ typedef bg::model::box boost_box; /*! Cell details which will be stored in R-Tree */ typedef std::pair rtree_elem; /*! R-Tree for finding points in cells */ typedef bgi::rtree > boost_rtree; int main() { //--------- Read box elements ---------------------------------- string fname = "../testfile.dat"; ifstream vecfile_in(fname.c_str(), std::ios::in | std::ofstream::binary); vector boxes; std::ifstream os_in(fname.c_str(), std::ios::in | std::ofstream::binary); boost::archive::binary_iarchive oi(os_in, boost::archive::no_header); { oi >> boxes; } os_in.close(); std::vector bounding_boxes; cout << "nboxes available: " << boxes.size()/6 << endl; //-------- Create rtree elements -------------------------- //for(int i = 0; i < 30684; ++i) // Works //for(int i = 200; i < 30685+200; ++i) // Does not work for(int i = 0; i < 30685; ++i) // Does not work { float *bb = &(boxes[i*6]); boost_pnt p1(bb[0], bb[1], bb[2]); boost_pnt p2(bb[3], bb[4], bb[5]); boost_box box(p1, p2); bounding_boxes.emplace_back(box, i); } cout << "nelems for rtree: " << bounding_boxes.size() << endl; //--------- Create rtree (where the error occurs) -------- boost_rtree tree(bounding_boxes); // Using the following lines instead of the previous line works //boost_rtree tree; //tree.insert(bounding_boxes); }