feat: 完善 Face 一级关系编辑和稳定性

This commit is contained in:
2026-08-04 09:35:39 +08:00
parent bb44e3920d
commit 5799d5d813
29 changed files with 6295 additions and 189 deletions
+53 -14
View File
@@ -462,7 +462,7 @@ INFO_LABELS = {
"ellipse_edge_major_radius": "椭圆Edge主半径",
"ellipse_edge_minor_radius": "椭圆Edge小半径",
"reference_radius": "参考半径",
"semi_angle": "半角",
"semi_angle": "圆锥半角",
"angular_span": "角度跨度",
"height_estimate": "估算高度",
"hole_depth_estimate": "孔/槽深度估算",
@@ -606,6 +606,12 @@ INFO_LABELS = {
"existing_fillet_radius_estimate": "已有圆角半径估算",
"feature_reference_radius": "特征参考半径",
"feature_reference_diameter": "特征参考直径",
"feature_cone_small_radius": "锥孔小端半径",
"feature_cone_small_diameter": "锥孔小端直径",
"feature_cone_large_radius": "锥孔大端半径",
"feature_cone_large_diameter": "锥孔大端直径",
"feature_cone_height": "锥孔高度",
"feature_cone_boundary_half_angle_degrees": "锥孔半角",
"feature_sphere_radius": "球面半径",
"feature_sphere_diameter": "球面直径",
"feature_torus_major_radius": "环面主半径",
@@ -768,6 +774,32 @@ SELECTION_MODE_LABELS = {
SELECTION_MODE_VALUES = {label: mode for mode, label in SELECTION_MODE_LABELS.items()}
SURFACE_VALUE_LABELS = {
"plane": "平面",
"cylinder": "圆柱面",
"cone": "圆锥面 / 拔模面",
"sphere": "球面",
"torus": "环面",
"bezier surface": "Bezier 曲面",
"b-spline surface": "B-spline 曲面",
"surface of revolution": "旋转曲面",
"surface of extrusion": "拉伸曲面",
"offset surface": "偏移曲面",
"other surface": "其它曲面",
}
CURVE_VALUE_LABELS = {
"line": "直线",
"circle": "圆 / 圆弧",
"ellipse": "椭圆 / 椭圆弧",
"hyperbola": "双曲线",
"parabola": "抛物线",
"bezier curve": "Bezier 曲线",
"b-spline curve": "B-spline 曲线",
"other curve": "其它曲线",
}
def _selection_mode_label(mode: object) -> str:
mode_text = str(mode or "")
return SELECTION_MODE_LABELS.get(mode_text, mode_text or "Face")
@@ -783,7 +815,7 @@ def _format_float(value: float) -> str:
def _info_to_text(info: dict[str, object]) -> str:
return "\n".join(f"{INFO_LABELS.get(key, key)}: {_format_value(value)}" for key, value in info.items())
return "\n".join(f"{INFO_LABELS.get(key, key)}: {_format_info_value(key, value)}" for key, value in info.items())
def _part_tree_kind_label(kind: str) -> str:
@@ -807,25 +839,21 @@ def _enable_overlay_depth_offset(mapper) -> None:
def _smooth_surface_polydata(polydata):
clean = vtk.vtkCleanPolyData()
clean.SetInputData(polydata)
clean.PointMergingOn()
clean.SetTolerance(1e-7)
clean.Update()
normals = vtk.vtkPolyDataNormals()
normals.SetInputConnection(clean.GetOutputPort())
# build_face_polydata owns a separate point set for each B-Rep Face.
# Keep those boundary points separate: averaging a side-wall normal into a
# planar cap creates the dark triangular gradients seen in the UI.
normals.SetInputData(polydata)
normals.ComputePointNormalsOn()
normals.ComputeCellNormalsOff()
normals.ConsistencyOn()
normals.SplittingOn()
normals.SetFeatureAngle(35.0)
if hasattr(normals, "AutoOrientNormalsOn"):
normals.AutoOrientNormalsOn()
normals.SplittingOff()
if hasattr(normals, "NonManifoldTraversalOff"):
normals.NonManifoldTraversalOff()
normals.Update()
smoothed = vtk.vtkPolyData()
smoothed.DeepCopy(normals.GetOutput())
smoothed.ShallowCopy(normals.GetOutput())
return smoothed
@@ -882,6 +910,17 @@ def _format_value(value: object) -> str:
return str(value)
def _format_info_value(key: object, value: object) -> str:
key_text = str(key or "")
if key_text == "surface":
value_text = str(value or "")
return SURFACE_VALUE_LABELS.get(value_text, value_text)
if key_text == "curve":
value_text = str(value or "")
return CURVE_VALUE_LABELS.get(value_text, value_text)
return _format_value(value)
def _int_values(value: object) -> list[int]:
if value is None or value == "":
return []