Esempio n. 1
0
    def splitr(self, sup, line, connect=True):
        sv = self.vs[sup]
        bd = sv[2]['bound']
        bprjx = vec3(1, 0, 0).prjps(bd)
        bprjy = vec3(0, 1, 0).prjps(bd)
        bprjz = vec3(0, 0, 1).prjps(bd)
        lp = vec3(bprjx[0] + line[0].x * (bprjx[1] - bprjx[0]),
                  bprjy[0] + line[0].y * (bprjy[1] - bprjy[0]),
                  bprjz[0] + line[0].z * (bprjz[1] - bprjz[0]))
        sp1 = lp.cp().trn(line[1].cp().uscl(1000))
        sp2 = lp.cp().trn(line[1].cp().uscl(-1000))

        l, r = pym.bsegsxy(bd, sp1, sp2)
        sv[2]['bound'] = tuple(l if pym.bccw(l) else l[::-1])
        newes = sv[1][:] + ([sup] if connect else [])
        new = self.defroom(r,
                           newes,
                           exits=sv[2]['exits'][:],
                           level=sv[2]['level'],
                           skirt=sv[2]['skirt'],
                           crown=sv[2]['crown'])
        # add edge for existing room
        for vx in sv[1]:
            self.vs[vx][1].append(new)
        if connect: sv[1].append(new)
        return new
Esempio n. 2
0
 def atest_split(self):
     fp = dbl.block('H',10,25,25)
     rg = ptg.partitiongraph()
     bs = pym.bsegsxy(fp[0],vec3(0,-100,0),vec3(0,100,0))
     b = fp[0]
     i1 = rg.av(b = [b,[]],p = vec3(0,0,0).com(b),l = 0)
     i2 = rg.sv(0,bs[0],bs[1])
     rg.plotxy()
     plt.show()
Esempio n. 3
0
 def atest_split(self):
     fp = dbl.block('H', 10, 25, 25)
     rg = ptg.partitiongraph()
     bs = pym.bsegsxy(fp[0], vec3(0, -100, 0), vec3(0, 100, 0))
     b = fp[0]
     i1 = rg.av(b=[b, []], p=vec3(0, 0, 0).com(b), l=0)
     i2 = rg.sv(0, bs[0], bs[1])
     rg.plotxy()
     plt.show()
Esempio n. 4
0
 def bv(self,vx,p,d,**kws):
     b = self.vs[vx][1]['b']
     p = pym.ptob(b[0],p)
     sp1 = p.cp().trn(d.cp().uscl( 10000))
     sp2 = p.cp().trn(d.cp().uscl(-10000))
     nfps = pym.bsegsxy(b[0],sp1,sp2)
     new = []
     l = nfps.pop(0)
     for r in nfps:new.append(self.sv(vx,l,r,**kws))
     return new
Esempio n. 5
0
    def atest_bsegsxy(self):
        def pl(bs):
            ax = dtl.plot_axes_xy(10)
            ax = dtl.plot_polygon_xy(b,ax,col = 'g',lw = 2)
            ax = dtl.plot_edges_xy((s1,s2),ax,col = 'r',lw = 1)
            for bpy in bs:
                bpy = pym.contract(bpy,0.1)
                ax = dtl.plot_polygon_xy(bpy,ax,col = 'b',lw = 4)
            plt.show()

        b = vec3(0,0,0).pring(7,4)
        s1,s2 = vec3(0,-10,0),vec3(0,10,0)
        bs = pym.bsegsxy(b,s1,s2)
        #pl(bs)
        b = dbl.block('C',1,3,3)[0]
        s1,s2 = vec3(0,-10,0),vec3(0,10,0)
        bs = pym.bsegsxy(b,s1,s2)
        #pl(bs)

        print('H problem!!!')
Esempio n. 6
0
    def atest_bsegsxy(self):
        def pl(bs):
            ax = dtl.plot_axes_xy(10)
            ax = dtl.plot_polygon_xy(b, ax, col='g', lw=2)
            ax = dtl.plot_edges_xy((s1, s2), ax, col='r', lw=1)
            for bpy in bs:
                bpy = pym.contract(bpy, 0.1)
                ax = dtl.plot_polygon_xy(bpy, ax, col='b', lw=4)
            plt.show()

        b = vec3(0, 0, 0).pring(7, 4)
        s1, s2 = vec3(0, -10, 0), vec3(0, 10, 0)
        bs = pym.bsegsxy(b, s1, s2)
        #pl(bs)
        b = dbl.block('C', 1, 3, 3)[0]
        s1, s2 = vec3(0, -10, 0), vec3(0, 10, 0)
        bs = pym.bsegsxy(b, s1, s2)
        #pl(bs)

        print('H problem!!!')
Esempio n. 7
0
def split(g,subseq):
    srx,spx,spy,sdx,sdy,sframe = [v for v in subseq.split(',')]
    spz,sdz = g.vs[int(srx)][1]['fp'][0].z,0
    lp,ld = vec3(float(spx),float(spy),spz),vec3(float(sdx),float(sdy),sdz)
    fp = g.vs[int(srx)][1]['fp']
    if   sframe == 'root':  lp = g.tfp(lp,g.footprint)
    elif sframe == 'vertex':lp = g.tfp(lp,fp)
    sp1 = lp.cp().trn(ld.cp().uscl( 10000))
    sp2 = lp.cp().trn(ld.cp().uscl(-10000))
    nfps = pym.bsegsxy(fp,sp1,sp2)
    l = nfps.pop(0)
    #for r in nfps:new = g.sv(int(srx),l,r,False,False)
    for r in nfps:new = g.sv(int(srx),l,r,True,True)
    return g
