コード例 #1
0
ファイル: cycles.py プロジェクト: defg/pylayers
 def flip(self):
     """ flip the Cycle
     """
     self.cycle = self.cycle[::-1]
     self.vertices = self.vertices[::-1]
     self.edges = self.edges[::-1]
     self.p = self.p[:, ::-1]
     self.area = geu.SignedArea(self.p)
コード例 #2
0
ファイル: cycles.py プロジェクト: defg/pylayers
    def update(self):
        """ update

        """
        self.size = len(self.cycle)
        self.vertices = self.cycle[np.nonzero(np.array(self.cycle) < 0)[0]]
        self.edges = self.cycle[np.nonzero(np.array(self.cycle) > 0)[0]]
        self.Nv = len(self.vertices)
        self.Ne = len(self.edges)

        for v in self.vertices:
            try:
                pt = np.array(self.G.pos[v]).reshape(2, 1)
            except:
                pdb.set_trace()
            try:
                self.p = np.hstack((self.p, pt))
            except:
                self.p = pt

        self.area = geu.SignedArea(self.p)
        self.g = geu.Centroid(self.p)
コード例 #3
0
ファイル: cycles.py プロジェクト: mlaaraie/pylayers
    def __init__(self, G, cycle):
        # This is to obtained an ordered cycle
        self.G = G.subgraph(cycle)
        cycle = nx.algorithms.cycles.cycle_basis(self.G)[0]
        self.G = G.subgraph(cycle)
        self.G.pos = {}
        for c in cycle:
            self.G.pos[c] = G.pos[c]
        self.cycle = np.array(cycle)
        self.size = len(self.cycle)
        self.vertices = self.cycle[np.nonzero(np.array(self.cycle) < 0)[0]]
        self.edges = self.cycle[np.nonzero(np.array(self.cycle) > 0)[0]]
        self.Nv = len(self.vertices)
        self.Ne = len(self.edges)
        self.p = np.array([])
        for v in self.vertices:
            try:
                self.p = np.hstack(
                    (self.p, np.array(self.G.pos[v]).reshape(2, 1)))
            except:
                self.p = np.array(self.G.pos[v]).reshape(2, 1)

        self.area = geu.SignedArea(self.p)
        self.g = geu.Centroid(self.p)