!   TITLE:  ara_part_arc.mac (SM_TOOL)
!
!
!   OBJECTIVE:
!
!   This sub-macro is used to partition a selected set of areas by using
!   arced partitioning line.
!
!   COMMAND SYNTAX:
!
!                         (1)   (2)      (3)       (4)    (5)
!           ARA_PART_ARC, acs, ang_ln, dist_pln, x_dist, y_dist
!
!
!   ARGUMENTS:
!
!       (1) acs = the active C.S. located on the areas plane. The XY plane
!                 must be aligned coplanar with the selected areas
!
!       (1) ang_ln = the angle of the cutting line as measured from the
!                    C.S. +x axis.
!
!       (2) dist_ln = the normal distance of the line from the C.S. origin
!                     as measured in the XY plane of the active C.S.
!                     X_DIST and Y_DIST are ignored.
!
!       (3) x_dist = the distance along the x (+ or -) axis the line
!                    intersects as measured in a plane parrallel to the
!                    XY plane. If this is specified, DO NOT specify Y_DIST
!                    and DIST_PLN.
!
!       (4) y_dist = the distance along the y (+ or -) axis the line
!                    intersects as measured in a plane parrallel to the
!                    XY plane. If this is specified, DO NOT specify X_DIST
!                    and DIST_PLN.
!
!
!   DESCRIPTION:
!
!   The cutting line is created at a user specified angle, ANG_PLN, with
!   respect to the +x axis, and is an angle (in degrees) range of:
!
!                           0 < ang_pln < 180
!
!   The distance of the line is the magnitude of a vector from the origin
!   oriented normal to the line. Therefore, it is the perpendicular distance
!   of the line from the origin. The line is constructed such that it lies
!   in a plane parrallel to the selected area(s). Therefore, the active C.S.
!   must have one of its principal planes oriented parrallel to the plane of
!   the areas to be partitioned.
!   to the z axis of the active C.S.
!
!
!
!
*get,prkey_,active,0,prkey
/nopr

actcs_=arg1
ang_=arg2
dist_=arg3
xdist_=arg4
ydist_=arg5
!
!
csys,actcs_
!
*get,acs_,active,,csys                  ! axis coordinate system (CS)
*get,acstyp_,cdsy,acs_,attr,kcs         ! axis CS type
!
*if,acstyp_,ne,0,then                   ! If axis CS is not cartesian, then
    create_cs,0,'acs_',0,0,0,0,0,0,0    ! create cartesian CS at same location.
*endif
!
cm,aset,area
!
max_enty_dim,'l'
!
lpln_=10*max_leng
!
*if,dist_,eq,0,then
    *if,xdist_,ne,0,then
        flag_=1
        create_cs,0,,1,xdist_,0,0,0,0,0
    *else
        *if,ydist_,ne,0,then
            flag_=1
            create_cs,0,,1,0,ydist_,0,0,0,0
        *endif
    *endif
*endif
!
*if,dist_,lt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_-90)*rconv)
        y_=abs(dist_)*sin((ang_-90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_-90)*rconv)
        y_=-abs(dist_)*sin((ang_-90)*rconv)
    *endif
*elseif,dist_,gt,0,then
    *if,ang_,lt,90,then
        x_=abs(dist_)*cos((ang_+90)*rconv)
        y_=abs(dist_)*sin((ang_+90)*rconv)
    *else
        x_=-abs(dist_)*cos((ang_+90)*rconv)
        y_=-abs(dist_)*sin((ang_+90)*rconv)
    *endif
*else
    *if,flag_,ne,1,then
        xdist_=0
        ydist_=0
        x_=0
        y_=0
    *endif
*endif
!
*if,flag_,ne,1,then
    create_cs,0,,1,x_,y_,0,0,0,0
*endif
!
!
!                (1)     (2)     (3)     (4)     (5)
! CREATE_ARCS, radius, ang_inc, n_arc, st_ang, fin_ang
!
create_arcs,

k,,lpln_,ang_,0
k,,-lpln_,ang_,0
!
create_lines,,1
!
_lcut=lm
!
cmsel,s,aset
!
*get,_alow,area,,num,min
*get,_ahigh,area,,num,max
!
*do,_iii,_alow,_ahigh,1
    *if,_alow,eq,_ahigh,then
        _kdv='delete'
    *else
        *if,_iii,ne,_ahigh,then
            _kdv='keep'             ! keep/delete decision variable
        *else
            _kdv='delete'
        *endif
    *endif
    !
    *if,asel(_iii),eq,1,then
        asbl,_iii,_lcut,,delete,_kdv
    *endif
*enddo
!
*get,_ptyp,parm,_lcut,type
!
*if,_ptyp,eq,3,then
    ldele,_lcut,,,1
*endif
!
*if,_ptyp,ne,3,then
    *if,lsel(_lcut),ne,0,then
        ldele,_lcut,,,1
    *endif
*endif
!
init_entity_num
!
csys,actcs_
!
*set,actcs_,
*set,_kdv,
*set,_alow,
*set,_ahigh,
*set,_lcut,
*set,_iii,
*set,_ptyp,
*set,x_,
*set,y_,
*set,ang_,
*set,dist_,
*set,xdist_,
*set,ydist_,
*set,lpln_,
*set,actcs_,
*set,acstyp_,
*set,acs_,
*set,flag_,
cmdele,aset,

*if,prkey_,eq,1,then
    /go
*endif