// local function : get the number of intersection points between rings of a polygon int numIntersectionPoints( const CGAL::Polygon_with_holes_2<Kernel>& poly ) { int numIntersectionPoints = 0; CGAL::Polygon_with_holes_2<Kernel>::Hole_const_iterator hit = poly.holes_begin(); for ( int i = 0; i == 0 || hit != poly.holes_end(); ++i ) { GeometrySet<2> ringI; if ( i == 0 ) { ringI.addSegments( poly.outer_boundary().edges_begin(), poly.outer_boundary().edges_end() ); } else { ringI.addSegments( hit->edges_begin(), hit->edges_end() ); hit++; } for ( CGAL::Polygon_with_holes_2<Kernel>::Hole_const_iterator hjt = hit; hjt != poly.holes_end(); ++hjt ) { GeometrySet<2> ringJ, inter; ringJ.addSegments( hjt->edges_begin(), hjt->edges_end() ); algorithm::intersection( ringI, ringJ, inter ); numIntersectionPoints += inter.points().size(); } } return numIntersectionPoints; }
void makeValidOrientation( CGAL::Polygon_with_holes_2< Kernel >& polygon ) { typedef CGAL::Polygon_with_holes_2< Kernel > Polygon_with_holes_2 ; if ( polygon.outer_boundary().orientation() != CGAL::COUNTERCLOCKWISE ) { polygon.outer_boundary().reverse_orientation() ; } for ( Polygon_with_holes_2::Hole_iterator it = polygon.holes_begin(); it != polygon.holes_end(); ++it ) { if ( it->orientation() != CGAL::CLOCKWISE ) { it->reverse_orientation() ; } } }
Polygon::Polygon( const CGAL::Polygon_with_holes_2< Kernel >& poly ) { _rings.push_back( new LineString() ); CGAL::Polygon_2<Kernel> outer = poly.outer_boundary(); CGAL::Polygon_2<Kernel>::Edge_const_iterator ei; for ( ei = outer.edges_begin(); ei != outer.edges_end(); ++ei ) { _rings.back().addPoint( ei->source() ); } _rings.back().addPoint( _rings.back().startPoint() ); for ( CGAL::Polygon_with_holes_2<Kernel>::Hole_const_iterator hit = poly.holes_begin(); hit != poly.holes_end(); ++hit ) { _rings.push_back( new LineString() ); CGAL::Polygon_2<Kernel>::Edge_const_iterator ei; for ( ei = hit->edges_begin(); ei != hit->edges_end(); ++ei ) { _rings.back().addPoint( ei->source() ); } _rings.back().addPoint( _rings.back().startPoint() ); } }