fix cli redundant images

finger-xynova first design completed
This commit is contained in:
ykcheungab
2026-09-28 16:18:17 +08:00
parent 88922f21ef
commit 267334d543
40 changed files with 618899 additions and 263563 deletions
+16 -6
View File
@@ -85,7 +85,8 @@ def mean(*points):
return tuple(sum(values) / len(points) for values in zip(*points))
def visible_triangles(triangle, visible, nx, ny, edge_sample_grid=5, depth=0):
def visible_triangles(triangle, visible, nx, ny, edge_sample_grid=5, depth=0,
fill_unresolved=False):
a, b, c = triangle
ab, bc, ca = mean(a, b), mean(b, c), mean(c, a)
probes = (a, b, c, ab, bc, ca, mean(a, b, c))
@@ -103,13 +104,20 @@ def visible_triangles(triangle, visible, nx, ny, edge_sample_grid=5, depth=0):
if not any(states):
return
if depth >= 6 or span <= MIXED_SPAN_CELLS:
# Never accept an unresolved mixed leaf, even if its centroid is visible.
if all(states):
# Default: never accept an unresolved mixed leaf, even if its centroid is
# visible, so occluded surface is left white rather than guessed.
#
# ``fill_unresolved`` accepts the leaf instead. On this surface the only occluder
# is the surface itself, and it intrudes only near the silhouette, where an
# unpainted leaf is a hole in the printed marker while a slight stretch is not.
# The default stays conservative so the single-view artifacts do not change.
if all(states) or fill_unresolved:
yield triangle
return
children = []
for child in ((a, ab, ca), (ab, b, bc), (ca, bc, c), (ab, bc, ca)):
children.extend(visible_triangles(child, visible, nx, ny, edge_sample_grid, depth + 1))
children.extend(visible_triangles(child, visible, nx, ny, edge_sample_grid,
depth + 1, fill_unresolved))
# Coalesce only the exact parent triangle after every child was accepted.
# This is not a UV hull or a cross-triangle/island join.
if children and abs(sum(area(list(t)) for t in children) - area(list(triangle))) <= area(list(triangle)) * 1e-12:
@@ -118,7 +126,8 @@ def visible_triangles(triangle, visible, nx, ny, edge_sample_grid=5, depth=0):
yield from children
def cell_fragments(clip_vertices, nx, ny, visible, edge_sample_grid=5):
def cell_fragments(clip_vertices, nx, ny, visible, edge_sample_grid=5,
fill_unresolved=False):
"""Yield (column,row,screen polygon) fragments of ONE loop triangle."""
projected = project_triangle(clip_vertices)
if len(projected) < 3 or area(projected) < 1e-18:
@@ -135,5 +144,6 @@ def cell_fragments(clip_vertices, nx, ny, visible, edge_sample_grid=5):
for k in range(1, len(polygon) - 1):
tri = (polygon[0], polygon[k], polygon[k + 1])
if area(list(tri)) > 1e-18:
for fragment in visible_triangles(tri, visible, nx, ny, edge_sample_grid):
for fragment in visible_triangles(tri, visible, nx, ny, edge_sample_grid,
0, fill_unresolved):
yield i, j, fragment