コード例 #1
0
ファイル: archi.py プロジェクト: PharrellG/-archi
 def draw_roof_deck():
     #比较长短
     if co.dis_between_two_points(roof[1],roof[2]) > co.dis_between_two_points(roof[2],roof[3]):
         cv2.polylines(img,[np.int32(np.around([co.cen(roof[2],roof[3]),co.cen(roof[1],roof[0])]))],True,(255,255,255),1)
         draw_roof_tile( roof[2], roof[3], roof[0], roof[1] )
     else:
         cv2.polylines(img,[np.int32(np.around([co.cen(roof[1],roof[2]),co.cen(roof[3],roof[0])]))],True,(255,255,255),1)
         draw_roof_tile( roof[3], roof[0], roof[1], roof[2] )
コード例 #2
0
 def draw_roof_deck():
     #比较长短
     if co.dis_between_two_points(roof[1],roof[2]) > co.dis_between_two_points(roof[2],roof[3]):
         cv2.polylines(img,[np.int32(np.around([co.cen(roof[2],roof[3]),co.cen(roof[1],roof[0])]))],True,(255,255,255),1)
         draw_roof_tile( roof[2], roof[3], roof[0], roof[1] )
     else:
         cv2.polylines(img,[np.int32(np.around([co.cen(roof[1],roof[2]),co.cen(roof[3],roof[0])]))],True,(255,255,255),1)
         draw_roof_tile( roof[3], roof[0], roof[1], roof[2] )
コード例 #3
0
 def draw_roof_deck():
     #比较长短
     if co.dis_between_two_points(roof[1],roof[2]) > co.dis_between_two_points(roof[2],roof[3]):
         drawing.append( sdxf.Line(points=[co.cen(roof[2],roof[3]),co.cen(roof[1],roof[0])], layer='roof_deck') )
         draw_roof_tile( roof[2], roof[3], roof[0], roof[1] )
     else:
         drawing.append( sdxf.Line(points=[co.cen(roof[1],roof[2]),co.cen(roof[3],roof[0])], layer='roof_deck') )
         draw_roof_tile( roof[3], roof[0], roof[1], roof[2] )
コード例 #4
0
ファイル: archi.py プロジェクト: PharrellG/-archi
 def draw_roof_deck():
     #比较长短
     if co.dis_between_two_points(roof[1],roof[2]) > co.dis_between_two_points(roof[2],roof[3]):
         drawing.append( sdxf.Line(points=[co.cen(roof[2],roof[3]),co.cen(roof[1],roof[0])], layer='roof_deck') )
         draw_roof_tile( roof[2], roof[3], roof[0], roof[1] )
     else:
         drawing.append( sdxf.Line(points=[co.cen(roof[1],roof[2]),co.cen(roof[3],roof[0])], layer='roof_deck') )
         draw_roof_tile( roof[3], roof[0], roof[1], roof[2] )
コード例 #5
0
 def draw_roof_tile(p0, p1, p2, p3, min_dist = 6, opp=1):
     
     if opp == 1:
         draw_roof_tile(p0, p1, p2, p3, 3*min_dist, opp=-1)
     #initialization
     if p0[1]*opp < p1[1]*opp:
         p1, p2 = co.cen( p0, p1 ), co.cen( p2, p3 )
     else:
         p0, p3 = co.cen( p0, p1 ), co.cen( p2, p3 )
     
     tile_dist = min_dist
     tile_dist_max = co.dis_between_two_points( p0, p3 )
     while 1:
         if tile_dist >= tile_dist_max: break
         point1 = ( tile_dist*(p3[0]-p0[0])/tile_dist_max+p0[0], tile_dist*(p3[1]-p0[1])/tile_dist_max+p0[1] )
         point2 = ( tile_dist*(p2[0]-p1[0])/tile_dist_max+p1[0], tile_dist*(p2[1]-p1[1])/tile_dist_max+p1[1] )
         cv2.polylines(img,[np.int32(np.around([point1, point2]))],True,(255,255,255),1)
         tile_dist = tile_dist + min_dist
