#
# Simple demo of handling coplanar Booleans.
#
#						Gershon Elber,  July 1992.
#
save_res = resolution;

# iritstate( "coplanar", true ); # Try 'iritstate( "coplanar", false );'
IntrCrv = iritstate( "intercrv", false );
resolution = 20;

do_coplanars = procedure( a, b, fname ): c1: c2: c3: c4:
    interact( list( a, b ) ):
    c1 = a + b:
    interact( c1 ):
    c2 = a * b:
    interact( c2 ):
    c3 = a - b:
    interact( c3 ):
    c4 = b - a:
    interact( c4 ):
    save( fname, list( c1, c2 * tx( 4 ), c3 * tx( 8 ), c4 * tx( 12 ) ) );

a = cylin(vector( 0.0, 0.0, 0.0 ), vector( 0.0, 0.0, 1.0 ), 1.0, 3 );
b = cylin(vector( 0.5, 0.0, 0.0 ), vector( 0.0, 0.0, 1.0 ), 1.0, 3 );
do_coplanars( a, b, "coplanr1" );

a = cylin(vector( 0.0, 0.0, 0.0 ), vector( 0.0, 0.0, 1.0 ), 1.0, 3 );
b = a * scale(vector( 2.0, 0.5, 1.0 ) );
do_coplanars( a, b, "coplanr2" );

a = box(vector( -2.0,  -2.0, 0.0 ), 4.0, 4.0, 1.0 );
b = cylin(vector( 0.0, 0.0, 0.0 ), vector( 0.0, 0.0, 2.0 ), 1.0, 3 );
do_coplanars( a, b, "coplanr3" );

a = box( vector( 0, 0, 0 ), 1, 1, 2 );
b = box( vector( 0, 0, 0 ), 2, 1, 1 );
do_coplanars( a, b, "coplanr4" );

a = box( vector( 0, 0, 0 ), 1, 1, 2 );
b = box( vector( 0, 0.5, 0 ), 2, 1, 1 );
do_coplanars( a, b, "coplanr5" );

a = box( vector( 0, 0, 0 ), 1, 1, 2 );
b = box( vector( 0, 0.5, 0.5 ), 2, 1, 1 );
do_coplanars( a, b, "coplanr6" );

a = box( vector( 0,  0,  0 ), 1, 1, 2 );
b = box( vector( 0.5, 0.5, 0.5 ), 2, 1, 1 );
do_coplanars( a, b, "coplanr7" );

IntrCrv = iritstate( "intercrv", IntrCrv );
resolution = save_res;

free( IntrCrv );

free( a );
free( b );
