def processRegion(region): area = [] if region.geom_type == "Polygon": area = GeoFunc.polyToArr(region) # 最终结果只和顶点相关 else: for shapely_item in list(region): if shapely_item.area > bias: area = area + GeoFunc.polyToArr(shapely_item) return area
def placePoly(self, index): adjoin = self.polygons[index] # 是否垂直 if self.vertical == True: ifr = packing.PackingUtil.getInnerFitRectangle( self.polygons[index], self.width, self.length) else: ifr = packing.PackingUtil.getInnerFitRectangle( self.polygons[index], self.length, self.width) differ_region = Polygon(ifr) for main_index in range(0, index): main = self.polygons[main_index] if self.NFPAssistant == None: nfp = NFP(main, adjoin).nfp else: nfp = self.NFPAssistant.getDirectNFP(main, adjoin) nfp_poly = Polygon(nfp) try: differ_region = differ_region.difference(nfp_poly) except: print('NFP failure, areas of polygons are:') self.showAll() for poly in main, adjoin: print(Polygon(poly).area) self.showPolys([main] + [adjoin] + [nfp]) print('NFP loaded from: ', self.NFPAssistant.history_path) differ = GeoFunc.polyToArr(differ_region) differ_index = self.getBottomLeft(differ) refer_pt_index = GeoFunc.checkTop(adjoin) GeoFunc.slideToPoint(self.polygons[index], adjoin[refer_pt_index], differ[differ_index])