コード例 #6
0
    def draw_roof_tile(p0, p1, p2, p3, min_dist = 6, opp=1):
        
        if opp == 1:
            draw_roof_tile(p0, p1, p2, p3, 3*min_dist, opp=-1)
        #initialization
        if p0[1]*opp < p1[1]*opp:
            p1, p2 = co.cen( p0, p1 ), co.cen( p2, p3 )
        else:
            p0, p3 = co.cen( p0, p1 ), co.cen( p2, p3 )

        tile_dist = min_dist
        tile_dist_max = co.dis_between_two_points( p0, p3 )
        while 1:
            if tile_dist >= tile_dist_max: break
            point1 = ( tile_dist*(p3[0]-p0[0])/tile_dist_max+p0[0], tile_dist*(p3[1]-p0[1])/tile_dist_max+p0[1] )
            point2 = ( tile_dist*(p2[0]-p1[0])/tile_dist_max+p1[0], tile_dist*(p2[1]-p1[1])/tile_dist_max+p1[1] )
            drawing.append( sdxf.Line(points=[point1, point2], layer='roof_tile') )
            tile_dist = tile_dist + min_dist
コード例 #7
0
ファイル: archi.py プロジェクト: PharrellG/-archi
 def draw_roof_tile(p0, p1, p2, p3, min_dist = 6, opp=1):
     
     if opp == 1:
         draw_roof_tile(p0, p1, p2, p3, 3*min_dist, opp=-1)
     #initialization
     if p0[1]*opp < p1[1]*opp:
         p1, p2 = co.cen( p0, p1 ), co.cen( p2, p3 )
     else:
         p0, p3 = co.cen( p0, p1 ), co.cen( p2, p3 )
     
     tile_dist = min_dist
     tile_dist_max = co.dis_between_two_points( p0, p3 )
     while 1:
         if tile_dist >= tile_dist_max: break
         point1 = ( tile_dist*(p3[0]-p0[0])/tile_dist_max+p0[0], tile_dist*(p3[1]-p0[1])/tile_dist_max+p0[1] )
         point2 = ( tile_dist*(p2[0]-p1[0])/tile_dist_max+p1[0], tile_dist*(p2[1]-p1[1])/tile_dist_max+p1[1] )
         cv2.polylines(img,[np.int32(np.around([point1, point2]))],True,(255,255,255),1)
         tile_dist = tile_dist + min_dist
コード例 #8
0
ファイル: archi.py プロジェクト: PharrellG/-archi
    def draw_roof_tile(p0, p1, p2, p3, min_dist = 6, opp=1):
        
        if opp == 1:
            draw_roof_tile(p0, p1, p2, p3, 3*min_dist, opp=-1)
        #initialization
        if p0[1]*opp < p1[1]*opp:
            p1, p2 = co.cen( p0, p1 ), co.cen( p2, p3 )
        else:
            p0, p3 = co.cen( p0, p1 ), co.cen( p2, p3 )

        tile_dist = min_dist
        tile_dist_max = co.dis_between_two_points( p0, p3 )
        while 1:
            if tile_dist >= tile_dist_max: break
            point1 = ( tile_dist*(p3[0]-p0[0])/tile_dist_max+p0[0], tile_dist*(p3[1]-p0[1])/tile_dist_max+p0[1] )
            point2 = ( tile_dist*(p2[0]-p1[0])/tile_dist_max+p1[0], tile_dist*(p2[1]-p1[1])/tile_dist_max+p1[1] )
            drawing.append( sdxf.Line(points=[point1, point2], layer='roof_tile') )
            tile_dist = tile_dist + min_dist
