trying to spell things more clearly in cc
This commit is contained in:
parent
d372620283
commit
e0460a0b8d
@ -7,7 +7,7 @@ def refine(mesh):
|
||||
new_vertices = list(mesh.vertices)
|
||||
f_vert_offset = len(new_vertices)
|
||||
|
||||
edge_vids_for = defaultdict(list)
|
||||
edge_vids_for_face = defaultdict(list)
|
||||
face_ids_for_v = defaultdict(list)
|
||||
|
||||
# TODO: not completely populated yet:
|
||||
@ -35,15 +35,15 @@ def refine(mesh):
|
||||
# For each edge, add an edge point.
|
||||
for old_edge_id, old_edge in enumerate(mesh.edges):
|
||||
# make mapping from edge -> new_face_vert for later
|
||||
face_ids_for_edge = mesh.faces_for_edge[old_edge_id]
|
||||
for fid in face_ids_for_edge:
|
||||
edge_vids_for[fid].append(old_edge_id)
|
||||
old_face_ids_for_old_edge = mesh.faces_for_edge[old_edge_id]
|
||||
for fid in old_face_ids_for_old_edge:
|
||||
edge_vids_for_face[fid].append(old_edge_id)
|
||||
|
||||
tmp_verts = []
|
||||
|
||||
# Set each edge point to be the average of the two neighbouring, (very
|
||||
# recently calculated) face points ...
|
||||
tmp_verts.extend([new_vertices[f + f_vert_offset] for f in face_ids_for_edge])
|
||||
tmp_verts.extend([new_vertices[f + f_vert_offset] for f in old_face_ids_for_old_edge])
|
||||
|
||||
# ... and its two original endpoints.
|
||||
tmp_verts.extend([mesh.vertices[vid] for vid in old_edge])
|
||||
@ -51,11 +51,11 @@ def refine(mesh):
|
||||
# centroid == average
|
||||
new_vertices.append(centroid(tmp_verts))
|
||||
|
||||
# For each face point, add an edge for every edge of the face, connecting
|
||||
# the face point to each edge point for the face.
|
||||
# For each face point, add an edge for every edge of the old face,
|
||||
# connecting the face point to each edge point for the face.
|
||||
for trunc_vid in xrange(len(new_vertices[f_vert_offset:e_vert_offset])):
|
||||
overall_vid = f_vert_offset + trunc_vid
|
||||
for edge_vid in edge_vids_for[trunc_vid]:
|
||||
for edge_vid in edge_vids_for_face[trunc_vid]:
|
||||
new_edges.append([edge_vid, overall_vid])
|
||||
|
||||
# v_vert_offset = len(new_vertices)
|
||||
@ -68,7 +68,6 @@ def refine(mesh):
|
||||
F_verts = []
|
||||
for fid in new_face_ids:
|
||||
F_verts.append(new_vertices[f_vert_offset + fid])
|
||||
|
||||
F = centroid(F_verts)
|
||||
|
||||
# and take the average R of all n edge midpoints for edges touching P
|
||||
@ -77,8 +76,8 @@ def refine(mesh):
|
||||
e_verts = []
|
||||
for edge in edges:
|
||||
e_verts.extend([mesh.vertices[vid] for vid in edge])
|
||||
|
||||
R = centroid(e_verts)
|
||||
|
||||
# where each edge midpoint is the average of its two endpoint vertices.
|
||||
# **Move** each original point to the point (or add it to new_verts)
|
||||
new_vertex_point = (F + 2 * R + (len(edges) - 3) * new_vertices[new_vid]) / len(edges)
|
||||
|
Loading…
Reference in New Issue
Block a user