Esempio n. 1
0
def sim_rule_L14(SS, PARA):
    print 'aligning posts'

    SS = ssgtools.clearTBDmarker(SS)

    for h in range(len(SS)):  # each slices
        for k in range(len(SS[h])):  # each contour
            for m in range(len(SS[h][k])):  # each node
                if not (SS[h][k][m].TBD) and not (SS[h][k][m].LPP == None):
                    LIST = []
                    pts = SS[h][k][m]
                    while (pts != None):
                        LIST.append(pts)
                        pts = pts.LPP
                        if pts != None:
                            pts.TBD = True
                    # compute AVG x,y
                    sum_x = 0.0
                    sum_y = 0.0
                    for i in LIST:
                        sum_x = sum_x + i.x
                        sum_y = sum_y + i.y
                    avg_x = sum_x / float(len(LIST))
                    avg_y = sum_y / float(len(LIST))
                    # replace x,y
                    for i in LIST:
                        i.x = avg_x
                        i.y = avg_y
    return SS
Esempio n. 2
0
def sim_rule_L33(SS, PARA):
    SS = ssgtools.clearTBDmarker(SS)

    nodelist = []

    for h in range(len(SS)):  # each slices
        for k in range(len(SS[h])):  # each contour
            for m in range(len(SS[h][k])):  # each node
                x1 = SS[h][k][m].x
                y1 = SS[h][k][m].y
                x2 = SS[h][k][m].RBP.x
                y2 = SS[h][k][m].RBP.y
                x0 = SS[h][k][m].LBP.x
                y0 = SS[h][k][m].LBP.y

                p1 = np.array([x1, y1])
                p2 = np.array([x2, y2])
                p0 = np.array([x0, y0])

                v2 = p2 - p1
                v1 = p0 - p1

                theta = ssgtools.angleoftwovectors(v1, v2)

                # store the measure
                SS[h][k][m].angle2 = theta

                if abs(theta) > (90.0 + 90.0 / 2.0 + 90.0 / 2.0 / 2.0):
                    a = p2 - p0
                    b = p1 - p0  #-v1

                    unitvec = a / np.linalg.norm(a)
                    s = np.dot(b, unitvec)
                    q = p0 + s * unitvec

                    SS[h][k][m].x = q[0]
                    SS[h][k][m].y = q[1]
                    # insert into the stack
                    nodelist.append(SS[h][k][m])
                    SS[h][k][m].TBDELETED = True
                    #SS[h][k][m].DEBUG = True

    for i in nodelist:
        if len(i.LJP) > 0 or len(i.PJP) > 0:
            i.TBDELETED = False
        else:
            if i.PPP:
                i.PPP.LPP = None
            if i.LPP:
                i.LPP.PPP = None
            i.LBP.RBP = i.RBP
            i.RBP.LBP = i.LBP

    deletenode_marked(SS)
    return SS
Esempio n. 3
0
def sim_rule_L34(SS, PARA):
    SS = ssgtools.clearTBDmarker(SS)
    SS = ssgtools.find_terminal_nodes(SS)

    # for short pillars
    if 1:
        for h in range(len(SS)):  # each slices
            for k in range(len(SS[h])):  # each contour
                for m in range(len(SS[h][k])):  # each node
                    if 0 and SS[h][k][m].LPP:
                        #SS[h][k][m].DEBUG = True
                        pass
                    if 0 and SS[h][k][m].start:
                        #SS[h][k][m].DEBUG = True
                        pass
                    if 1 and (SS[h][k][m].start and len(SS[h][k][m].LJP) == 0
                              and SS[h][k][m].LPP.end
                              and len(SS[h][k][m].LPP.PJP) == 0):
                        #SS[h][k][m].TBDELETED = True
                        #SS[h][k][m].LPP.TBDELETED = True  # DO NOT DELETE! it can be a corner

                        #SS[h][k][m].DEBUG = True
                        #SS[h][k][m].LPP.DEBUG = True

                        SS[h][k][m].start = None
                        SS[h][k][m].LPP.end = None
                        SS[h][k][m].LPP.PPP = None
                        SS[h][k][m].LPP = None
        #deletenode_marked(SS)

    # for short joists
    if 1:
        for h in range(len(SS)):  # each slices
            for k in range(len(SS[h])):  # each contour
                for m in range(len(SS[h][k])):  # each node
                    if (SS[h][k][m].start and len(SS[h][k][m].LJP) == 1
                            and SS[h][k][m].LJP[0].end
                            and len(SS[h][k][m].LJP[0].PJP) == 1):
                        #SS[h][k][m].TBDELETED = True
                        #SS[h][k][m].LPP.TBDELETED = True  # DO NOT DELETE! it can be a corner

                        #SS[h][k][m].DEBUG = True
                        #SS[h][k][m].LJP[0].DEBUG = True

                        SS[h][k][m].start = None
                        SS[h][k][m].LJP[0].end = None
                        SS[h][k][m].LJP[0].PJP = []
                        SS[h][k][m].LJP = []
    return SS
