feat(engine): 鏀寔 annulus/circles profile 鐩存帴閲嶅缓涓?schema 鍚屾

This commit is contained in:
2026-08-28 16:20:49 +08:00
parent 7e199d785d
commit 9d849df618
737 changed files with 216949 additions and 6 deletions
+50 -4
View File
@@ -1,9 +1,9 @@
"""Core CDSL sketch resolver.
The runtime accepts only direct geometric descriptions: circles, straight-edge
polygons, and closed analytic line/arc/circle contours. Semantic shapes and
historical profile macros belong to the importer compatibility layer and must
be lowered before this module is invoked.
polygons, closed analytic line/arc/circle contours, concentric annuli, and
multi-circle sets. Semantic shapes and historical profile macros belong to the
importer compatibility layer and must be lowered before this module is invoked.
"""
from __future__ import annotations
@@ -276,12 +276,58 @@ def _gen_analytic_contours(profile: _Ctx, meta: _Ctx) -> tuple[list[_Ctx], list[
return entities, []
CORE_SHAPE_GENERATORS: dict[str, Any] = {"circle": _gen_circle, "polygon": _gen_polygon, "analytic_contours": _gen_analytic_contours}
def _gen_annulus(profile: _Ctx, meta: _Ctx) -> tuple[list[_Ctx], list[_Ctx]]:
"""annulus: 同心圆环,由内外两个实体圆组成。
与 legacy 链路(legacy_profiles._gen_annulus)同构:只产出圆实体、
不产轮廓边,建面交给 adapter 的 _faces_from_circles(内圆被外圆包含
→ 作为孔洞打掉,得到环面)。
"""
center = profile.get("center") or [0.0, 0.0]
inner_radius = float(profile.get("inner_radius_mm") or 0.0)
outer_radius = float(profile.get("outer_radius_mm") or 0.0)
if inner_radius <= 0 or outer_radius <= 0:
raise ValueError("annulus: radii must be > 0")
if inner_radius >= outer_radius:
raise ValueError("annulus: inner_radius must be < outer_radius")
cx, cy = float(center[0]), float(center[1])
return [_circle([cx, cy], inner_radius), _circle([cx, cy], outer_radius)], []
def _gen_circles(profile: _Ctx, meta: _Ctx) -> tuple[list[_Ctx], list[_Ctx]]:
"""circles: 多圆轮廓,每个圆一个实体圆(互不相交时为独立面)。
与 legacy 链路(legacy_profiles._gen_circles)同构:只产出圆实体、
不产轮廓边,建面交给 adapter 的 _faces_from_circles(按圆间包含关系
识别孔洞,被包含的圆跳过、直接包含的圆作为孔洞)。
"""
items = profile.get("items") or []
if not items:
raise ValueError("circles: items must be non-empty")
entities: list[_Ctx] = []
for item in items:
center = item.get("center") or [0.0, 0.0]
radius = float(item.get("radius_mm") or 0.0)
if radius <= 0:
raise ValueError("circles: radius_mm must be > 0")
entities.append(_circle([float(center[0]), float(center[1])], radius))
return entities, []
CORE_SHAPE_GENERATORS: dict[str, Any] = {
"circle": _gen_circle,
"polygon": _gen_polygon,
"analytic_contours": _gen_analytic_contours,
"annulus": _gen_annulus,
"circles": _gen_circles,
}
SHAPE_GENERATORS = CORE_SHAPE_GENERATORS
SHAPE_CAPABILITIES: dict[str, _Ctx] = {
"circle": {"detectable": True, "arity": "circle", "description": "single circular contour"},
"polygon": {"detectable": True, "arity": "polygon", "description": "closed straight-edge contour"},
"analytic_contours": {"detectable": True, "arity": "analytic", "description": "closed line, arc, and circle contours"},
"annulus": {"detectable": True, "arity": "annulus", "description": "concentric inner and outer circular contours"},
"circles": {"detectable": True, "arity": "circles", "description": "multiple circular contours with hole nesting"},
}