def subdivide_face_split_rel_multiple(face, direction, splits): sA = [] sA.append(face.vertices[direction]) lA = face.vertices[direction + 1] sB = [] sB.append(face.vertices[direction + 3]) lB = face.vertices[(direction + 2) % len(face.vertices)] for i in range(len(splits)): sA.append(utils_vertex.vertex_between_rel(sA[0], lA,splits[i])) sB.append(utils_vertex.vertex_between_rel(sB[0], lB,splits[i])) sA.append(lA) sB.append(lB) result = [] for i in range(len(splits) + 1): if(dir == 1): f = Face([sB[i], sA[i], sA[i+1], sB[i+1]]) utils_face.face_copy_properties(face, f) result.append(f) else: f = Face([sB[i], sB[i+1], sA[i+1], sA[i]]) utils_face.face_copy_properties(face, f) result.append(f) return result
def subdivide_face_split_rel_free_quad(face, indexEdge, split1, split2): """ Splits a quad in two new quads through the points specified by relative position along the edge. Arguments: ---------- face : mola.core.Face The face to be extruded indexEdge : int direction of split, 0: 0->2, 1: 1->3 split1, split2 : float relative position of split on each edge (0..1) """ # only works with quads, therefore return original face if triangular if len(face.vertices) != 4: return face # constrain indexEdge to be either 0 or 1 indexEdge = indexEdge % 2 indexEdge1 = (indexEdge + 1) % len(face.vertices) indexEdge2 = (indexEdge + 2) % len(face.vertices) indexEdge3 = (indexEdge + 3) % len(face.vertices) p1 = utils_vertex.vertex_between_rel(face.vertices[indexEdge], face.vertices[indexEdge1], split1) p2 = utils_vertex.vertex_between_rel(face.vertices[indexEdge2], face.vertices[indexEdge3], split2) faces = [] if indexEdge == 0: f1 = Face([face.vertices[0], p1, p2, face.vertices[3]]) f2 = Face([p1, face.vertices[1], face.vertices[2], p2]) utils_face.face_copy_properties(face, f1) utils_face.face_copy_properties(face, f2) faces.extend([f1, f2]) elif indexEdge == 1: f1 = Face([face.vertices[0], face.vertices[1], p1, p2]) f2 = Face([p2, p1, face.vertices[2], face.vertices[3]]) utils_face.face_copy_properties(face, f1) utils_face.face_copy_properties(face, f2) faces.extend([f1, f2]) return faces