fix(json_to_cdsl): 多圆轮廓改为 analytic_contours 格式
This commit is contained in:
@@ -414,7 +414,16 @@ def _analytic_profile(sketch: dict[str, Any]) -> dict[str, Any]:
|
|||||||
smaller, larger = sorted(drawable, key=lambda item: item["radius_mm"])
|
smaller, larger = sorted(drawable, key=lambda item: item["radius_mm"])
|
||||||
return {"type": "annulus", "center": larger["center"], "inner_radius_mm": smaller["radius_mm"], "outer_radius_mm": larger["radius_mm"]}
|
return {"type": "annulus", "center": larger["center"], "inner_radius_mm": smaller["radius_mm"], "outer_radius_mm": larger["radius_mm"]}
|
||||||
if drawable and all(item["type"] == "circle" for item in drawable):
|
if drawable and all(item["type"] == "circle" for item in drawable):
|
||||||
return {"type": "circles", "items": [{"center": item["center"], "radius_mm": item["radius_mm"]} for item in drawable]}
|
# Multiple independent circles share the "extrude every closed loop" intent;
|
||||||
|
# emit them as analytic_contours (one outer contour per circle) so the
|
||||||
|
# generic runtime profile contract accepts the record.
|
||||||
|
return {
|
||||||
|
"type": "analytic_contours",
|
||||||
|
"contours": [
|
||||||
|
{"role": "outer", "closed": True, "segments": [item]}
|
||||||
|
for item in drawable
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
contours = _chain_segments(drawable)
|
contours = _chain_segments(drawable)
|
||||||
areas = [_contour_area(contour) for contour in contours]
|
areas = [_contour_area(contour) for contour in contours]
|
||||||
|
|||||||
Reference in New Issue
Block a user