!*********************************************************************************************************************************************************!
!* 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. 																															 *!
!*********************************************************************************************************************************************************!

!Web geometry creating module

/PREP7

ALLSEL,ALL

! use information from arrays: webinfo, weblam1, weblam2, NWEBLAY

pi = 3.14159265359

*IF,FLIPFLAG,EQ,0,THEN
	*DO,i,1,nwebs
		theta = webagl_%i%*pi/180
		webY = ABS(0.25*CL*SIN(theta))
		webX = ABS(0.25*CL*COS(theta))
		webcentx = webx_%i%*CL-centx
		
		*GET,CKPN,KP,0,NUM,MAX	           !CKPN: Current keypoint numbers
		*IF,webagl_%i%,LE,90,THEN
				K, CKPN+1, webcentx - webX, -webY  ! lower (high pressure side) keypoint 
				K, CKPN+2, webcentx + webX,  webY                    !upper (low pressure side) keypoint
			*ELSEIF,webagl_%i%,GT,90
				K, CKPN+1, webcentx - webX,  webY                    !upper (low pressure side) keypoint
				K, CKPN+2, webcentx + webX, -webY  ! lower (high pressure side) keypoint	
			*ELSE
		*ENDIF
		L, CKPN+1, CKPN+2
	*ENDDO
*ENDIF

*IF,FLIPFLAG,EQ,1,THEN
	*DO,i,1,nwebs
		theta = webagl_%i%*pi/180
		webY = ABS(0.25*CL*SIN(theta))
		webX = ABS(0.25*CL*COS(theta))
		webcentx = webx_%i%*CL-centx
		
		*GET,CKPN,KP,0,NUM,MAX	           !CKPN: Current keypoint numbers
		*IF,webagl_%i%,LE,90,THEN
				K, CKPN+1, -(webcentx + webX),  webY  ! lower (high pressure side) keypoint 
				K, CKPN+2,  -(webcentx - webX), -webY                   !upper (low pressure side) keypoint
			*ELSEIF,webagl_%i%,GT,90
				K, CKPN+1, -(webcentx + webX), -webY                   !upper (low pressure side) keypoint
				K, CKPN+2, -(webcentx - webX),  webY  ! lower (high pressure side) keypoint	
			*ELSE
		*ENDIF
		L, CKPN+1, CKPN+2
	*ENDDO
*ENDIF


ALLSEL,ALL
/PNUM,KP,0  
/PNUM,LINE,1
/PNUM,AREA,0
/PNUM,VOLU,0
/PNUM,NODE,0
/PNUM,TABN,0
/PNUM,SVAL,0  
/NUMBER,0 !Specify whether numbers, colors, or both are used for displays 0:color and number; 1:only color; 2:only number; -1:nothing
/AUTO,1 
/REP,FAST
LPLOT