コード例 #9
0
def roof_cut( four_points, bound_A=100, bound_B=230, gap=25, corner=38 ):
    '''智能分割布局'''
    global img_black_paper
    
    rect_width = co.dis_between_two_points( four_points[0], four_points[1] ) #width
    rect_height = co.dis_between_two_points( four_points[1], four_points[2] ) #height
    rect_max_side = max( rect_width, rect_height )

    # Kind1:One building
    if rect_max_side < bound_A:
        if min( rect_width, rect_height ) <10: return set()
        return set([four_points])
    
    result_set = set()
    
    # Kind2:One side to be a yard or block
    # Kind3:A yard or a street block
    if rect_max_side < bound_B:
        if rect_width < bound_A:
            # Kind2
            c_right, c_left, c_up, c_down = co.sidecenter( four_points )
            center_rect = co.cen(c_up,c_down)
            tmp_point = co.cen( co.cen(c_down, center_rect), c_up )
            result_set = result_set.union( roof_cut( co.line_to_rect(c_up, tmp_point, rect_width*0.5*0.8, 0.2*0.5*rect_width ) ) )
            result_set = result_set.union( roof_cut( co.line_to_rect(tmp_point, c_down, rect_width*0.5 ) ) )
            return result_set
            
        elif rect_height < bound_A:
            # Kind2
            c_right, c_left, c_up, c_down = co.sidecenter( four_points )
            center_rect = co.cen(c_up,c_down)
            tmp_point = co.cen( co.cen(c_right, center_rect), c_left )
            result_set = result_set.union( roof_cut( co.line_to_rect(c_left, tmp_point, rect_height*0.5*0.8, 0.2*0.5*rect_height ) ) )
            result_set = result_set.union( roof_cut( co.line_to_rect(tmp_point, c_right, rect_height*0.5 ) ) )
            return result_set
            
        else:
            # Kind3
            if rect_width>2*bound_A or rect_height>2*bound_A:
                width_cut, height_cut = int(rect_width / bound_A), int(rect_height / bound_A)
                if width_cut == 0: width_cut = 1
                if height_cut == 0: height_cut = 1
                width_side, height_side = rect_width / width_cut, rect_height / height_cut
                print width_side, height_side,width_cut,height_cut, '&&&&'
                for i in xrange(width_cut):
                    for j in xrange(height_cut):
                        #wrong
                        p0 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*width_side, j*height_side )
                                   
                        p1 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               (i+1)*width_side, j*height_side )
                                               
                        p2 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               (i+1)*width_side, (j+1)*height_side )
                        
                        p3 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               i*width_side, (j+1)*height_side )
                        
                        result_set = result_set.union( roof_cut( (p0,p1,p2,p3) ) )
            
            else:
                #先加入四个角,再把四边剩下来的递归处理(目前再处理角的问题上不引入折角,未来可以在此处引入)
                rect_tmp1 = co.rect_scale( four_points[0], four_points[1], four_points[2], four_points[3], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp1 )
                rect_tmp2 = co.rect_scale( four_points[1], four_points[2], four_points[3], four_points[0], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp2 )
                rect_tmp3 = co.rect_scale( four_points[2], four_points[3], four_points[0], four_points[1], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp3 )
                rect_tmp4 = co.rect_scale( four_points[3], four_points[0], four_points[1], four_points[2], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp4 )
                
                #
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp1[1],rect_tmp2[3], co.get_l_point(rect_tmp1[1], rect_tmp1[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp2[1],rect_tmp3[3], co.get_l_point(rect_tmp2[1], rect_tmp2[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp3[1],rect_tmp4[3], co.get_l_point(rect_tmp3[1], rect_tmp3[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp4[1],rect_tmp1[3], co.get_l_point(rect_tmp4[1], rect_tmp4[2], corner*random.uniform(0.6,0.9)) ) ) )


            return result_set

    # Kind4:Too Larger
    width_cut, height_cut = int(rect_width / bound_B + 1), int(rect_height / bound_B + 1)
    width_side, height_side = (rect_width - gap*(width_cut-1))/width_cut, (rect_height - gap*(height_cut-1))/height_cut

    for i in xrange(width_cut):
        for j in xrange(height_cut):
            #wrong
            p0 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap), j*(height_side+gap) )
                                   
            p1 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap)+width_side, j*(height_side+gap) )
                                   
            p2 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap)+width_side, j*(height_side+gap)+height_side )
            
            p3 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap), j*(height_side+gap)+height_side )
            
            result_set = result_set.union( roof_cut( (p0,p1,p2,p3) ) )

    return result_set
