#
# This solid uses free form surfaces to create a rolling-pin. This
# file pushed the IBM PC version to its (memory) limits. Take <4 minutes
# on my 286 12MHz with 287.
#   One could do it much easier as one surface of revolution.
# final = surfrev(T1 + -T2) should do it. The unary minus flips the curve
# and the add, chain them together into a single curve by adding a linear
# segment (practically the rolling pin itself) between them.
#
#				Created by Gershon Elber,	May 90
#

time(true);

save_mat = view_mat;
view_mat = view_mat * scale( vector( 0.5, 0.5, 0.5 ) );
save_res = resolution;

resolution = 12;

T1 = cbspline( 3,
	       list( ctlpt( E3, 0.25,  0.0, 1.0 ),
		     ctlpt( E3, 0.01,  0.0, 1.0 ),
		     ctlpt( E3, 0.04,  0.0, 1.1 ),
		     ctlpt( E3, 0.04,  0.0, 1.25 ),
		     ctlpt( E3, 0.04,  0.0, 1.3 ),
		     ctlpt( E3, 0.001, 0.0, 1.3 ) ),
	       list( 0, 0, 0, 1, 2, 3, 4, 4, 4 ) );
T1 = surfrev( T1 );

T2 = T1 * rotx( 180 );
T = gpolygon( list( T1, T2 ), on );
free( T1 );
free( T2 );
interact( list( view_mat, T ) );

resolution = 20;

T3 = cylin( vector( 0.0, 0.0, -2.0 ), vector( 0.0, 0.0, 4.0 ), 0.1, 3 );
view( T3, false );

S1 = T3 * T;
free( T );
free( T3 );

final = convex( S1 );
free( S1 );

time( false ); # In Seconds

interact( final );
save( "solid5", final );
free( final );

view_mat = save_mat;
resolution = save_res;
