示例#1
0
 def breadth_first_layout_face_version(self, island, startMeshLoc, startIslandLoc):
     """
     traverse all faces of mesh breadth first and create an island
     (does not check if edges are cut or fold) 
     need to figure out how to setup island so ready to do this function...
     """
     layoutPair = (startMeshLoc, startIslandLoc)
     queue = collections.deque([layoutPair])
     visited = [startMeshLoc.face]
     while True:
         try:
             meshLoc, islandLoc = queue.popleft()
         except IndexError:
             break
         orientedEdges = self.myMesh.get_edges_ccw_besides_base(meshLoc.edge, meshLoc.face)
         newVerts = []
         newEdges = []
         islandFaceToBe = island.next_face_index()
         for i, orientedEdge in enumerate(orientedEdges):
             edge, alignedWithFace = orientedEdge
             face = self.myMesh.getOtherFaceIdx(edge, meshLoc.face)
             if orientedEdge != orientedEdges[-1]:  # the last edge's head has already been layed out
                 tailPoint, headPoint = self.myMesh.get_aligned_points(orientedEdge)
                 mapped_point = self.get_mapped_point(headPoint, meshLoc, islandLoc)
                 island.layout_add_vert_point(mapped_point)
             newEdge = island.layout_add_edge(i + 1)
             if face and face not in visited:
                 visited.append(face)
                 island.update_edge_to_face(edge=newEdge, toFace=islandFaceToBe + (i + 1))
                 newMeshLoc = MeshLoc(face, edge)
                 newIslandLoc = IslandLoc(islandFaceToBe, newEdge)
                 queue.append((newMeshLoc, newIslandLoc))
         island.layout_add_face(baseEdge=islandLoc.edge)
示例#2
0
 def breadth_first_layout(self, island, startMeshLoc, startIslandLoc):
     ''' for layout to not accidently infinite loop the startMeshLoc must be on cut or naked edge
     '''
     assert (self.myMesh.is_cut_edge(startMeshLoc.edge)
             or self.myMesh.is_naked_edge(startMeshLoc.edge)
             ), "meshloc is not on a cut edge or a naked edge!"
     layoutPair = (startMeshLoc, startIslandLoc)
     queue = collections.deque([layoutPair])
     self.visited_faces.append(startMeshLoc.face)
     while True:
         try:
             meshLoc, islandLoc = queue.popleft()
         except IndexError:
             break
         orientedEdges = self.myMesh.get_edges_ccw_besides_base(
             meshLoc.edge, meshLoc.face)
         newVerts = []
         newEdges = []
         islandFaceToBe = island.next_face_index()
         for i, orientedEdge in enumerate(orientedEdges):
             edge, alignedWithFace = orientedEdge
             face = self.myMesh.getOtherFaceIdx(edge, meshLoc.face)
             # the last edge's head has already been layed out
             if orientedEdge != orientedEdges[-1]:
                 tailPoint, headPoint = self.myMesh.get_aligned_points(
                     orientedEdge)
                 mapped_point = self.get_mapped_point(
                     headPoint, meshLoc, islandLoc)
                 island.layout_add_vert_point(mapped_point)
             angle = self.myMesh.getEdgeAngle(edge)
             newEdge = island.layout_add_edge(i + 1, edge, angle)
             if self.myMesh.is_fold_edge(edge):
                 island.change_to_fold_edge(edge=newEdge)
                 self.visited_faces.append(face)
                 island.update_edge_to_face(edge=newEdge,
                                            toFace=islandFaceToBe + (i + 1))
                 newMeshLoc = MeshLoc(face, edge)
                 newIslandLoc = IslandLoc(islandFaceToBe, newEdge)
                 queue.append((newMeshLoc, newIslandLoc))
             elif self.myMesh.is_cut_edge(edge):
                 is_first = True
                 if edge in self.visited_edges:
                     is_first = False
                 island.change_to_cut_edge(edge=newEdge, isLeader=is_first)
             elif self.myMesh.is_naked_edge(edge):
                 island.change_to_naked_edge(edge=newEdge)
             self.visited_edges.append(edge)
         island.layout_add_face(baseEdge=islandLoc.edge)