コード例 #10
0
ファイル: archi.py プロジェクト: PharrellG/-archi
def roof_cut( four_points, bound_A=100, bound_B=230, gap=25, corner=38 ):
    '''智能分割布局'''
    global img_black_paper
    
    rect_width = co.dis_between_two_points( four_points[0], four_points[1] ) #width
    rect_height = co.dis_between_two_points( four_points[1], four_points[2] ) #height
    rect_max_side = max( rect_width, rect_height )

    # Kind1:One building
    if rect_max_side < bound_A:
        if min( rect_width, rect_height ) <10: return set()
        return set([four_points])
    
    result_set = set()
    
    # Kind2:One side to be a yard or block
    # Kind3:A yard or a street block
    if rect_max_side < bound_B:
        if rect_width < bound_A:
            # Kind2
            c_right, c_left, c_up, c_down = co.sidecenter( four_points )
            center_rect = co.cen(c_up,c_down)
            tmp_point = co.cen( co.cen(c_down, center_rect), c_up )
            result_set = result_set.union( roof_cut( co.line_to_rect(c_up, tmp_point, rect_width*0.5*0.8, 0.2*0.5*rect_width ) ) )
            result_set = result_set.union( roof_cut( co.line_to_rect(tmp_point, c_down, rect_width*0.5 ) ) )
            return result_set
            
        elif rect_height < bound_A:
            # Kind2
            c_right, c_left, c_up, c_down = co.sidecenter( four_points )
            center_rect = co.cen(c_up,c_down)
            tmp_point = co.cen( co.cen(c_right, center_rect), c_left )
            result_set = result_set.union( roof_cut( co.line_to_rect(c_left, tmp_point, rect_height*0.5*0.8, 0.2*0.5*rect_height ) ) )
            result_set = result_set.union( roof_cut( co.line_to_rect(tmp_point, c_right, rect_height*0.5 ) ) )
            return result_set
            
        else:
            # Kind3
            if rect_width>2*bound_A or rect_height>2*bound_A:
                width_cut, height_cut = int(rect_width / bound_A), int(rect_height / bound_A)
                if width_cut == 0: width_cut = 1
                if height_cut == 0: height_cut = 1
                width_side, height_side = rect_width / width_cut, rect_height / height_cut
                print width_side, height_side,width_cut,height_cut, '&&&&'
                for i in xrange(width_cut):
                    for j in xrange(height_cut):
                        #wrong
                        p0 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*width_side, j*height_side )
                                   
                        p1 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               (i+1)*width_side, j*height_side )
                                               
                        p2 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               (i+1)*width_side, (j+1)*height_side )
                        
                        p3 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                               i*width_side, (j+1)*height_side )
                        
                        result_set = result_set.union( roof_cut( (p0,p1,p2,p3) ) )
            
            else:
                #先加入四个角,再把四边剩下来的递归处理(目前再处理角的问题上不引入折角,未来可以在此处引入)
                rect_tmp1 = co.rect_scale( four_points[0], four_points[1], four_points[2], four_points[3], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp1 )
                rect_tmp2 = co.rect_scale( four_points[1], four_points[2], four_points[3], four_points[0], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp2 )
                rect_tmp3 = co.rect_scale( four_points[2], four_points[3], four_points[0], four_points[1], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp3 )
                rect_tmp4 = co.rect_scale( four_points[3], four_points[0], four_points[1], four_points[2], corner*random.uniform(1.3,1.8), corner )
                result_set.add(  rect_tmp4 )
                
                #
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp1[1],rect_tmp2[3], co.get_l_point(rect_tmp1[1], rect_tmp1[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp2[1],rect_tmp3[3], co.get_l_point(rect_tmp2[1], rect_tmp2[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp3[1],rect_tmp4[3], co.get_l_point(rect_tmp3[1], rect_tmp3[2], corner*random.uniform(0.6,0.9)) ) ) )
                result_set = result_set.union( roof_cut( co.rect_progress(rect_tmp4[1],rect_tmp1[3], co.get_l_point(rect_tmp4[1], rect_tmp4[2], corner*random.uniform(0.6,0.9)) ) ) )


            return result_set

    # Kind4:Too Larger
    width_cut, height_cut = int(rect_width / bound_B + 1), int(rect_height / bound_B + 1)
    width_side, height_side = (rect_width - gap*(width_cut-1))/width_cut, (rect_height - gap*(height_cut-1))/height_cut

    for i in xrange(width_cut):
        for j in xrange(height_cut):
            #wrong
            p0 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap), j*(height_side+gap) )
                                   
            p1 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap)+width_side, j*(height_side+gap) )
                                   
            p2 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap)+width_side, j*(height_side+gap)+height_side )
            
            p3 = co.get_rect_point( four_points[0], four_points[1], four_points[2], four_points[3], \
                                   i*(width_side+gap), j*(height_side+gap)+height_side )
            
            result_set = result_set.union( roof_cut( (p0,p1,p2,p3) ) )

    return result_set