Esempio n. 1
0
 def pv(v,ax):
     dtl.plot_polygon(v.loop,ax,lw = 2)
     vp = v.loop[0]
     for c in self.below(v):
         cp = c.loop[0]
         dtl.plot_points((vp,cp),ax)
         dtl.plot_edges((vp,cp),ax,lw = 3,col = 'b')
         pv(c,ax)
Esempio n. 2
0
 def plot(self, ax=None):
     scale = vec3(1, 0, 0).prjps(self.footprint)
     scale = scale[1] - scale[0]
     if ax is None: ax = dtl.plot_axes(scale)
     for vx in range(self.vcnt):
         v = self.vs[vx]
         if v is None: continue
         vb = v[1]['fp']
         vrtls = '--' if 'natural' in v[1]['type'] else '-'
         ax = dtl.plot_polygon(pym.contract(vb, 0.01 * scale),
                               ax,
                               lw=2,
                               ls=vrtls,
                               col=None)
         vbc = vec3(0, 0, 0).com(vb)
         for ve in v[1]['edges']:
             if self.vs[ve] is None: continue
             ovbc = vec3(0, 0, 0).com(self.vs[ve][1]['fp'])
             ax = dtl.plot_edges((vbc, ovbc), ax, lw=3, col='c')
         for ep in v[1]['exits']:
             ax = dtl.plot_point(ep, ax, mk='s', col='r')
     top = [p.cp().ztrn(self.height) for p in self.footprint]
     ax = dtl.plot_polygon(self.footprint, ax, lw=1, col='g')
     ax = dtl.plot_polygon(top, ax, lw=1, col='b')
     return ax
Esempio n. 3
0
def realize(i, p, d, axiom, rules, **params):
    ax = dtl.plot_axes(10)
    for piece in lsy.lgen(p, d, axiom, rules, i, **params):
        if isinstance(piece, tuple):
            ax = dtl.plot_edges(piece, ax, lw=2, col='k')
        elif isinstance(piece, vec3):
            ax = dtl.plot_point(piece, ax)
    plt.show()
Esempio n. 4
0
    def test_spline(self):
        e = vec3(10,10,1)
        t1,t2 = vec3(1,0,0),vec3(0,-1,0)
        pline = self.origin.spline(e,t1,t2,5)

        ax = dtl.plot_axes(10)
        ax = dtl.plot_edges(pline,ax,lw = 3,col = 'b')
        plt.show()
Esempio n. 5
0
def realize(i,p,d,axiom,rules,**params):
    ax = dtl.plot_axes(10)
    for piece in lsy.lgen(p,d,axiom,rules,i,**params):
        if isinstance(piece,tuple):
            ax = dtl.plot_edges(piece,ax,lw = 2,col = 'k')
        elif isinstance(piece,vec3):
            ax = dtl.plot_point(piece,ax)
    plt.show()
Esempio n. 6
0
    def test_spline(self):
        e = vec3(10, 10, 1)
        t1, t2 = vec3(1, 0, 0), vec3(0, -1, 0)
        pline = self.origin.spline(e, t1, t2, 5)

        ax = dtl.plot_axes(10)
        ax = dtl.plot_edges(pline, ax, lw=3, col='b')
        plt.show()
Esempio n. 7
0
 def plot(self,ax = None,l = 10,**kws):
     if ax is None:ax = dtl.plot_axes(l)
     for j in range(self.vcnt):
         i = self.vs[j]
         if i is None:continue
         ip = i[1]['p']
         ax = dtl.plot_point(ip,ax,col = 'r')
     for k in self.rings:
         vr = self.rings[k]
         for ov in vr:
             if vr[ov] is None:continue
             re = (self.vs[k][1]['p'].cp(),self.vs[ov][1]['p'].cp())
             rn = vec3(0,0,1).crs(re[0].tov(re[1])).nrm()
             re = (re[0].trn(rn),re[1].trn(rn))
             ax = dtl.plot_edges(re,ax,lw = 2,col = 'g')
     return ax
