예제 #1
0
 def plot(self,ax = None):
     if ax is None:ax = dtl.plot_axes()
     plotp = self.p.copy()
     dtl.plot_point(plotp,ax)
     for d in self.ring.keys():
         f = plotp.copy().translate(self.spikes[d])
         dtl.plot_edges([plotp,f],ax)
     return ax
예제 #2
0
 def plot_rgraph(self,ax):
     for n in self.rgraph.nodes:
         if not n is None:
             n.room.plot(ax)
             dtl.plot_point(self.geom.points.ps[n.px],ax)
     for e in self.rgraph.edges:
         if not e is None:
             e1 = self.geom.points.ps[e.one.px]
             e2 = self.geom.points.ps[e.two.px]
             dtl.plot_edges([e1,e2],ax)
예제 #3
0
 def plot_rgraph(self, ax):
     for n in self.rgraph.nodes:
         if not n is None:
             n.room.plot(ax)
             dtl.plot_point(self.geom.points.ps[n.px], ax)
     for e in self.rgraph.edges:
         if not e is None:
             e1 = self.geom.points.ps[e.one.px]
             e2 = self.geom.points.ps[e.two.px]
             dtl.plot_edges([e1, e2], ax)
예제 #4
0
 def plot(self,ax = None):
     if ax is None:ax = dtl.plot_axes()
     for n in self.mesh.nodes:
         dtl.plot_point(self.geom.points.ps[n.px],ax)
     for e in self.mesh.edges:
         if e is None:continue
         eps = self.geom.points.ps[e.one.px],self.geom.points.ps[e.two.px]
         dtl.plot_edges(eps,ax)
     r = self.geom.radius()
     ax.set_xlim([-r,r])
     ax.set_ylim([-r,r])
     ax.set_zlim([-r,r])
     return ax
예제 #5
0
 def plot(self,ax = None,limit = 250):
     if ax is None:ax = dtl.plot_axes()
     for pg in self.plugs:
         edx,epos,elay = pg
         e0,e1 = edx,edx+1 if edx+1<len(self.boundary) else 0
         s,e = self.boundary[e0],self.boundary[e1]
         pgp = s.linterpolate(e,epos).translate_z(20*elay)
         ndkey = (pgp.x,pgp.y,elay)
         dtl.plot_point(pgp,ax)
     for l in self._layers():self.plot_boundary(l,ax)
     ax.set_xlim([-limit,limit])
     ax.set_ylim([-limit,limit])
     ax.set_zlim([0,40])
     for ch in self.children:ax = ch.plot(ax,limit = limit)
     return ax
예제 #6
0
 def plot(self, ax=None, limit=250):
     if ax is None: ax = dtl.plot_axes()
     for pg in self.plugs:
         edx, epos, elay = pg
         e0, e1 = edx, edx + 1 if edx + 1 < len(self.boundary) else 0
         s, e = self.boundary[e0], self.boundary[e1]
         pgp = s.linterpolate(e, epos).translate_z(20 * elay)
         ndkey = (pgp.x, pgp.y, elay)
         dtl.plot_point(pgp, ax)
     for l in self._layers():
         self.plot_boundary(l, ax)
     ax.set_xlim([-limit, limit])
     ax.set_ylim([-limit, limit])
     ax.set_zlim([0, 40])
     for ch in self.children:
         ax = ch.plot(ax, limit=limit)
     return ax
예제 #7
0
 def plot(self, ax=None):
     if ax is None: ax = dtl.plot_axes()
     plotp = self.p.copy()
     dtl.plot_point(plotp, ax)
     return ax
예제 #8
0
def break_polygon(py,p2s,subop = 'union'):
    breakers = [x for x in range(len(p2s))]
    broken = [dpr.copy_polygon(py)]
    pieces = []

    while broken:
        piece = broken.pop(0)
        eb1,ibs1 = piece
        ebn1 = dpr.polygon_normal(eb1)

        brokeone = False
        for x in breakers:
            breaker = p2s[x]
            eb2,ibs2 = breaker
            ebn2 = dpr.polygon_normal(eb2)
            pj1 = dpv.project_coords(list(eb1),ebn1)
            pj2 = dpv.project_coords(list(eb2),ebn1)

            if dpr.isnear(pj2.x,pj2.y):
                if not dpr.isnear(pj1.x,pj2.x):
                    print('disjoint polygons!')
                else:
                    if subop == 'union':
                        pu = dtl.polygon_union(piece,breaker)
                    elif subop == 'intersection':
                        pu = dtl.polygon_intersection(piece,breaker)
                    elif subop == 'difference':
                        pu = dtl.polygon_difference(piece,breaker)
                    else:print('unknown subop!',subop)
                    print('known subop!',subop)
                    print('coplanar polygons!',pu)

                    if not pu is None:

                        ax = dtl.plot_axes()
                        #dtl.plot_polygon_full(piece,ax)
                        #dtl.plot_polygon_full(breaker,ax)
                        dtl.plot_polygon(list(pu[0]),ax,lw = 5.0)
                        dtl.plot_polygon(list(pu[1][0]),ax,lw = 1.0)
                        plt.show()

                        #broken.append(pu)
                        pieces.append(pu)
                        print("breaker will continue to intersect this guy...")
                        brokeone = True
                        break
            else:
                print('skew polygons')
                plintersect = dtl.planes_intersection(ebn1,eb1[0],ebn2,eb2[0])
                if not plintersect is None:
                    pli1,pli2 = plintersect

                    intins = subop == 'difference'
                    #intins = dpr.inconcave_xy(dpv.midpoint(pli1,pli2),eb2)

                    #print('inis',subop,intins)
                    breakersect = dtl.line_intersects_polygon_at(
                                        pli1,pli2,breaker,intins)
                    if not breakersect is None:

                        if not len(breakersect) == 2:
                            print('breakersect is confusing!!')

                            ax = dtl.plot_axes()
                            dtl.plot_polygon_full(breaker,ax)
                            dtl.plot_line(pli1,pli2,25,ax,lw = 4.0)
                            for x in range(len(breakersect)):
                                dtl.plot_point(breakersect[x],ax)
                            plt.show()

                            pdb.set_trace()
                        
                        b1,b2 = breakersect
                        lsp = dtl.segment_split_polygon(b1,b2,piece)
                        if not lsp is None:
                            
                            '''#
                            print('lsssspppp',len(lsp))
                            ax = dtl.plot_axes()
                            dtl.plot_line(b1,b2,25,ax,lw = 8.0)
                            for ls in lsp:
                                ax = dtl.plot_polygon_full(ls,ax,lw = 1.0)
                            ax = dtl.plot_polygon_full(breaker,ax,lw = 3.0)
                            plt.show()
                            '''#

                            broken.extend(lsp)
                            brokeone = True
                            #pdb.set_trace()
                            break
        if not brokeone:
            pieces.append(piece)
            print('nice piece',len(pieces))
    
    '''#
    if len(pieces) > 1:
      print('broke some shit??')
      ax = dtl.plot_axes()
      for p in pieces:dtl.plot_polygon_full(p,ax)
      plt.show()
    '''#
  
    return pieces
예제 #9
0
 def plot(self,ax = None):
     if ax is None:ax = dtl.plot_axes()
     plotp = self.p.copy()
     dtl.plot_point(plotp,ax)
     return ax