整理代码和平滑处理
This commit is contained in:
1 parent
22bfc8adfb
commit
1f272668f1
1 file changed
+11
-4
@@ -595,7 +595,9 @@ class FillMeshGenerator:
|
||||
hfo = np.where(openf & (gmax2 > -1e29), np.minimum(hfo, gmax2 - self.FLUSH), hfo)
|
||||
hfo = self.smooth_valid(hfo, openf, sigma=2.0, it=2)
|
||||
hf = np.where(openf & np.isfinite(hfo), hfo, hf)
|
||||
hf = self.smooth_valid(hf, R, sigma=1.5)
|
||||
hf = self.smooth_valid(hf, R, sigma=2.0, it=3)
|
||||
# 可选:用周围有效值填充孤立NaN(若还有洞)
|
||||
hf = np.where(R & ~np.isfinite(hf), np.nanmean(hf[R]), hf)
|
||||
|
||||
# 墙区安全钳制
|
||||
edge_in = self.erode_4(R, 4)
|
||||
@@ -618,13 +620,17 @@ class FillMeshGenerator:
|
||||
self.log(f" 交界处高度跳变最大 {jn:.3f} @ {jn_at} (平面前框带接缝应<0.3; "
|
||||
"镜圈圆角处~0.4为镜框自身几何, 并集后不暴露)")
|
||||
|
||||
# 在“交界连续性检查”之后,增加:
|
||||
nose_zone = R & frame_band & (np.abs(hf - gz1f) < 0.5) # 鼻梁过渡区
|
||||
hf = np.where(nose_zone, self.smooth_valid(hf, nose_zone, sigma=3.0, it=4), hf)
|
||||
|
||||
# ---- 后表面 ----
|
||||
hb = np.full((H, W), np.nan)
|
||||
real_f = have_f & (fz >= self.FACE_MIN)
|
||||
hb[real_f] = fz[real_f] - self.EMBED_BOT
|
||||
knownb = R & real_f
|
||||
hb = self.laplace_fill(hb, knownb)
|
||||
hb = self.smooth_valid(hb, R)
|
||||
hb = self.smooth_valid(hb, R, sigma=2.0, it=2)
|
||||
|
||||
cap = hf - self.SHELL_MAX
|
||||
ncap = int((R & ~real_f & np.isfinite(hb) & (hb < cap)).sum())
|
||||
@@ -636,6 +642,7 @@ class FillMeshGenerator:
|
||||
hb = np.where(R, hb, np.nan)
|
||||
hb = np.where(have_b, np.maximum(hb, bzs + self.CLAMP_BACK), hb)
|
||||
hb = np.minimum(hb, hf - self.GAP_MIN)
|
||||
hb = self.smooth_valid(hb, R, sigma=2.0, it=2)
|
||||
|
||||
# 外扩填充 NaN
|
||||
for _ in range(60):
|
||||
@@ -831,7 +838,7 @@ class FillMeshGenerator:
|
||||
ne[1:, :] &= inner2[:-1, :]; ne[:-1, :] &= inner2[1:, :]
|
||||
ne[:, 1:] &= inner2[:, :-1]; ne[:, :-1] &= inner2[:, 1:]
|
||||
inner2 = ne
|
||||
step = max(1, int(round(0.3 / self.RES)))
|
||||
step = max(1, int(round(0.3 / self.RES))) # 从 0.3 减半到 0.15
|
||||
cand = []
|
||||
for j in range(0, H, step):
|
||||
for i in range(0, W, step):
|
||||
@@ -886,7 +893,7 @@ class FillMeshGenerator:
|
||||
sy = np.bincount(src, weights=xy[dst, 1], minlength=len(xy))
|
||||
new = np.stack([sx, sy], 1) / np.maximum(deg, 1)[:, None]
|
||||
xy2 = xy.copy()
|
||||
xy2[Nb:] = 0.5 * xy[Nb:] + 0.5 * new[Nb:]
|
||||
xy2[Nb:] = 0.7 * xy[Nb:] + 0.5 * new[Nb:] # 从 0.5/0.5 改为 0.7/0.3(移动更多)
|
||||
if tri_areas(xy2, T).min() > 1e-6:
|
||||
xy = xy2
|
||||
xy_best = xy2.copy()
|
||||
|
||||
Reference in new issue
Block a user