!   TITLE:  tv_rec_bore.mac (SM_TOOL)
!
!
!       Expanded macro to include CSKP and pre-existing c.s.;
!       and for explicit input for each KP coordinate.
!
!
!   This sub-macro creates a hexahedral shaped volume which is to be sub-
!   tracted out, thereby creating a rectangular shaped cavity either within
!   or on the surface of the selected volume. This volume may have right
!   angled corners (phibev = 0), or angled (0 < phibev < 90) corners.
!
!   Parameters needed to be passed to this macro are:
!
!       A selected volume
!
!       opt = input options: 1,2,3,4,5,6,7,8,9,10,11 or 12
!
!       p1 = c.s. origin keypoint
!       p2 = c.s. +x axis keypoint
!       p3 = c.s. +y axis keypoint
!
!       xcutc = x component of cut volume local c.s.
!       ycutc = y component of cut volume local c.s.
!       zcutc = z component of cut volume local c.s.
!       rotxyc = 1st orientation angle (+x to +y) of 'reccutcs' c.s.
!       rotyzc = 2nd orientation angle (+y to +z) of 'reccutcs' c.s.
!       rotzxc = 3rd orientation angle (+z to +x) of 'reccutcs' c.s.
!
!       dcut = the depth or thickness of the volume
!       phibev = angle of bevel as measured from the normal
!                to the rectangular surfaces (from volume cut
!                coordinate system z axis)
!       xwcut = width of cut/volume (along local c.s. x axis)
!       yhcut = height of cut/volume (along local c.s. y axis)
!       x23 = x coordinate value for KP's in quadrants 2 and 3
!       x14 = x coordinate value for KP's in quadrants 1 and 4
!       y12 = y coordinate value for KP's in quadrants 1 and 2
!       y34 = y coordinate value for KP's in quadrants 3 and 4
!       acs1= pre-existing Active Coordinate System
!
!   The position and orientation of the volume cut c.s. is measured in
!   relation to the active c.s. for options 1,2,7 and 8 (See below). From
!   this c.s., the local coordinate system building this volume is placed.
!   Options 3,4,9 and 10 allow construction of the cut volume from a c.s.
!   defined by 3 KP's. Lastly, options 5,6,11 and 12 allow construction from
!   a pre-existing c.s.  Options 7 thru 12 correspond to the same input as
!   1 thru 6, except that these options are used when the dimensions of the
!   base rectangle are specified.
!
!
!   The 12 options of input data are summarized as follows:
!
!       1.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       2.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       3.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       4.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       5.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               x23, x14, y12, y34
!
!       6.  Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the surface, input:
!               xwcut, yhcut
!
!       7.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       8.  Create local c.s. by CLOCAL, input:
!               xcutc, ycutc, zcutc, rotxyc, rotyzc, rotzxc
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       9.  Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       10. Create local c.s. by CSKP, input:
!               p1, p2, p3
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!       11. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               x23, x14, y12, y34
!
!       12. Use pre-existing c.s.,input: acs1
!
!           Dimensions of rectangle at the base, input:
!               xwcut, yhcut
!
!
!
! REC_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc,x23,x14,y12,y34,dcut,phibev
!
!
! REC_BORE,opt,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc,xwcut,yhcut,dcut,phibev
!
!
! REC_BORE,opt,p1,p2,p3,x23,x14,y12,y34,dcut,phibev
!
!
! REC_BORE,opt,p1,p2,p3,xwcut,yhcut,dcut,phibev
!
!
! REC_BORE,opt,acs1,x23,x14,y12,y34,dcut,phibev
!
!
! REC_BORE,opt,acs1,xwcut,yhcut,dcut,phibev
!
!
*get,prkey_,active,0,prkey
/nopr

*ask,opt,OPTION,1
!
*if,opt,eq,1,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,2,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,3,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,4,then
    *ask,p1,origin KP of C.S.,
    *ask,p2,+X axis KP of C.S.,
    *ask,p3,+Y axis KP of C.S.,
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,5,then
    *ask,acs1,Active C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,6,then
    *ask,acs1,Active C.S.,0
    !
    *ask,xwcut,X width of surface cut,2
    *ask,yhcut,Y height of surface cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
