bool can_cut(const Polygon_2& polygon, Polygon_2::Vertex_circulator p, Polygon_2::Vertex_circulator c, Polygon_2::Vertex_circulator n, 
	     const boost::unordered_map<Point_3, boost::unordered_set<Segment_3_undirected> >& point2edges)
{
  Segment_2 seg(*p, *n);
  Point_2 mid((p->x()+n->x())/2.0, (p->y()+n->y())/2.0);
  return (CGAL::left_turn(*p, *c, *n) &&
	  is_legal(*p, *c, *n, point2edges) &&
	  !intersects_boundary(polygon, seg, true, false) &&
	  polygon.has_on_bounded_side(mid));
}
Exemple #2
0
static Point_2 centroid(const Polygon_2& poly)
{
  assert(poly.size() >= 3);

  Polygon_2::Vertex_circulator vcir = poly.vertices_circulator();
  Polygon_2::Vertex_circulator vend = vcir;
  Polygon_2::Vertex_circulator vnext = vcir; ++vnext;

  Vector_2 centre(0, 0);
  NT a(0), asum(0);
  do {
    a = (vcir->x() * vnext->y()) - (vnext->x() * vcir->y());
    centre = centre + a * ((*vcir - CGAL::ORIGIN) + (*vnext - CGAL::ORIGIN)); // slow...
    asum += a;
    vcir = vnext;
    ++vnext;
  } while(vcir != vend);
  centre = centre / (asum * 3);
  return CGAL::ORIGIN + centre;
}