示例#3
0
 def breadth_first_layout(self, island, startMeshLoc, startIslandLoc):
     """ for layout to not accidently infinite loop the startMeshLoc must be on cut or naked edge
     """
     assert self.myMesh.is_cut_edge(startMeshLoc.edge) or self.myMesh.is_naked_edge(
         startMeshLoc.edge
     ), "meshloc is not on a cut edge or a naked edge!"
     layoutPair = (startMeshLoc, startIslandLoc)
     queue = collections.deque([layoutPair])
     self.visited_faces.append(startMeshLoc.face)
     while True:
         try:
             meshLoc, islandLoc = queue.popleft()
         except IndexError:
             break
         orientedEdges = self.myMesh.get_edges_ccw_besides_base(meshLoc.edge, meshLoc.face)
         newVerts = []
         newEdges = []
         islandFaceToBe = island.next_face_index()
         for i, orientedEdge in enumerate(orientedEdges):
             edge, alignedWithFace = orientedEdge
             face = self.myMesh.getOtherFaceIdx(edge, meshLoc.face)
             # the last edge's head has already been layed out
             if orientedEdge != orientedEdges[-1]:
                 tailPoint, headPoint = self.myMesh.get_aligned_points(orientedEdge)
                 mapped_point = self.get_mapped_point(headPoint, meshLoc, islandLoc)
                 island.layout_add_vert_point(mapped_point)
             angle = self.myMesh.getEdgeAngle(edge)
             newEdge = island.layout_add_edge(i + 1, edge, angle)
             if self.myMesh.is_fold_edge(edge):
                 island.change_to_fold_edge(edge=newEdge)
                 self.visited_faces.append(face)
                 island.update_edge_to_face(edge=newEdge, toFace=islandFaceToBe + (i + 1))
                 newMeshLoc = MeshLoc(face, edge)
                 newIslandLoc = IslandLoc(islandFaceToBe, newEdge)
                 queue.append((newMeshLoc, newIslandLoc))
             elif self.myMesh.is_cut_edge(edge):
                 is_first = True
                 if edge in self.visited_edges:
                     is_first = False
                 island.change_to_cut_edge(edge=newEdge, isLeader=is_first)
             elif self.myMesh.is_naked_edge(edge):
                 island.change_to_naked_edge(edge=newEdge)
             self.visited_edges.append(edge)
         island.layout_add_face(baseEdge=islandLoc.edge)
示例#4
0
 def breadth_first_layout_face_version(self, island, startMeshLoc,
                                       startIslandLoc):
     '''
     traverse all faces of mesh breadth first and create an island
     (does not check if edges are cut or fold) 
     need to figure out how to setup island so ready to do this function...
     '''
     layoutPair = (startMeshLoc, startIslandLoc)
     queue = collections.deque([layoutPair])
     visited = [startMeshLoc.face]
     while True:
         try:
             meshLoc, islandLoc = queue.popleft()
         except IndexError:
             break
         orientedEdges = self.myMesh.get_edges_ccw_besides_base(
             meshLoc.edge, meshLoc.face)
         newVerts = []
         newEdges = []
         islandFaceToBe = island.next_face_index()
         for i, orientedEdge in enumerate(orientedEdges):
             edge, alignedWithFace = orientedEdge
             face = self.myMesh.getOtherFaceIdx(edge, meshLoc.face)
             if orientedEdge != orientedEdges[
                     -1]:  # the last edge's head has already been layed out
                 tailPoint, headPoint = self.myMesh.get_aligned_points(
                     orientedEdge)
                 mapped_point = self.get_mapped_point(
                     headPoint, meshLoc, islandLoc)
                 island.layout_add_vert_point(mapped_point)
             newEdge = island.layout_add_edge(i + 1)
             if face and face not in visited:
                 visited.append(face)
                 island.update_edge_to_face(edge=newEdge,
                                            toFace=islandFaceToBe + (i + 1))
                 newMeshLoc = MeshLoc(face, edge)
                 newIslandLoc = IslandLoc(islandFaceToBe, newEdge)
                 queue.append((newMeshLoc, newIslandLoc))
         island.layout_add_face(baseEdge=islandLoc.edge)