Exemplo n.º 1
0
/**
 * intersection post processing
 */
void post_intersection( const GeometrySet<2>& input, GeometrySet<2>& output )
{
    //
    // reverse orientation of polygons if needed
    for ( GeometrySet<2>::SurfaceCollection::const_iterator it = input.surfaces().begin();
            it != input.surfaces().end();
            ++it ) {
        const CGAL::Polygon_with_holes_2<Kernel>& p = it->primitive();
        CGAL::Polygon_2<Kernel> outer = p.outer_boundary();

        if ( outer.orientation() == CGAL::CLOCKWISE ) {
            outer.reverse_orientation();
        }

        std::list<CGAL::Polygon_2<Kernel> > rings;

        for ( CGAL::Polygon_with_holes_2<Kernel>::Hole_const_iterator hit = p.holes_begin();
                hit != p.holes_end();
                ++hit ) {
            rings.push_back( *hit );

            if ( hit->orientation() == CGAL::COUNTERCLOCKWISE ) {
                rings.back().reverse_orientation();
            }
        }

        output.surfaces().push_back( CGAL::Polygon_with_holes_2<Kernel>( outer, rings.begin(), rings.end() ) );
    }

    output.points() = input.points();
    output.segments() = input.segments();
    output.volumes() = input.volumes();
}
Exemplo n.º 2
0
CGAL::Polygon_with_holes_2<Kernel> Polygon::toPolygon_with_holes_2( bool fixOrientation ) const
{
    std::list<CGAL::Polygon_2<Kernel> > holes;

    for ( size_t i = 0; i < numInteriorRings(); ++i ) {
        // note that the orientation is fixed here to avoid double reverse for interior rings
        CGAL::Polygon_2<Kernel> inner = interiorRingN( i ).toPolygon_2( false );

        if ( fixOrientation && inner.orientation() == CGAL::COUNTERCLOCKWISE ) {
            inner.reverse_orientation();
        }

        holes.push_back( inner );
    }

    CGAL::Polygon_2<Kernel> outer = exteriorRing().toPolygon_2( fixOrientation );
    return CGAL::Polygon_with_holes_2<Kernel>( outer,
            holes.begin(),
            holes.end() );
}
Exemplo n.º 3
0
void makeValidOrientation( CGAL::Polygon_2< Kernel >& polygon )
{
    if ( polygon.orientation() != CGAL::COUNTERCLOCKWISE ) {
        polygon.reverse_orientation() ;
    }
}