Esempio n. 4
0
def sim_rule_L35(SS, PARA):
    SS = ssgtools.clearTBDmarker(SS)

    nodelist = []

    for h in range(len(SS)):  # each slices
        for k in range(len(SS[h])):  # each contour
            for m in range(len(SS[h][k])):  # each node
                if len(SS[h][k][m].PJP) > 1:
                    nodelist.append(SS[h][k][m])

    for i in nodelist:
        # visit all leaves
        stacklist = [i]  # per node
        winnerlist = []
        looserlist = []
        history = []

        while len(stacklist) > 0:
            newstacklist = []
            for n in stacklist:
                history.append(n)
                if len(n.PJP) > 0:  # has parents
                    for j in n.PJP:
                        newstacklist.append(j)  # insert all parents
                        #j.DEBUG = True
            stacklist = newstacklist

            if len(
                    stacklist
            ) > 0:  # because the lastest stack contains the longer joists
                winnerlist = stacklist

        # find the winner
        if len(winnerlist) == 1:
            #winnerlist[0].DEBUG = True
            Bestnode = winnerlist[0]
        else:  # find the shortest one
            Bestdist = 999999
            Bestnode = None
            for candi in winnerlist:
                dist = ssgtools.L2dist(i, candi)
                if dist < Bestdist:
                    Bestdist = dist
                    Bestnode = candi
            #Bestnode.DEBUG = True
        #i.DEBUG = True

        for n in history:
            if n == i:
                #print 'a'
                pass
            elif n == Bestnode:
                #print 'b'
                pass
            else:
                #n.DEBUG = True
                if len(j.PJP) == 0 and len(j.LJP) > 0:
                    index = j.LJP[0].PJP.index(j)
                    j.LJP[0].PJP.pop(index)
                    j.LJP = []

    return SS
Esempio n. 5
0
def sim_rule_L13b(SS, PARA):
    print 'aligning multi-angle joist'

    SS = ssgtools.clearTBDmarker(SS)

    joist_set = [
    ]  # contains lists each of that contains nodes in the contiguous joists
    for h in range(len(SS)):  # each slices
        for k in range(len(SS[h])):  # each contour
            for m in range(len(SS[h][k])):  # each node
                if not (SS[h][k][m].TBD) and len(SS[h][k][m].LJP) > 0:
                    LIST = []
                    pts = SS[h][k][m]
                    while (pts != None):
                        LIST.append(pts)
                        if len(pts.LJP) > 0:
                            pts = pts.LJP[0]
                        else:
                            pts = None
                        if pts != None:
                            pts.TBD = True

                    data = []
                    for i in LIST:
                        data.append([i.x, i.y, i.z])
                    data2, margin = line3dfit.movencheck_fixedheight(
                        np.array(data))
                    #print 'max residual', margin
                    if margin < (PARA.joist_dist /
                                 3.0):  # ex: hexagonal gazebo
                        for idx in range(len(LIST)):
                            i = LIST[idx]
                            i.x = data2[idx][0]
                            i.y = data2[idx][1]
                        #LIST[0].start = True
                        #LIST[-1].end = True
                    else:  # it detects the multi-angle joist
                        joist_set.append(LIST)

    # process rejected joists
    while len(joist_set) > 0:
        joist = joist_set.pop()

        if len(joist) < 3:
            pass  # nothing.
        else:
            start_node = joist[0]
            end_node = joist[-1]
            #start_node.start = True
            #end_node.end = True

            # compute curvature
            curvature_list = []
            for n in joist[1:-1]:
                n.DEBUG = False
                curvature_list.append(
                    ssgtools.computeanglefromnodes(
                        n, start_node, end_node))  # or center, top, down

            # find 3D corner
            min_angle = min(curvature_list)
            minindex = curvature_list.index(min_angle)
            i = joist[minindex + 1]
            #i.corner = 2

            # break the joist into two edges
            listA = joist[:minindex + 1 + 1]
            listB = joist[minindex + 1:]

            # fit 3D line ---- A
            data = []
            for i in listA:
                data.append([i.x, i.y, i.z])
            #data2 = line3dfit.move(np.array(data))
            data2, margin = line3dfit.movencheck_fixedheight(np.array(data))
            if margin < 1:  # 5 is good for hexagonal gazebo
                for idx in range(len(listA)):
                    i = listA[idx]
                    i.x = data2[idx][0]
                    i.y = data2[idx][1]
            else:  # it detects the multi-angle joists
                joist_set.append(listA)

            # fit 3D line ---- B
            data = []
            for i in listB:
                data.append([i.x, i.y, i.z])
            #data2 = line3dfit.move(np.array(data))
            data2, margin = line3dfit.movencheck_fixedheight(np.array(data))
            if margin < (PARA.joist_dist /
                         3.0):  # 5 is good for hexagonal gazebo
                for idx in range(len(listB)):
                    i = listB[idx]
                    i.x = data2[idx][0]
                    i.y = data2[idx][1]
            else:  # it detects the multi-angle joists
                joist_set.append(listB)
    return SS