void mapdraw() { VisiLibity::Point pt1; //pt1=VisiLibity::Point(160.0f,180.0f); pt1=guest1.pos; pt1.snap_to_boundary_of(mapEnv); pt1.snap_to_vertices_of(mapEnv); visiPoly=VisiLibity::Visibility_Polygon(pt1,mapEnv,0.00001); Polygon_2 CGALvp; for (int j=0;j<visiPoly.n();j++){ CGALvp.push_back(Point_2(visiPoly[j].x(),visiPoly[j].y())); }; // CGAL::difference(mapEnvOB,holeCGAL,std::back_inserter(mapEnvOB)); Polygon_2 visRange=ngon(20,150.0); Pwh_list_2 intR; CGAL::intersection(CGALvp,visRange,std::back_inserter(intR)); visiBounded=intR.front(); tess = gluNewTess(); gluTessCallback (tess, GLU_TESS_BEGIN, (GLvoid (CALLBACK *)())tcbBegin); gluTessCallback (tess, GLU_TESS_VERTEX, (GLvoid (CALLBACK *)())tcbVertex); gluTessCallback (tess, GLU_TESS_END, (GLvoid (CALLBACK *)())tcbEnd); };
void GDALParceling::split_up(Pwh_list_2 & ress, Point_2 & p3, Point_2 & p1, Point_2 & p4, Vector_2 & v2, Point_2 & p2) { Polygon_with_holes_2 split_left_1; split_left_1.outer_boundary().push_back(p1); split_left_1.outer_boundary().push_back(p2); split_left_1.outer_boundary().push_back(p2+v2); split_left_1.outer_boundary().push_back(p1+v2); ress.push_back(split_left_1); //Right Polygon_with_holes_2 split_right_1; split_right_1.outer_boundary().push_back(p3-v2); split_right_1.outer_boundary().push_back(p3); split_right_1.outer_boundary().push_back(p4); split_right_1.outer_boundary().push_back(p4-v2); ress.push_back(split_right_1); }
void GDALParceling::split_left(Point_2 & p3, Pwh_list_2 & ress, Point_2 & p2, Point_2 & p4, Point_2 & p1, Vector_2 & v1) { Polygon_with_holes_2 split_left; split_left.outer_boundary().push_back(p1); split_left.outer_boundary().push_back(p1+v1); split_left.outer_boundary().push_back(p4+v1); split_left.outer_boundary().push_back(p4); ress.push_back(split_left); //Right Polygon_with_holes_2 split_right; split_right.outer_boundary().push_back(p2-v1); split_right.outer_boundary().push_back(p2); split_right.outer_boundary().push_back(p3); split_right.outer_boundary().push_back(p3-v1); ress.push_back(split_right); }
int main () { // Construct P - a bounded rectangle that contains a rectangular hole. Polygon_2 outP; Polygon_2 holesP[1]; outP.push_back (Point_2 (-3, -5)); outP.push_back (Point_2 (3, -5)); outP.push_back (Point_2 (3, 5)); outP.push_back (Point_2 (-3, 5)); holesP[0].push_back (Point_2 (-1, -3)); holesP[0].push_back (Point_2 (-1, 3)); holesP[0].push_back (Point_2 (1, 3)); holesP[0].push_back (Point_2 (1, -3)); Polygon_with_holes_2 P (outP, holesP, holesP + 1); std::cout << "P = "; print_polygon_with_holes (P); // Construct Q - a bounded rectangle that contains a rectangular hole. Polygon_2 outQ; Polygon_2 holesQ[1]; outQ.push_back (Point_2 (-5, -3)); outQ.push_back (Point_2 (5, -3)); outQ.push_back (Point_2 (5, 3)); outQ.push_back (Point_2 (-5, 3)); holesQ[0].push_back (Point_2 (-3, -1)); holesQ[0].push_back (Point_2 (-3, 1)); holesQ[0].push_back (Point_2 (3, 1)); holesQ[0].push_back (Point_2 (3, -1)); Polygon_with_holes_2 Q (outQ, holesQ, holesQ + 1); std::cout << "Q = "; print_polygon_with_holes (Q); // Compute the symmetric difference of P and Q. Pwh_list_2 symmR; Pwh_list_2::const_iterator it; CGAL::symmetric_difference (P, Q, std::back_inserter(symmR)); std::cout << "The symmetric difference:" << std::endl; for (it = symmR.begin(); it != symmR.end(); ++it) { std::cout << "--> "; print_polygon_with_holes (*it); } return 0; }
Polygon_2 CPElement::intersection_with_support(const Polygon_2& P) const { static log4cplus::Logger logger = Logger("intersection_with_support"); typedef std::list<Bso_polygon_with_holes_2> Pwh_list_2; Pwh_list_2 intR; Pwh_list_2::const_iterator it; CGAL::intersection(change_kernel<Bso_kernel>(P), change_kernel<Bso_kernel>(support()), std::back_inserter(intR)); if (intR.size() > 1) { LOG4CPLUS_WARN(logger, "intersection yielded more than one component"); } Polygon_with_holes_2 pwh = to_common(*intR.begin()); if (pwh.holes_begin() != pwh.holes_end()) { LOG4CPLUS_WARN(logger, "intersection yielded holes"); } return pwh.outer_boundary(); }
void arrangement::admissible_configuration(Op2_it pgn, std::vector<Offset_polygon_with_holes_2> &off,Pwh_list_2 &adm) { Offset_polygon_with_holes_2 poly(*pgn); std::vector<Offset_polygon_with_holes_2> polys; polys.push_back(poly); for (int i =0; i< (int) polys.size(); ++i) if (polys[i].outer_boundary().orientation() == -1) polys[i].outer_boundary().reverse_orientation(); for (int i =0; i< (int)polys.size(); ++i) { int before; bool flag = false; for (int k = 0; k < (int)off.size(); ++k) { if (off[k].outer_boundary().orientation() == -1) off[k].outer_boundary().reverse_orientation(); if (CGAL::do_intersect(polys[i], off[k])) { flag = true; before = (int) adm.size(); CGAL::difference(polys[i], off[k],std::back_inserter(adm)); polys.pop_back(); int cpt_tmp = (int)adm.size(); for (int j = before; j < cpt_tmp; ++j) { polys.push_back(adm.back()); adm.pop_back(); } } } if (flag) --i; } for (int k = 0; k < (int)polys.size(); ++k) adm.push_back(polys[k]); }