Esempio n. 8
0
def split(g, subseq):
    srx, spx, spy, sdx, sdy, sframe = [v for v in subseq.split(',')]
    spz, sdz = g.vs[int(srx)][1]['fp'][0].z, 0
    lp, ld = vec3(float(spx), float(spy), spz), vec3(float(sdx), float(sdy),
                                                     sdz)
    fp = g.vs[int(srx)][1]['fp']
    if sframe == 'root': lp = g.tfp(lp, g.footprint)
    elif sframe == 'vertex': lp = g.tfp(lp, fp)
    sp1 = lp.cp().trn(ld.cp().uscl(10000))
    sp2 = lp.cp().trn(ld.cp().uscl(-10000))
    nfps = pym.bsegsxy(fp, sp1, sp2)
    l = nfps.pop(0)
    #for r in nfps:new = g.sv(int(srx),l,r,False,False)
    for r in nfps:
        new = g.sv(int(srx), l, r, True, True)
    return g
Esempio n. 9
0
    def test_av(self):
        fp = dbl.block('H',10,25,25)
        rg = ptg.partitiongraph()
        bs = pym.bsegsxy(fp[0],vec3(0,-100,0),vec3(0,100,0))
        for b in bs:
            i = rg.av(b = [b,[]],p = vec3(0,0,0).com(b),l = 0)

        rg.plotxy()
        plt.show()

        pg = rg.bgraph()
        pgpy = pg.polygon(1,'ccw')
        ax = pg.plotxy()
        #ax = dtl.plot_axes_xy(20)
        #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2)
        ax = dtl.plot_polygon_xy(pgpy[0],ax,lw = 2)
        for pgp in pgpy[1]:
            ax = dtl.plot_polygon_xy(pgp,ax,lw = 2)
        plt.show()
Esempio n. 10
0
    def test_av(self):
        fp = dbl.block('H', 10, 25, 25)
        rg = ptg.partitiongraph()
        bs = pym.bsegsxy(fp[0], vec3(0, -100, 0), vec3(0, 100, 0))
        for b in bs:
            i = rg.av(b=[b, []], p=vec3(0, 0, 0).com(b), l=0)

        rg.plotxy()
        plt.show()

        pg = rg.bgraph()
        pgpy = pg.polygon(1, 'ccw')
        ax = pg.plotxy()
        #ax = dtl.plot_axes_xy(20)
        #ax = dtl.plot_polygon_full_xy(pgpy,ax,lw = 2)
        ax = dtl.plot_polygon_xy(pgpy[0], ax, lw=2)
        for pgp in pgpy[1]:
            ax = dtl.plot_polygon_xy(pgp, ax, lw=2)
        plt.show()
Esempio n. 11
0
    def split(self,v,s,z,rad,epsilon):
        sp = vec3(0,0,0).com(v.loop)
        sd = vec3(0,1,0) if random.random() > 0.5 else vec3(1,0,0)
        s1 = sp.cp().trn(sd.cp().uscl( 10000))
        s2 = sp.cp().trn(sd.cp().uscl(-10000))
        loops = pym.bsegsxy(v.loop,s1,s2,0.1)

        lvs = []
        for el in loops:
            if not pym.bccw(el):el.reverse()
            el = pym.blimithmin(el,2,50)
            el = pym.aggregate(el,2)
            #el = pym.smoothxy(el,0.5,epsilon)
            nv = self.grow(v,z,rad,epsilon,el)
            lvs.append(nv)

        ax = self.plot()
        for el in loops:
            ax = dtl.plot_polygon(el,ax,lw = 2,col = 'r')
        plt.show()

        return lvs
Esempio n. 12
0
    def splitr(self,sup,line,connect = True):
        sv = self.vs[sup]
        bd = sv[2]['bound']
        bprjx = vec3(1,0,0).prjps(bd)
        bprjy = vec3(0,1,0).prjps(bd)
        bprjz = vec3(0,0,1).prjps(bd)
        lp = vec3(
            bprjx[0]+line[0].x*(bprjx[1]-bprjx[0]),
            bprjy[0]+line[0].y*(bprjy[1]-bprjy[0]),
            bprjz[0]+line[0].z*(bprjz[1]-bprjz[0]))
        sp1 = lp.cp().trn(line[1].cp().uscl( 1000))
        sp2 = lp.cp().trn(line[1].cp().uscl(-1000))

        l,r = pym.bsegsxy(bd,sp1,sp2)
        sv[2]['bound'] = tuple(l if pym.bccw(l) else l[::-1])
        newes = sv[1][:]+([sup] if connect else [])
        new = self.defroom(r,newes,
            exits = sv[2]['exits'][:],level = sv[2]['level'],
            skirt = sv[2]['skirt'],crown = sv[2]['crown'])
        # add edge for existing room
        for vx in sv[1]:self.vs[vx][1].append(new)
        if connect:sv[1].append(new)
        return new