!   TITLE:  oval_area.mac (SM_TOOL)
!
!
!       Extended capability to create oval in various positions relative
!       to a specified CS.
!
!   OBJECTIVE:
!
!   This sub-macro creates an oval shaped area.
!
!
!   COMMAND SYNTAX:
!
!                   (1) (2)    (3)     (4)     (5)      (6)
!        OVAL_AREA, cs, rad, ov_leng, z_loc, cs__loc, 1_or_sep
!
!
!   ARGUMENTS:
!
!       (1) cs = coordinate system to build area relative to.
!
!       (2) rad = the radius of the oval ends.
!
!       (3) ov_leng = 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_or_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.
!
!
!   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.
!
!   To view an oval created from this macro, run the following example lines
!   of code (must execute 'mod_assemb_prep' prior to running):
!
!                           OVAL_AREA,0,0.5,5,0,0,0
!
!                           OVAL_AREA,0,0.5,5,0,1,0
!
!                           OVAL_AREA,0,0.5,5,0,2,1
!
!                           OVAL_AREA,0,0.5,5,0,3,0
!
!                           OVAL_AREA,0,0.5,5,0,4,1
!
!
!
*get,prkey_,active,0,prkey
/nopr
!
configuration,0
!
cs__=arg1
rade__=arg2
ovl__=arg3
zloc___=arg4
csloc__=arg5
sepa__=arg6
!
csys,cs__
clocal,csn+100,0,0,0,0
!
*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
!
configuration,1
init_entity_num
!
aplot
!
*set,cs__,
*set,rade__,
*set,ovl__,
*set,zloc___,
*set,csloc__,
*set,sepa__,
!
*if,prkey_,eq,1,then
    /go
*endif