Changeset 2627 in lmdz_wrf
- Timestamp:
- Jun 23, 2019, 8:33:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2626 r2627 1595 1595 linti = list(inti) 1596 1596 for ip in range(iNpts): 1597 iip1 = ip+1 1598 if ip == iNpts-1: iip1 = 0 1599 print ip, ipoly[ip,:], ':', ipoly[iip1,:] 1597 1600 Nc = linti.count(ip) 1598 dists = np.zeros((Nc), dtype=np.float) 1601 ldists = [] 1602 ddists = {} 1599 1603 if Nc > 0: 1600 1604 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 1602 1607 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 1604 1621 else: 1605 1622 newipoly.append(ipoly[ip,:]) 1606 1607 1608 1609 Npi=01610 for ip in range(Nint):1611 # Determine side of the point of the polygon to cut1612 # Here are assumed that all polygons are clockwise created, thus any1613 # cutting point will lay to the left side of the face which cuts1614 # but we need to deterime if it is the starting point or the ending point1615 # the one which lays to the left of the over pile polygon1616 iip = inti[ip]1617 iip1 = iip + 11618 if iip1 > iNpts-1: iip1=01619 pip = intp[ip]1620 pip1 = pip + 11621 if pip1 > Npts-1: pip1=01622 1623 print ip, ': Lluis iip, iip1', iip, iip1, 'pip, pip1', pip, pip11624 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 polygon1635 for iv in range(Npi,Npi+iip): newipoly.append(ipoly[iv,:])1636 Npi = Npi + iip1637 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 polygon1642 newipoly.append([gen.fillValueF, gen.fillValueF])1643 newipoly.append(pts[ip])1644 newipoly.append(ipoly[iip1,:])1645 Npi = iip11646 else:1647 print errormsg1648 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,:]1653 1623 1654 1624 pilepolygons[polyns[Npolys-1]] = newipoly
Note: See TracChangeset
for help on using the changeset viewer.