Está en la página 1de 2

!

READ THE FILE CONTAINING THE POLYGON INFORMATION


pol_file = TRIM(fls%dir_pol)//fls%SEP//TRIM(fls%pol_file)
write(*,*) 'Read: '//TRIM(pol_file)
open(unit=iu,FILE=pol_file)
rewind iu
read (iu,*,err=81) npol
do i=1,npol
read (iu,*,err=81) nspnts_pol,nstype_pol
xint = 0.0d0
yint = 0.0d0
do j=1,nspnts_pol
read (iu,*,err=81) x_ply(j),y_ply(j)
xint = xint+x_ply(j)
yint = yint+y_ply(j)
end do
! Calculate internal point of the polygon segment
xint = xint/dble(nspnts_pol)
yint = yint/dble(nspnts_pol)
if (fpl%nnode == 0) then
! Assign the first node
fpl%nnode = 1
fpl%x(1) = x_ply(1)
fpl%y(1) = y_ply(1)
ply_pnter(1) = 1
end if
do j=1,nspnts_pol
do k=1,fpl%nnode
dx = x_ply(j)-fpl%x(k)
dy = y_ply(j)-fpl%y(k)
dist = (dx*dx+dy*dy)**0.5d0
if (dist.lt.told) then
ply_pnter(j) = k
goto 43
end if
end do
fpl%nnode = fpl%nnode+1
ply_pnter(j) = fpl%nnode
fpl%x(fpl%nnode) = x_ply(j)
fpl%y(fpl%nnode) = y_ply(j)
43 continue
end do
do k=1,fpl%nnode
dx = dabs(xint-fpl%x(k))
dy = dabs(yint-fpl%y(k))
dist = (dx*dx+dy*dy)**0.5d0
if (dist < told) then
int_pnter(i) = k
goto 44
end if
end do
fpl%nnode = fpl%nnode+1
int_pnter(i) = fpl%nnode
fpl%x(fpl%nnode) = xint
fpl%y(fpl%nnode) = yint
44 continue
do j=1,(nspnts_pol-1)
fpl%nelm = fpl%nelm+1
fpl%node(fpl%nelm,1) = ply_pnter(j)
fpl%node(fpl%nelm,2) = ply_pnter((j+1))
fpl%node(fpl%nelm,3) = int_pnter(i)
fpl%itype(fpl%nelm) = nstype_pol
end do
fpl%nelm = fpl%nelm+1
fpl%node(fpl%nelm,1) = ply_pnter(nspnts_pol)
fpl%node(fpl%nelm,2) = ply_pnter(1)
fpl%node(fpl%nelm,3) = int_pnter(i)
fpl%itype(fpl%nelm) = nstype_pol
end do
close(unit=iu,status='keep')

También podría gustarte