added inner-face edges and all new faces
This commit is contained in:
parent
719bc94e8c
commit
889cdf201c
@ -43,11 +43,8 @@ def _make_edge_point(mesh, eid):
|
|||||||
def refine(mesh):
|
def refine(mesh):
|
||||||
new_verts = list(mesh.vertices)
|
new_verts = list(mesh.vertices)
|
||||||
nv_offset = len(new_verts)
|
nv_offset = len(new_verts)
|
||||||
|
|
||||||
# TODO:
|
|
||||||
new_faces = []
|
|
||||||
# TODO:
|
|
||||||
new_edges = []
|
new_edges = []
|
||||||
|
new_faces = []
|
||||||
|
|
||||||
for eid, verts_for_edge in enumerate(mesh.edges):
|
for eid, verts_for_edge in enumerate(mesh.edges):
|
||||||
new_vert = _make_edge_point(mesh, eid)
|
new_vert = _make_edge_point(mesh, eid)
|
||||||
@ -61,8 +58,23 @@ def refine(mesh):
|
|||||||
|
|
||||||
for fid in range(len(mesh.faces)):
|
for fid in range(len(mesh.faces)):
|
||||||
# join all new edge points on a face:
|
# join all new edge points on a face:
|
||||||
new_edges.extend(
|
new_center_face = [i + nv_offset for i in mesh.edges_for_face[fid]]
|
||||||
[[i[0] + nv_offset, i[1] + nv_offset]
|
inner_edges = list(combinations(new_center_face, 2))
|
||||||
for i in combinations(mesh.edges_for_face[fid], 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)
|
return PolygonMesh(new_verts, new_faces, new_edges)
|
||||||
|
Loading…
Reference in New Issue
Block a user