void RectCluster::partition() { VLOG(6) << "Grid side length: " << len_cell_; // random shift unsigned seed = std::chrono::system_clock::now().time_since_epoch().count(); std::default_random_engine generator(seed); std::uniform_real_distribution<double> distribution(0.0, (double) len_cell_); double rand_shift_x = distribution(generator); double rand_shift_y = distribution(generator); Vector_2 vec(rand_shift_x, rand_shift_y); LOG(INFO) << "Random shift: " << vec; // Build grid grid_ = new Grid(curve1_, curve2_, lb_, ub_, len_cell_); grid_->init(vec); for (auto it = grid_->begin(); it != grid_->end(); it++) { // quad-tree from containing points from curve1 QuadTree* curr_qt = it->second.first; // check if the node contains points from curve 1 if (curr_qt->is_empty()) { continue; } // find the neighboring nodes that contain points from curve 2 vector<QuadTree*> nbrs = grid_->neighbors(it->first, 1); //VLOG(7) << it->second.first->to_string() << " ---------- "; for (auto& qt : nbrs) { WSPD wspd(curr_qt, qt, 1 / eps_, lb_ / max(curve1_.size(), curve2_.size())); for (auto it = wspd.begin(); it != wspd.end(); it++) { gen_rect(it->first->idx_segments(), it->second->idx_segments()); } } } // after generating all rectangles, build a dependency graph of them and topologically sort them build_rect_graph(); topo_sort(); }
int main(int argc, char* argv[]) { const unsigned int D = 4; const unsigned int N = 100000; CGAL::Random rand(42); Random_points_iterator rpit(D, 1.0, rand); std::vector<Point_d> pts; pts.reserve(N); for(int i = 0; i < N; i++) { pts.push_back(*rpit++); } WSPD wspd(D, 1.0, pts.begin(), pts.end()); // Uncomment to print the size of the sets of each pair in the WSPD. /*for(Well_separated_pair_iterator it = wspd.wspd_begin(); it < wspd.wspd_end(); it++) { Well_separated_pair &pair = *it; std::cout << "(" << pair.a()->point_container().size() << ", " << pair.b()->point_container().size() << ")" << std::endl; }*/ // Prints the number of pairs in the WSPD. std::cout << wspd.wspd_size() << std::endl; return 0; }