def getLengthDecreaing(self): length_list = [] for i, poly in enumerate(self.polys): bottom_pt, top_pt = LPAssistant.getBottomPoint( poly), LPAssistant.getTopPoint(poly) length_list.append([i, top_pt[1] - bottom_pt[1]]) return length_list
def getNFP(self, j, i): # j是固定位置,i是移动位置 row = j * 192 + i * 16 + self.poly_status[j][2] * 4 + self.poly_status[ i][2] bottom_pt = LPAssistant.getBottomPoint(self.polys[j]) delta_x, delta_y = bottom_pt[0], bottom_pt[1] nfp = GeoFunc.getSlide(json.loads(self.fu_pre["nfp"][row]), delta_x, delta_y) return nfp
def getPrerequisite(self, i, orientation, **kw): # 获得全部NFP以及拆分情况 self.all_nfps,self.all_points_target,self.all_edges_target = [],[],[] offline = kw['offline'] for j, item in enumerate(self.polys): # 两个相等的情况,跳过否则会计算错误 if j == i: self.all_nfps.append([]) self.all_points_target.append([]) self.all_edges_target.append([]) continue # 预处理的情况 points_target, edges_target, nfp = [], [], [] if offline == True: row = j * 192 + i * 16 + self.poly_status[j][ 2] * 4 + orientation bottom_pt = LPAssistant.getBottomPoint(self.polys[j]) delta_x, delta_y = bottom_pt[0], bottom_pt[1] nfp = GeoFunc.getSlide(json.loads(self.fu_pre["nfp"][row]), delta_x, delta_y) else: nfp = LPAssistant.deleteOnline( self.NFPAssistant.getDirectNFP( self.polys[j], self.polys[i])) # NFP可能有同一直线上的点 # 计算对应目标函数 for pt_index in range(len(nfp)): edges_target.append( LPAssistant.getTargetFunction( [nfp[pt_index - 1], nfp[pt_index]])) points_target.append([nfp[pt_index][0], nfp[pt_index][1]]) # 添加上去 self.all_nfps.append(nfp) self.all_edges_target.append(edges_target) self.all_points_target.append(points_target) # 获取IFR self.target_poly = self.all_polygons[i][orientation] self.ifr = PackingUtil.getInnerFitRectangle(self.target_poly, self.cur_length, self.width) self.IFR = Polygon(self.ifr) self.final_IFR = Polygon(self.ifr)