Example #1
0
 def placeFirstPoly(self):
     '''
     放置第一个形状进去,并平移到left-bottom
     '''
     poly=self.polygons[0]
     poly_index=GeoFunc.checkTop(poly)
     left_index,bottom_index,right_index,top_index=GeoFunc.checkBound(poly)
     
     move_x=poly[left_index][0]
     move_y=poly[bottom_index][1]
     GeoFunc.slidePoly(poly,0,-move_y)
Example #2
0
    def getInnerFitRectangle(self,poly):
        '''
        获得IFR,同时平移到left-bottom
        '''
        poly_index=GeoFunc.checkTop(poly)
        left_index,bottom_index,right_index,top_index=GeoFunc.checkBound(poly)
        
        move_x=poly[left_index][0]
        move_y=poly[bottom_index][1]
        GeoFunc.slidePoly(poly,-move_x,-move_y)

        refer_pt=[poly[poly_index][0],poly[poly_index][1]]
        width=self.width-poly[right_index][0]
        height=self.height-poly[top_index][1]

        IFR=[refer_pt,[refer_pt[0]+width,refer_pt[1]],[refer_pt[0]+width,refer_pt[1]+height],[refer_pt[0],refer_pt[1]+height]]
        
        return IFR
Example #3
0
    def getInnerFitRectangleNew(self,poly):
        '''
        获得IFR,不平移
        '''
        poly_index=GeoFunc.checkBottom(poly)
        left_index,bottom_index,right_index,top_index=GeoFunc.checkBound(poly)
        
        move_x=poly[left_index][0]
        move_y=poly[top_index][1]
        new_poly=GeoFunc.getSlide(poly,-move_x,-move_y)

        refer_pt=[new_poly[poly_index][0],new_poly[poly_index][1]]
        width=self.width-new_poly[right_index][0]
        height=self.height-new_poly[bottom_index][1]

        IFR=[refer_pt,[refer_pt[0]+width,refer_pt[1]],[refer_pt[0]+width,refer_pt[1]+height],[refer_pt[0],refer_pt[1]+height]]
        print("计算出结果:",IFR)

        return IFR