!   TITLE:  profile_close.mac (CALCULATION)
!
!
!   OBJECTIVE:
!
!   This macro creates an enclosed profile from a series of overlaping, dis-
!   connected lines.
!
!
!   COMMAND SYNTAX:
!
!        PROFILE_CLOSE
!
!
!   DESCRIPTION:
!
!   A set of independent, overlapping lines with no intersection points, and
!   whose combined paths form a closed loop path, or series of closed paths,
!   are transformed into a connected, continuous closed loop chain profile.
!   Each line must be overlapped by other lines at at least 2 points along its
!   length. After execution, the resulting closed path is a set of lines that
!   share common end keypoints. The extraneous line segments resulting from the
!   line overlap operation (LOVLAP) are 'cleaned' from the new path.
!
!
!
*get,prkey_,active,0,prkey
/nopr

isolate_lines
!
lovlap,all
init_entity_num
!
isolate_lines
ksll,s
!
entity_array,'k','kset1_','array'
numkps_=ecount
!
*do,aaa_,1,numkps_,1
    ksel,s,kp,,kset1_(aaa_,1)
    lslk,s,0
    *get,numcl_,line,,count
    !
    *if,numcl_,lt,2,then
        ldele,all,,,1
    *endif
*enddo
!
init_entity_num
!
lplot
!
*set,numkps_,
*set,ecount,
*set,kset1_(1),
*set,numcl_,
*set,aaa_,

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