Esempio n. 8
0
 def plot(self, ax=None, l=10, **kws):
     if ax is None: ax = dtl.plot_axes(l)
     for j in range(self.vcnt):
         i = self.vs[j]
         if i is None: continue
         ip = i[1]['p']
         ax = dtl.plot_point(ip, ax, col='r')
     for k in self.rings:
         vr = self.rings[k]
         for ov in vr:
             if vr[ov] is None: continue
             re = (self.vs[k][1]['p'].cp(), self.vs[ov][1]['p'].cp())
             rn = vec3(0, 0, 1).crs(re[0].tov(re[1])).nrm()
             re = (re[0].trn(rn), re[1].trn(rn))
             ax = dtl.plot_edges(re, ax, lw=2, col='g')
     return ax
Esempio n. 9
0
 def plotmesh(self):
     mesh = self.mesh
     ax = dtl.plot_axes()
     for f in mesh.faces:                    
         for l in mesh.mask(2,None,None,None,f):
             hes = mesh.mask(6,None,None,l,None)
             p1 = self.pset.ps[hes[0].one[1]]
             p2 = self.pset.ps[hes[0].two[1]]
             ps = [p1,p2]
             for hx in range(1,len(hes)):
                 onep = self.pset.ps[hes[hx].one[1]]
                 twop = self.pset.ps[hes[hx].two[1]]
                 if   ps[-1].isnear(onep):ps.append(twop)
                 elif ps[-1].isnear(twop):ps.append(onep)
                 else:raise ValueError
             ax = dtl.plot_edges(ps,ax)
     plt.show()
Esempio n. 10
0
 def plotmesh(self):
     mesh = self.mesh
     ax = dtl.plot_axes()
     for f in mesh.faces:
         for l in mesh.mask(2, None, None, None, f):
             hes = mesh.mask(6, None, None, l, None)
             p1 = self.pset.ps[hes[0].one[1]]
             p2 = self.pset.ps[hes[0].two[1]]
             ps = [p1, p2]
             for hx in range(1, len(hes)):
                 onep = self.pset.ps[hes[hx].one[1]]
                 twop = self.pset.ps[hes[hx].two[1]]
                 if ps[-1].isnear(onep): ps.append(twop)
                 elif ps[-1].isnear(twop): ps.append(onep)
                 else: raise ValueError
             ax = dtl.plot_edges(ps, ax)
     plt.show()
Esempio n. 11
0
 def plot(self,ax = None):
     if ax is None:ax = dtl.plot_axes(300)
     for v,depth in self.enum(False):
         if self.below(v):col = 'g'
         else:col = 'b'
         vloop = [p.ztrn(depth*10) for p in pym.contract(v.loop,2)]
         #vloop = [p.cp().ztrn(depth*10) for p in v.loop]
         vanchor = vloop[0]
         if depth > 0:
             panchor = self.above(v).loop[0].cp().ztrn((depth-1)*10)
         else:panchor = vec3(0,0,0)
         ax = dtl.plot_polygon(vloop,ax,lw = 3,col = col)
         ax = dtl.plot_edges((vanchor,panchor),ax,col = col,lw = 5)
         for hole in v.holes:
             hole = [p.ztrn(depth*10) for p in pym.contract(hole,-2)]
             #hole = [p.cp().ztrn(depth*10) for p in hole]
             ax = dtl.plot_polygon(hole,ax,lw = 2,col = 'r')
     return ax
Esempio n. 12
0
 def plot(self, ax=None):
     if ax is None: ax = dtl.plot_axes(300)
     for v, depth in self.enum(False):
         if self.below(v): col = 'g'
         else: col = 'b'
         vloop = [p.ztrn(depth * 10) for p in pym.contract(v.loop, 2)]
         #vloop = [p.cp().ztrn(depth*10) for p in v.loop]
         vanchor = vloop[0]
         if depth > 0:
             panchor = self.above(v).loop[0].cp().ztrn((depth - 1) * 10)
         else:
             panchor = vec3(0, 0, 0)
         ax = dtl.plot_polygon(vloop, ax, lw=3, col=col)
         ax = dtl.plot_edges((vanchor, panchor), ax, col=col, lw=5)
         for hole in v.holes:
             hole = [p.ztrn(depth * 10) for p in pym.contract(hole, -2)]
             #hole = [p.cp().ztrn(depth*10) for p in hole]
             ax = dtl.plot_polygon(hole, ax, lw=2, col='r')
     return ax
