feat: 推进一级关系参数化编辑与参数导出
This commit is contained in:
+27
-1
@@ -69,6 +69,32 @@ def _polydata_id_key(values: Iterable[int] | None) -> tuple[int, ...] | None:
|
||||
return tuple(sorted({int(value) for value in values}))
|
||||
|
||||
|
||||
def _display_edge_samples(edge: TopoDS_Shape, deflection: float) -> list[tuple[float, float, float]]:
|
||||
try:
|
||||
curve = BRepAdaptor_Curve(edge)
|
||||
curve_type = curve.GetType()
|
||||
first = float(curve.FirstParameter())
|
||||
last = float(curve.LastParameter())
|
||||
except Exception:
|
||||
return list(discretize_edge(edge, deflection))
|
||||
|
||||
if curve_type in {GeomAbs_Circle, GeomAbs_Ellipse} and math.isfinite(first) and math.isfinite(last):
|
||||
span = abs(last - first)
|
||||
if span > 1e-9:
|
||||
min_segments = 24 if span >= math.tau * 0.75 else 8
|
||||
segments = max(min_segments, int(math.ceil(span / math.radians(7.5))))
|
||||
segments = min(max(segments, 2), 128)
|
||||
samples: list[tuple[float, float, float]] = []
|
||||
for index in range(segments + 1):
|
||||
parameter = first + (last - first) * (index / segments)
|
||||
point = curve.Value(parameter)
|
||||
samples.append((float(point.X()), float(point.Y()), float(point.Z())))
|
||||
if len(samples) >= 2:
|
||||
return samples
|
||||
|
||||
return list(discretize_edge(edge, deflection))
|
||||
|
||||
|
||||
class PolydataMixin:
|
||||
def build_face_polydata(
|
||||
self,
|
||||
@@ -272,7 +298,7 @@ class PolydataMixin:
|
||||
continue
|
||||
if edge_id in hidden_edge_ids:
|
||||
continue
|
||||
samples = discretize_edge(edge, deflection)
|
||||
samples = _display_edge_samples(edge, deflection)
|
||||
if len(samples) < 2:
|
||||
continue
|
||||
polyline = vtk.vtkPolyLine()
|
||||
|
||||
Reference in New Issue
Block a user