!   TITLE:  create_oval.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro creates an oval shaped area or set of lines.
!   (Supercedes OVAL_AREA.MAC)
!
!
!   COMMAND SYNTAX:
!
!                    (1) (2)    (3)    (4)    (5)      (6)    (7)   (8)
!       CREATE_OVAL, cs, rad, oval_l, z_loc, cs_loc, 1_?_sep, A_?, H_?_V
!
!
!   ARGUMENTS:
!
!       (1) cs = coordinate system to build area relative to.
!
!       (2) rad = the radius of the oval ends.
!
!       (3) oval_l = the over-all length of the oval.
!
!       (4) z_loc = location of the plane of the area along the Z axis
!                   of the coordinate system specified in argument 1.
!
!       (5) cs_loc = CS location on the oval. This location specifies the
!                    position/orientation of the oval relative to the CS
!                    specified in argument 1. The 5 different position
!                    options are as follows:
!
!               0 (or blank) = origin at the oval centroid, X axis
!                              passing through radiused-edge centers.
!
!               1 = origin at mid-point of straight edge, -Y axis normal
!                   to that edge, pointing toward oval centroid.
!
!               2 = origin at mid-point of straight edge, +Y axis normal
!                   to that edge, pointing toward oval centroid.
!
!               3 = origin at the center of radiused edge, +X axis
!                   pointing toward oval centroid.
!
!               4 = origin at the center of radiused edge, -X axis
!                   pointing toward oval centroid.
!
!       (6) 1_?_sep = create single oval area, or overlapped circular
!                     areas:
!
!               0 (or blank) = single oval area.
!
!               1 = separate circular-end areas attached to a
!                   rectangular area.
!
!       (7) A_? = boolean to determine if the oval is to be lines or
!                 an area:
!
!               0 = form oval from lines only (default).
!
!               1 = form oval as an area.
!
!       (8) H_?_V = boolean to determine if the oval is to be horizontal
!                   (default) or vertical:
!
!               0 = form oval in horizontal direction (default)
!                   [i.e., circular ends are symmetric about the Y axis
!                   at the centroid]
!
!               1 = form oval in vertical direction.
!                   [i.e., circular ends are symmetric about the X axis]
!                   at the centroid]
!
!
!   DESCRIPTION:
!
!   The oval is created relative to a coordinate system specified in argument
!   1. This coordinate system aligns itself with the mid-point of the straight
!   edge with the positive Y-axis pointing toward the centroid of the area. The
!   plane of the area is located along the Z axis of the specified C.S. by arg-
!   ument 4. This default value is 0 (i.e., the plane of the area is the XY
!   plane of the specified C.S.).
!
!   The width of the oval is the diameter of the semi-circular ends of the
!   area; and the over-all length is the length of the rectangular mid-sec-
!   tion of the area plus the diameter of the semi-circular ends.
!
!   If it is desired to create the oval in the vertical direction, then argument
!   8 should be specified as 1, where the oval is created rotated 90 degrees
!   CCW about the CS specified in argument 1.
!
!   To view an oval created from this macro, run the following example lines
!   of code (must execute 'mod_assemb_prep' prior to running):
!
!                           CREATE_OVAL,0,0.5,5,0,0,0,0,0
!
!                           CREATE_OVAL,0,0.5,5,0,1,0,0,1
!
!                           CREATE_OVAL,0,0.5,5,0,2,1,1,0
!
!                           CREATE_OVAL,0,0.5,5,0,3,0,1,1
!
!                           CREATE_OVAL,0,0.5,5,0,4,1,1,1
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
cs__=arg1
rade__=arg2
ovl__=arg3
zloc___=arg4
csloc__=arg5
sepa__=arg6
aorl__=arg7
horv__=arg8
!
*if,aorl__,eq,0,then
    sepa__=0
*endif
!
csys,cs__
!
*if,horv__,eq,0,then
    clocal,csn+100,0,0,0,0
*elseif,horv__,eq,1,then
    clocal,csn+100,0,0,0,0,90,0,0
*endif
!
*if,csloc__,eq,1,then
   clocal,csn+101,0,0,-rade__,0
*elseif,csloc__,eq,2,then
    clocal,csn+101,0,0,rade__,0
*elseif,csloc__,eq,3,then
    clocal,csn+101,0,(ovl__-2*rade__)/2,0,0
*elseif,csloc__,eq,4,then
    clocal,csn+101,0,-(ovl__-2*rade__)/2,0,0
*else
    clocal,csn+101,0,0,0,0
*endif
!
clocal,csn+102,0,-((ovl__-2*rade__)/2),0,0
clocal,csn+103,0,ovl__-2*rade__,0,0
!
csys,csn+101
create_rectangle,csn+51,-((ovl__-2*rade__)/2),(ovl__-2*rade__)/2,-rade__,rade__,zloc___,1
!
csys,csn+102
create_circ_area,rade__,zloc___,,2,90
!
csys,csn+103
create_circ_area,rade__,zloc___,,2,90
!
*if,sepa__,eq,0,then
    aadd,am-2,am-1,am
*elseif,sepa__,eq,1,then
    aovlap,am-2,am-1,am
    init_entity_num
    !
    aadd,am-4,am-2,am
*else
    aadd,am-2,am-1,am
*endif
!
init_entity_num
csdele,csn+100,csn+103,1
!
*if,aorl__,eq,0,then
    adele,am
    configuration,1
    init_entity_num
    lplot
*elseif,aorl__,eq,1,then
    configuration,1
    init_entity_num
    aplot
*endif
!
*set,cs__,
*set,rade__,
*set,ovl__,
*set,zloc___,
*set,csloc__,
*set,sepa__,
!
*if,prkey_,eq,1,then
    /go
*endif