Esempio n. 13
0
 def plot(self,ax = None):
     scale = vec3(1,0,0).prjps(self.footprint)
     scale = scale[1]-scale[0]
     if ax is None:ax = dtl.plot_axes(scale)
     for vx in range(self.vcnt):
         v = self.vs[vx]
         if v is None:continue
         vb = v[1]['fp']
         vrtls = '--' if 'natural' in v[1]['type'] else '-'
         ax = dtl.plot_polygon(
             pym.contract(vb,0.01*scale),ax,lw = 2,ls = vrtls,col = None)
         vbc = vec3(0,0,0).com(vb)
         for ve in v[1]['edges']:
             if self.vs[ve] is None:continue
             ovbc = vec3(0,0,0).com(self.vs[ve][1]['fp'])
             ax = dtl.plot_edges((vbc,ovbc),ax,lw = 3,col = 'c')
         for ep in v[1]['exits']:
             ax = dtl.plot_point(ep,ax,mk = 's',col = 'r')
     top = [p.cp().ztrn(self.height) for p in self.footprint]
     ax = dtl.plot_polygon(self.footprint,ax,lw = 1,col = 'g')
     ax = dtl.plot_polygon(top,ax,lw = 1,col = 'b')
     return ax
Esempio n. 14
0
 def plot(self, fp=None, ax=None):
     if ax is None: ax = dtl.plot_axes(50)
     for rmv in self.vs:
         if rmv is None: continue
         ax = dtl.plot_polygon(rmv[2]['bound'], ax, lw=4)
         rc = vec3(0, 0, 0).com(rmv[2]['bound'])
         rs = str(rmv[0]) + ',' + str(rmv[1])
         ax = dtl.plot_point(rc, dtl.plot_point_xy_annotate(rc, ax, rs))
         if rmv[1]:
             for re in rmv[1]:
                 if self.vs[re] is None: continue
                 rt = (rc, vec3(0, 0, 0).com(self.vs[re][2]['bound']))
                 ax = dtl.plot_edges(rt, ax, col='g')
         for exit in rmv[2]['exits']:
             if exit is True:
                 exitp = rc
                 ax = dtl.plot_point(
                     exitp, dtl.plot_point_xy_annotate(exitp, ax, 'exit'))
             else:
                 ax = dtl.plot_point(
                     exit, dtl.plot_point_xy_annotate(exit, ax, 'exit'))
     if not fp is None:
         ax = dtl.plot_polygon(fp, ax, lw=2, col='r')
     return ax
Esempio n. 15
0
 def plot(self,fp = None,ax = None):
     if ax is None:ax = dtl.plot_axes(50)
     for rmv in self.vs:
         if rmv is None:continue
         ax = dtl.plot_polygon(rmv[2]['bound'],ax,lw = 4)
         rc = vec3(0,0,0).com(rmv[2]['bound'])
         rs = str(rmv[0])+','+str(rmv[1])
         ax = dtl.plot_point(rc,dtl.plot_point_xy_annotate(rc,ax,rs))
         if rmv[1]:
             for re in rmv[1]:
                 if self.vs[re] is None:continue
                 rt = (rc,vec3(0,0,0).com(self.vs[re][2]['bound']))
                 ax = dtl.plot_edges(rt,ax,col = 'g')
         for exit in rmv[2]['exits']:
             if exit is True:
                 exitp = rc
                 ax = dtl.plot_point(exitp,
                     dtl.plot_point_xy_annotate(exitp,ax,'exit'))
             else:
                 ax = dtl.plot_point(exit,
                     dtl.plot_point_xy_annotate(exit,ax,'exit'))
     if not fp is None:
         ax = dtl.plot_polygon(fp,ax,lw = 2,col = 'r')
     return ax
Esempio n. 16
0
 def show(self,tris,bnds):
     ax = dtl.plot_axes()
     for t in tris:dtl.plot_polygon(t,ax,True,lw = 2,col = 'g')
     for b in bnds:dtl.plot_edges(b,ax,True,lw = 5,col = 'b')
     if self.doshow:plt.show()