! ***************** lofted_sur ****************************
!
! +++
! SUR_CONIC sample
!
! Start with as few limit/tangent curves as possible. Add curves and/or
! segments only as required to get the required shape and quality of the
! surface
!
! Use CUR_CONIC curves as limit and tangent curves.
! The CUR_SPLINE curve type easily oscillates. The spline curves
! need many, very well defined points in order to get a high
! quality curve. Such well-defined points cannot be defined
! manually (inteactively). Spline smoothing functions are
! needed in order to be able to use splines as input to
! surfaces.
!
! Generally favor use of P-value curves instead of
! midpoint curves to control the surface, since they are easier to alter when
! the shape and quality of the surface requires adjustment.
!
! It is recommended that the surface is defined in millimeters
! and the geometry calculation tolerances are trimmed for objects
! that are about a meter or two meters, i.e. point coordinates
! around 1000.0.
!
!
! 2006-03-02 John Hughes and Gunnar Liden
!
! ---
!************************************************************
!sdesce SUR_CONIC sample
!sdescs SUR_CONIC exempel
GLOBAL GEOMETRY MODULE lofted_sur(
INT graphic:=1 > "Graphic 0: Nothing 1: Surface 2: All");
! Internal variables
! BLANK values for graphic
INT bval_sur;
INT bval_csy;
INT bval_cur;
INT bval_poi;
REF int_id;
! Section curves
REF sect_1_id;
REF sect_2_id;
REF sect_3_id;
REF spine_id;
REF lim_1_id;
REF lim_2_id;
REF tang_1_id;
REF tang_2_id;
REF pcur_id;
VECTOR poi_l;
BEGINMODULE
! +++
! Initializations and check of input data
! ---
IF graphic = 0 THEN
bval_sur := 1;
bval_csy := 1;
bval_cur := 1;
bval_poi := 1;
ELIF graphic = 1 THEN
bval_sur := 0;
bval_csy := 1;
bval_cur := 1;
bval_poi := 1;
ELIF graphic = 2 THEN
bval_sur := 0;
bval_csy := 0;
bval_cur := 0;
bval_poi := 0;
ELSE
EXIT("lofted_sur: graphic not 0, 1 or 2");
ENDIF;
! Initializations of local variables in order avoid crashes
! using unitialized variables
int_id := #0;
sect_1_id := #0;
sect_2_id := #0;
sect_3_id := #0;
spine_id := #0;
lim_1_id := #0;
lim_2_id := #0;
tang_1_id := #0;
tang_2_id := #0;
pcur_id := #0;
! +++
! Generate local coord. systems in the GLOBAL (inherited) coord. system
! for the definition of section curves and the spine
! ---
csys_1p(#3,"Stern", vec(0, 20, 0), 0.0, 0.0, 0.0:BLANK=bval_csy);
csys_1p(#4,"Bow", vec(0, 20, 192), 0.0, 0.0, 0.0:BLANK=bval_csy);
csys_1p(#5,"Near-Stern", vec(0, 20, 12), 0.0, 0.0, 0.0:BLANK=bval_csy);
csys_1p(#6,"Near-Bow", vec(0, 20, 180), 0.0, 0.0, 0.0:BLANK=bval_csy);
csys_1p(#7,"Mid-Ship", vec(0, 20, 96), 0.0, 0.0, 0.0:BLANK=bval_csy);
! +++
! Create the spine curve. It is a straight line but sur_conic does
! not (yet) accept this type as input.
! ---
! Change to "Near-stern" coordinate system.
mode_local(#5);
cur_conic(#9,"FREE", vec(0, 0, 0), vec(0, 0, 168), 0.5,
vec(0, 0, 168), vec(0,
0, 0):BLANK=bval_cur);
spine_id := #9;
! +++
! Create the points that will be used for the definition of the limit curves.
! ---
! Change to "Near-stern" coordinate system.
mode_local(#5);
! Define points for "Near-stern" section curve
poi_free(#10,vec(4.083581517166, 21.720943070165, 0.0):BLANK=bval_poi);
poi_free(#11,vec(0.23613936746047, 0.25846526576975, 0.0):BLANK=bval_poi);
poi_free(#12,vec(2.6216848117135, 8.3495976410652, 0.0):BLANK=bval_poi);
poi_free(#13,vec(3.620285230238, 14.552799128792, 0.0):BLANK=bval_poi);
poi_free(#14,vec(1.623084393189, 4.3040314534175, 0.0):BLANK=bval_poi);
! Change to "Mid-ship" coordinate system.
mode_local(#7);
! Define points for "Mid-ship" section curve
poi_free(#17,vec(21.376287262411, 12.086888404603, 0.0):BLANK=bval_poi);
poi_free(#22,vec(9.7394376103902, 3.0714197177825, 0.0):BLANK=bval_poi);
poi_free(#23,vec(17.570912343131, 6.824288804571, 0.0):BLANK=bval_poi);
poi_free(#24,vec(4.5930399288751, 1.1677904708607, 0.0):BLANK=bval_poi);
poi_free(#25,vec(13.93487050293, 5.0294383717591, 0.0):BLANK=bval_poi);
poi_free(#26,vec(19.752537447251, 9.3262015290966, 0.0):BLANK=bval_poi);
! Change to "Near-bow" coordinate system.
mode_local(#6);
! Define points for "Near-bow" section curve
poi_free(#27,vec(0.17385061540016, 0.6782858073666, 0.0):BLANK=bval_poi);
poi_free(#28,vec(1.4045109305451, 4.6487125223747, 0.0):BLANK=bval_poi);
poi_free(#29,vec(2.2995366142868, 8.6735286444378, 0.0):BLANK=bval_poi);
poi_free(#31,vec(3.2505014032625, 14.819531641642, 0.0):BLANK=bval_poi);
poi_free(#32,vec(3.7539533503672, 18.409232507266, 0.0):BLANK=bval_poi);
! Change back to the GLOBAL coordinate system
mode_global();
! +++
! Create the section curves Near-stern, Mid-ship and Near-bow
! ---
cur_conic(#33,"FREE", on(#11), on(#14), on(#12), on(#13), on(#10)
:BLANK=bval_cur,PEN=2);
sect_1_id := #33;
cur_conic(#34,"FREE", on(#27), on(#28), on(#29), on(#31), on(#32)
:BLANK=bval_cur,PEN=2);
sect_1_id := #34;
cur_conic(#35,"FREE", on(#24), on(#22), on(#25), on(#26), on(#17)
:BLANK=bval_cur,PEN=2);
sect_1_id := #35;
! +++
! Define tangent definition points for the limit curves
! ---
POI_FREE(#201, VEC( 0.3916,20.2883, 13.9937):BLANK=bval_poi);
POI_FREE(#202, VEC( 4.5923,21.1728, 98.0000):BLANK=bval_poi);
POI_FREE(#203, VEC( 0.0169,20.6584,181.9937):BLANK=bval_poi);
POI_FREE(#204, VEC( 1.9111,24.2585, 13.9786):BLANK=bval_poi);
POI_FREE(#205, VEC( 9.7368,23.0755, 98.0000):BLANK=bval_poi);
POI_FREE(#206, VEC( 1.1114,24.7024,181.9777):BLANK=bval_poi);
POI_FREE(#207, VEC( 4.1736,34.3727, 13.9135):BLANK=bval_poi);
POI_FREE(#208, VEC(19.7481,29.3294, 98.0000):BLANK=bval_poi);
POI_FREE(#209, VEC( 2.9700,34.9125,180.9554):BLANK=bval_poi);
POI_FREE(#210, VEC( 4.6684,41.4148, 13.8879):BLANK=bval_poi);
POI_FREE(#211, VEC(21.3724,32.0475, 97.9996):BLANK=bval_poi);
POI_FREE(#212, VEC( 3.1594,38.6419,181.8953):BLANK=bval_poi);
! +++
! Create limit curves and tangent curves for the lofted surface
! The type of curve used for these curves are cur_conic curves
!
! ---
! Define 1st limit curve
cur_conic(#36,"FREE", on(#11), on(#201), 0.5,
on(#24), on(#202), 0.5,
on(#27), on(#203) :BLANK=bval_cur,PEN=2);
lim_1_id := #36;
! Define 1st tanget curve
cur_conic(#37,"FREE", on(#14), on(#204), 0.5,
on(#22), on(#205), 0.5,
on(#28), on(#206) :BLANK=bval_cur,PEN=2);
tang_1_id := #37;
! Define 2nd limit curve
cur_conic(#40,"FREE", on(#13), on(#207), 0.5,
on(#26), on(#208), 0.5,
on(#31), on(#209) :BLANK=bval_cur,PEN=2);
lim_2_id := #40;
! Define 2nd Tangent curve
cur_conic(#41,"FREE", on(#10), on(#210), 0.5,
on(#17), on(#211), 0.5,
on(#32), on(#212) :BLANK=bval_cur,PEN=2);
tang_2_id := #41;
! +++
! Define P-curve. The curve must be defined in the BASIC coordinate system
! ---
mode_basic();
cur_conic(#44,"FREE", vec( 0, 0.55, 0), vec(180, 0.45, 0), 0.5,
vec(180, 0.45, 0), vec( 0, 0.55,
0):BLANK=1);
mode_global();
pcur_id := #44;
! +++
! Define the lofted surface
! ---
sur_conic( #1, #9, lim_1_id, tang_1_id, "P", pcur_id, lim_2_id, tang_2_id
:PEN=3, BLANK=bval_sur);
ENDMODULE