!*********************************************************************************************************************************************************!
!* Copyright (c) <2015> <Purdue University> All rights reserved.																					     *!
!*                                                                      																			     *!
!* Developed by:  Fang Jiang, Wenbin Yu                                                                                                                  *!
!*        <Prof. Yu’s Research Group>,                                                                                                                   *!
!*        <School of Aeronautics and Astronautics, Purdue University>                                                                                    *!
!*        <https://cdmhub.org/projects/ansysvabsgui2015>                                                                                                 *!
!*                                                                      																			     *!
!* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"),    *!
!* to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,  *!
!* and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:            *!
!*                                                                      																			     *!
!* •Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.                        *!
!*                                                                      																			     *!
!* •Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation *!
!*  and/or other materials provided with the distribution.                                                                                               *!
!*                                                                      																			     *!
!* •Neither the names of < Prof. Yu’s Research Group, School of Aeronautics and Astronautics, Purdue University >,                                       *!
!*  nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.   *!
!*                                                                      																			     *!
!* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *!
!* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR     *!
!* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER     *!
!* DEALINGS WITH THE SOFTWARE. 																															 *!
!*********************************************************************************************************************************************************!

	!===========================================================================================================================================
	!===========================================================================================================================================
	!===========================================================================================================================================
	/PREP7
	
				*DO, p, 1, Nlam
					*GET,CKPN,KP,0,NUM,MAXD
					*DO,j,1,KPC
						*IF,SEGPK_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j),GT,0,THEN
	
								DX = THsum_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(p,1)*ABS(SEGPKY_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j))
								DY = THsum_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(p,1)*ABS(SEGPKX_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j))
	
								X_ITR = SEGCX_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j) + DX                                     !X_ITR: new x coordinate
								Y_ITR = SEGCY_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j) - DY
	
							*ELSEIF,SEGPK_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j),EQ,0
	
								X_ITR = SEGCX_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j)
								Y_ITR = SEGCY_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j) - THsum_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(p,1)
	
							*ELSEIF,SEGPK_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j),LT,0
	
								DX = THsum_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(p,1)*ABS(SEGPKY_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j))
								DY = THsum_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(p,1)*ABS(SEGPKX_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j))
	
								X_ITR = SEGCX_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j) - DX
								Y_ITR = SEGCY_BSL_%BSL_NUM%_DIREC_%LAMDIREC%(j) - DY
	
							*ELSE
						*ENDIF
						K,CKPN+j,X_ITR,Y_ITR,0
					*ENDDO
					!--------------------------------------------------------------------------------------
					!Cutting line selection
					KSEL,S,KP,,CKPN+1,CKPN+KPC
	!				SPLINE,ALL
						BSPLIN,ALL
					KSEL,S,KP,,CKPN+1
					KSEL,A,KP,,CKPN+KPC
	
					LSLK,S,1
	
					*GET,OVERLAP_LPS_%p%,LINE,0,NUM,MAX
	
					KSEL,S,KP,,CKPN+2,CKPN+KPC-1				
					KDELE,ALL
	
				*ENDDO	
	!=======================================================================================================
	AllSEL,ALL
	/PNUM,KP,0  
	/PNUM,LINE,1
	/PNUM,AREA,0
	/PNUM,VOLU,0
	/PNUM,NODE,0
	/PNUM,TABN,0
	/PNUM,SVAL,0
	/PNUM,ELEM,0
	LPLOT
	!-------------------------------------------------------------------------------------------------------
	/NUMBER,1 !	0:color and number;  !	1:only color; !	2:only number; !-1:nothing