Changeset 2627 in lmdz_wrf


Ignore:
Timestamp:
Jun 23, 2019, 8:33:06 PM (5 years ago)
Author:
lfita
Message:

First working version of `pile_polygons'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2626 r2627  
    15951595        linti = list(inti)
    15961596        for ip in range(iNpts):
     1597            iip1 = ip+1
     1598            if ip == iNpts-1: iip1 = 0
     1599            print ip, ipoly[ip,:], ':', ipoly[iip1,:]
    15971600            Nc = linti.count(ip)
    1598             dists = np.zeros((Nc), dtype=np.float)
     1601            ldists = []
     1602            ddists = {}
    15991603            if Nc > 0:
    16001604                iic = gen.multi_index_vec(inti,ip)
    1601                 # Sortering from distance respect the vertex ip
     1605                mindist = 1000000.
     1606                # Sorting from distance respect the vertex ip
    16021607                for ic in range(Nc):
    1603                     dists[ic] = dist_points(ipoly[ip,:], pts[inti[ic],:])
     1608                    ddists[iic[ic]] = dist_points(ipoly[ip,:], pts[iic[ic],:])
     1609                    ldists.append(ddists[iic[ic]])
     1610                    print '  ', ic, ';', iic[ic], '=', pts[iic[ic],:], ddists[iic[ic]]
     1611                ldists.sort()
     1612                print '    ldists', ldists
     1613                newipoly.append(ipoly[ip,:])
     1614                for ic in range(Nc):
     1615                    iic = gen.dictionary_key(ddists,ldists[ic])
     1616                    newipoly.append(pts[iic,:])
     1617                    print '  ', ic, '|', iic, ';', pts[iic,:]
     1618                    if ic < Nc-1: newipoly.append([gen.fillValueF, gen.fillValueF])
     1619                newipoly.append(ipoly[iip1,:])
     1620
    16041621            else:
    16051622                newipoly.append(ipoly[ip,:])
    1606 
    1607 
    1608 
    1609         Npi=0
    1610         for ip in range(Nint):
    1611             # Determine side of the point of the polygon to cut
    1612             #   Here are assumed that all polygons are clockwise created, thus any
    1613             #   cutting point will lay to the left side of the face which cuts
    1614             #   but we need to deterime if it is the starting point or the ending point
    1615             #   the one which lays to the left of the over pile polygon
    1616             iip = inti[ip]
    1617             iip1 = iip + 1
    1618             if iip1 > iNpts-1: iip1=0
    1619             pip = intp[ip]
    1620             pip1 = pip + 1
    1621             if pip1 > Npts-1: pip1=0
    1622 
    1623             print ip, ': Lluis iip, iip1', iip, iip1, 'pip, pip1', pip, pip1
    1624 
    1625             iface = ipoly[iip,:]-poly[pip,:]
    1626             pface = poly[pip1,:]-poly[pip,:]
    1627             ifangle=angle_vectors2D(pface,iface)
    1628 
    1629             iface = ipoly[iip1,:]-poly[pip,:]
    1630             pface = poly[pip1,:]-poly[pip,:]
    1631             efangle=angle_vectors2D(pface,iface)
    1632 
    1633             if ifangle < 0.:
    1634                 # Initial point of the cuted face to the left of the overlying polygon
    1635                 for iv in range(Npi,Npi+iip): newipoly.append(ipoly[iv,:])
    1636                 Npi = Npi + iip
    1637                 newipoly.append(pts[ip])
    1638                 newipoly.append([gen.fillValueF, gen.fillValueF])
    1639 
    1640             elif efangle < 0.:
    1641                 # Ending point of the cuted face to the left of the overlying polygon
    1642                 newipoly.append([gen.fillValueF, gen.fillValueF])
    1643                 newipoly.append(pts[ip])
    1644                 newipoly.append(ipoly[iip1,:])
    1645                 Npi = iip1
    1646             else:
    1647                 print errormsg
    1648                 print '  ' + fname + ': No left point found !!'
    1649                 print '    crossing point number', ip, 'below polygon vertex:',      \
    1650                   inti[ip], 'above', intp[ip]
    1651                 print '    for pile face', poly[pip,:], '->', poly[pip1,:],          \
    1652                   'and below face', ipoly[iip,:], '->', ipoly[iip1,:]
    16531623   
    16541624        pilepolygons[polyns[Npolys-1]] = newipoly
Note: See TracChangeset for help on using the changeset viewer.