Browse Source

added inner-face edges and all new faces

master
Stephen M. McQuay 10 years ago
parent
commit
889cdf201c
  1. 26
      surf/subd/butterfly.py

26
surf/subd/butterfly.py

@ -43,11 +43,8 @@ def _make_edge_point(mesh, eid):
def refine(mesh):
new_verts = list(mesh.vertices)
nv_offset = len(new_verts)
# TODO:
new_faces = []
# TODO:
new_edges = []
new_faces = []
for eid, verts_for_edge in enumerate(mesh.edges):
new_vert = _make_edge_point(mesh, eid)
@ -61,8 +58,23 @@ def refine(mesh):
for fid in range(len(mesh.faces)):
# join all new edge points on a face:
new_edges.extend(
[[i[0] + nv_offset, i[1] + nv_offset]
for i in combinations(mesh.edges_for_face[fid], 2)])
new_center_face = [i + nv_offset for i in mesh.edges_for_face[fid]]
inner_edges = list(combinations(new_center_face, 2))
new_edges.extend(inner_edges)
# make new faces: center face
new_faces.append(new_center_face)
# three new faces, one per old vertex:
for fvid in mesh.faces[fid]:
possible_edges = mesh.edges_for_vert[fvid]
face_edges = mesh.edges_for_face[fid]
edges_for_fvid = list(set(possible_edges) & set(face_edges))
assert len(edges_for_fvid) == 2
new_faces.append([
edges_for_fvid[0] + nv_offset,
fvid,
edges_for_fvid[1] + nv_offset
])
return PolygonMesh(new_verts, new_faces, new_edges)

Loading…
Cancel
Save