*endif
!
*if,opt,eq,7,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,8,then
    *ask,xcutc,X coordinate of C.S.,0
    *ask,ycutc,Y coordinate of C.S.,0
    *ask,zcutc,Z coordinate of C.S.,0
    !
    *ask,rotxyc,XY rotation of C.S.,0
    *ask,rotyzc,YZ rotation of C.S.,0
    *ask,rotzxc,ZX rotation of C.S.,0
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,9,then
    *ask,p1,origin KP of C.S.,0
    *ask,p2,+X axis KP of C.S.,0
    *ask,p3,+Y axis KP of C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,10,then
    *ask,p1,origin KP of C.S.,
    *ask,p2,+X axis KP of C.S.,
    *ask,p3,+Y axis KP of C.S.,
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
*if,opt,eq,11,then
    *ask,acs1,Active C.S.,0
    !
    *ask,x23,X coordinate of KPs/quads 2&3,1
    *ask,x14,X coordinate of KPs/quads 1&4,1
    *ask,y12,Y coordinate of KPs/quads 1&2,1
    *ask,y34,Y coordinate of KPs/quads 3&4,1
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    x23=x23+x
    x14=x14+x
    y12=y12+x
    y34=y34+x
*endif
!
*if,opt,eq,12,then
    *ask,acs1,Active C.S.,0
    !
    *ask,xwcut,X width of base cut,2
    *ask,yhcut,Y height of base cut,2
    *ask,dcut,depth of cut,0.25
    *ask,phibev,bevel angle,0
    !
    x=dcut*tan(phibev*rconv)
    !
    xwcut=xwcut+2*x
    yhcut=yhcut+2*x
*endif
!
get_max_entity
!
v2bcut=vm   ! selected volume to be (2b) cut
!
*if,opt,eq,1,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,2,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,3,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,4,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,5,then
    csys,acs1
*endif
!
*if,opt,eq,6,then
    csys,acs1
*endif
!
*if,opt,eq,7,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,8,then
    csn=csn+1
    reccutcs=csn
    clocal,reccutcs,0,xcutc,ycutc,zcutc,rotxyc,rotyzc,rotzxc
*endif
!
*if,opt,eq,9,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,10,then
    csn=csn+1
    reccutcs=csn
    cskp,reccutcs,0,p1,p2,p3
*endif
!
*if,opt,eq,11,then
    csys,acs1
*endif
!
*if,opt,eq,12,then
    csys,acs1
*endif
!
*if,opt,eq,2,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,4,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,6,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,1,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,3,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,5,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,8,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,10,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,12,then
    k,,-xwcut/2,-yhcut/2,0
    k,,xwcut/2,-yhcut/2,0
    k,,xwcut/2,yhcut/2,0
    k,,-xwcut/2,yhcut/2,0
*endif
!
*if,opt,eq,7,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,9,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
*if,opt,eq,11,then
    k,,-x23,-y34,0
    k,,x14,-y34,0
    k,,x14,y12,0
    k,,-x23,y12,0
*endif
!
x=dcut*tan(phibev*rconv)
!
*if,opt,eq,2,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,4,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,6,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,1,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,3,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,5,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,8,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,10,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,12,then
    !
    *if,(xwcut/2-x),gt,0,then
        !
        *if,(yhcut/2-x),gt,0,then
            !
            k,,-(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),-(yhcut/2-x),-dcut
            k,,(xwcut/2-x),(yhcut/2-x),-dcut
            k,,-(xwcut/2-x),(yhcut/2-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,7,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,9,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
*if,opt,eq,11,then
    !
    *if,(x14-x),gt,-(x23-x),then
        !
        *if,(y12-x),gt,-(y34-x),then
            !
            k,,-(x23-x),-(y34-x),-dcut
            k,,(x14-x),-(y34-x),-dcut
            k,,(x14-x),(y12-x),-dcut
            k,,-(x23-x),(y12-x),-dcut
            !
            init_entity_num
            !
            v,km-7,km-6,km-5,km-4,km-3,km-2,km-1,km
            !
            init_entity_num
            !
            vsbv,v2bcut,vm,,delete,delete
            !
            init_entity_num
        *else
            init_entity_num
            !
            kdele,km-3,km,1
            csdele,csn
            csn=csn-1
            !
            init_entity_num
        *endif
    *else
        init_entity_num
        !
        kdele,km-3,km,1
        csdele,csn
        csn=csn-1
        !
        init_entity_num
    *endif
*endif
!
lplot
!
*set,xcutc, ! undefine parameters
*set,ycutc,
*set,zcutc,
*set,opt,
*set,acs1,
*set,rotxyc,
*set,rotyzc,
*set,rotzxc,
*set,x23,
*set,x14,
*set,y12,
*set,y34,
*set,phibev,
*set,dcut
*set,xwcut
*set,yhcut
*set,x,
!
abbres,new,tools,mac

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