Exemplo n.º 1
0
void Cut ( TPol & Poly , TLine Line , TPos Center )
{
     int N = Poly.size ();
     if ( N == 0 ) return;
     
     double Key = Line.value ( Center );
     TPol New;
     New.clear ();
     for ( int i = 0; i < N; i ++ ) if ( Line.value ( Poly [i] ) * Key < - eps ) {
         int j = ( i + N - 1 ) % N;
         if ( Line.value ( Poly [j] ) * Key > eps ) New.push_back ( Line * ( Poly [j] * Poly [i] ));
         j = ( i + 1 ) % N;
         if ( Line.value ( Poly [j] ) * Key > eps ) New.push_back ( Line * ( Poly [i] * Poly [j] ));
     } else New.push_back ( Poly [i] );
     Poly = New;
}