#
# Simple examples for the use of adaptive isocurves.
#
#					Gershon Elber May 1993.
#
srf1 = sbezier( list( list( ctlpt( E3, -0.5, -1.0,  0.0 ),
		            ctlpt( E3,  0.4,  0.0,  0.1 ),
		            ctlpt( E3, -0.5,  1.0,  0.0 ) ),
	              list( ctlpt( E3,  0.0, -0.7,  0.1 ),
		            ctlpt( E3,  0.0,  0.0,  0.0 ),
		            ctlpt( E3,  0.0,  0.7, -0.2 ) ),
	              list( ctlpt( E3,  0.5, -1.0,  0.1 ),
		            ctlpt( E3, -0.4,  0.0,  0.0 ),
		            ctlpt( E3,  0.5,  1.0, -0.2 ) ) ) );
color( srf1, magenta );

aiso = adapiso( srf1, COL, 0.1, true, false );
color( aiso, yellow );
interact( list( axes, srf1, aiso ) );
aiso = adapiso( srf1, COL, 0.1, false, false );
color( aiso, yellow );
interact( list( axes, srf1, aiso ) );
color( srf1, magenta );
aiso = adapiso( srf1, ROW, 0.05, true, false );
color( aiso, yellow );
interact( list( axes, srf1, aiso ) );
aiso = adapiso( srf1, ROW, 0.05, false, false );
color( aiso, yellow );
interact( list( axes, srf1, aiso ) );

srf2 = sbspline( 3, 3,
		 list( list( ctlpt( E3, 1.0, 0.0, 0.0 ),
		             ctlpt( E3, 1.0, 1.0, 2.0 ),
		             ctlpt( E3, 1.0, 2.0, 0.0 ) ),
        	       list( ctlpt( E3, 2.0, 0.9, 2.0 ),
	        	     ctlpt( E3, 2.0, 1.0, 0.0 ),
		             ctlpt( E3, 2.0, 1.1, 2.0 ) ),
        	       list( ctlpt( E3, 3.0, 0.0, 0.0 ),
	        	     ctlpt( E3, 3.0, 1.0, 2.0 ),
		             ctlpt( E3, 3.0, 2.0, 0.0 ) ),
        	       list( ctlpt( E3, 4.0, 0.9, 1.0 ),
	        	     ctlpt( E3, 4.0, 1.0, 0.0 ),
		             ctlpt( E3, 4.0, 1.1, 1.0 ) ) ),
		 list( list( KV_OPEN ),
		       list( KV_OPEN ) ) ) *
	scale( vector( 0.5, 0.5, 0.5 ) ) * trans( vector( -0.5, 0.0, 0.0 ) );
color( srf2, magenta );

aiso = adapiso( srf2, COL, 0.05, true, false );
color( aiso, yellow );
interact( list( axes, srf2, aiso ) );
save( "adap1iso", list( axes, srf2, aiso ) );

aiso = adapiso( srf2, COL, 0.05, false, false );
color( aiso, yellow );
interact( list( axes, srf2, aiso ) );
save( "adap2iso", list( SplitLst( axes ), srf2, aiso ) ); # Test SplitLst...

srf3 = sbspline( 3, 3,
		 list( list( ctlpt( E3, 1.0, 0.0, 0.0 ),
		             ctlpt( E3, 1.0, 1.0, 0.0 ),
		             ctlpt( E3, 1.0, 2.0, 0.0 ) ),
        	       list( ctlpt( E3, 2.0, 0.9, 0.0 ),
	        	     ctlpt( E3, 2.0, 1.0, 0.0 ),
		             ctlpt( E3, 2.0, 1.1, 0.0 ) ),
        	       list( ctlpt( E3, 3.0, 0.0, 0.0 ),
	        	     ctlpt( E3, 3.0, 1.0, 0.0 ),
		             ctlpt( E3, 3.0, 2.0, 0.0 ) ),
        	       list( ctlpt( E3, 4.0, 0.9, 0.0 ),
	        	     ctlpt( E3, 4.0, 1.0, 0.0 ),
		             ctlpt( E3, 4.0, 1.1, 0.0 ) ) ),
		 list( list( KV_OPEN ),
		       list( KV_OPEN ) ) ) *
	scale( vector( 0.5, 0.5, 0.5 ) ) * trans( vector( -0.5, 0.0, 0.0 ) );
color( srf3, magenta );

aiso = adapiso( srf3, COL, 0.05, true, false );
color( aiso, yellow );
interact( list( axes, srf3, aiso ) );
save( "adap3iso", list( axes, srf3, aiso ) );

aiso = adapiso( srf3, COL, 0.05, false, false );
color( aiso, yellow );
interact( list( axes, srf3, aiso ) );
save( "adap4iso", list( axes, srf3, aiso ) );

free( srf1 );
free( srf2 );
free( srf3 );
free( aiso );
