Changeset 2624 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jun 22, 2019, 9:56:59 PM (5 years ago)
Author:
lfita
Message:

Working on piling polygons

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2623 r2624  
    292292    1.57079632679
    293293    >>> angle_vectors2D([0.,1.], [1.,0.])
    294     1.57079632679
     294    -1.57079632679
    295295    """
    296296    fname = 'angle_vectors2D'
     
    310310
    311311    return theta
    312 
    313 print angle_vectors2D([1.,0.], [0.,1.])
    314 print angle_vectors2D([0.,1.], [1.,0.])
    315 
    316 quit()
    317312
    318313def max_coords_poly(polygon):
     
    15771572    """
    15781573    fname = 'pile_polygons'
    1579 
    1580     Npolys = len(polygons)
     1574    pilepolygons = dict(polygons)
     1575
     1576    Npolys = len(polyns)
    15811577    ipoly = polygons[polyns[Npolys-1]]
    15821578    iNpts = ipoly.shape[0]
    1583     pilepolygons = ipoly
    15841579
    15851580    pilesortpolys = polyns[::-1]
    15861581    pilesortpolys.remove(polyns[Npolys-1])
     1582    newipoly = []
    15871583    for polyn in pilesortpolys:
    15881584        poly = polygons[polyn]
     
    15911587          nvertexa=iNpts, nvertexb=Npts, nvertexab=iNpts*Npts, polya=ipoly,          \
    15921588          polyb=poly)
    1593         iip=0
    1594         for ip in Nint:
    1595             newipoly = ipoly[iip:inti]
    1596        
     1589        Npi=0
     1590        for ip in range(Nint):
     1591            # Determine side of the point of the polygon to cut
     1592            #   Here are assumed that all polygons are clockwise created, thus any
     1593            #   cutting point will lay to the left side of the face which cuts
     1594            #   but we need to deterime if it is the starting point or the ending point
     1595            #   the one which lays to the left of the over pile polygon
     1596            iip = inti[ip]
     1597            iip1 = iip + 1
     1598            if iip1 > iNpts-1: iip1=0
     1599            pip = intp[ip]
     1600            pip1 = pip + 1
     1601            if pip1 > Npts-1: pip1=0
     1602
     1603            iface = ipoly[iip,:]-poly[pip,:]
     1604            pface = poly[pip1,:]-poly[pip,:]
     1605            ifangle=angle_vectors2D(pface,iface)
     1606
     1607            iface = ipoly[iip1,:]-poly[pip,:]
     1608            pface = poly[pip1,:]-poly[pip,:]
     1609            efangle=angle_vectors2D(pface,iface)
     1610
     1611            if ifangle < 0.:
     1612                # Initial point of the cuted face to the left of the overlying polygon
     1613                for iv in range(Npi,Npi+iip): newipoly.append(ipoly[iv,:])
     1614                Npi = Npi + iip
     1615                newipoly.append([gen.fillvalueF, gen.fillvalueF])
     1616
     1617            elif efangle < 0.:
     1618                # Ending point of the cuted face to the left of the overlying polygon
     1619                newipoly.append([gen.fillvalueF, gen.fillvalueF])
     1620                newipoly.append(ipoly[iip1,:])
     1621                Npi = iip1
     1622            else:
     1623                print errormsg
     1624                print '  ' + fname + ': No left point found !!'
     1625                print '    for pile face'
     1626   
     1627        pilepolygons[polyns[Npolys-1]] = newipoly
    15971628       
    15981629    return pilepolygons
Note: See TracChangeset for help on using the changeset viewer.