Example #1
0
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]);
}
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();
}