Example #1
0
 def sortEdges(self):
     """ Sort the edges by their connection points. Also gives if
     an edge is ill oriented (thir connection point is the end
     point, not the starting point), with True when is good oriented,
     and False otherwise.
     @return True if error happens. False otherwise
     """
     edges = self.edges
     self.edges = [edges[0]]
     self.direction = [True]
     Vertex = self.edges[0].Vertexes[1]
     for i in range(0,len(edges)-1):
         for j in range(0,len(edges)):
             if self.edges[i] == edges[j]:
                 continue
             Vertexes = edges[j].Vertexes
             if Math.isSameVertex(Vertex,Vertexes[0]):
                 Vertex = Vertexes[1]
                 self.edges.append(edges[j])
                 self.direction.append(True)
                 break
             if Math.isSameVertex(Vertex,Vertexes[1]):
                 Vertex = Vertexes[0]
                 self.edges.append(edges[j])
                 self.direction.append(False)
                 break
     return False
Example #2
0
 def isClosed(self):
     """ Returns if the edges objects are a closed curve.
     @return True if a closed curve can be built with edge objects.
     False otherwise
     """
     edges = self.edges
     for i in range(0,len(edges)):
         edge = edges[i]
         vertex1 = edge.Vertexes
         count = [0,0]
         for j in range(0,len(edges)):
             if j== i:
                 continue
             vertex2 = edges[j].Vertexes
             for k in range(0,2):
                 if Math.isSameVertex(vertex1[0],vertex2[k]):
                     count[0] = count[0]+1
                 if Math.isSameVertex(vertex1[1],vertex2[k]):
                     count[1] = count[1]+1
         if count != [1,1]:
             msg = Translator.translate("4 Edges curve must be closed")
             App.Console.PrintError(msg)
             return False
     return True