feat: P1批次1 设计域(AI推荐/分享体系/阳光房绘图/量尺标注/逐格指定编辑)
This commit is contained in:
@@ -41,6 +41,12 @@ QUICK_SCENE = {
|
||||
"studio": "studio product shot on a seamless neutral background, softbox lighting, slight floor reflection",
|
||||
}
|
||||
|
||||
# 阳光房场景(对齐目标站 sunnyhouse 平顶/人字顶)
|
||||
SUNROOM_DESC = {
|
||||
"sunroom-flat": "a flat-roof glass sunroom attached to the house, slim {frame_word} aluminum posts and glass beams, clear tempered glass roof panels, furnished with rattan chairs and plants, garden view",
|
||||
"sunroom-gable": "a gable (A-frame pitched) glass sunroom attached to the house, ridge beam with fan-shaped front glass, {frame_word} aluminum structure, clear glass roof, garden view",
|
||||
}
|
||||
|
||||
|
||||
def _sash_kind(sub: dict) -> str | None:
|
||||
t = str(sub.get("type", ""))
|
||||
@@ -134,12 +140,25 @@ def build_prompt(drawing: str | dict, style: str = "modern", time: str = "day",
|
||||
ratio: portrait/landscape/square → 依据窗型宽高比的构图引导。
|
||||
"""
|
||||
info = describe_window(drawing)
|
||||
dd = parse_drawing(drawing)
|
||||
finish, style_word = STYLE_FINISH.get(style, STYLE_FINISH["modern"])
|
||||
light = TIME_LIGHT.get(time, TIME_LIGHT["day"])
|
||||
scene_tpl = SCENE_DESC.get(scene) or QUICK_SCENE.get(scene) or SCENE_DESC["render"]
|
||||
scene_text = scene_tpl.replace("{style_word}", style_word)
|
||||
|
||||
window_desc = info["summary"] or "a modern aluminum window"
|
||||
# 阳光房场景: 窗型描述让位于结构描述
|
||||
frame_word = "anthracite" if style == "modern" else ("bronze" if style == "chinese" else "white")
|
||||
if scene in SUNROOM_DESC:
|
||||
scene_text = SUNROOM_DESC[scene].replace("{frame_word}", frame_word)
|
||||
sr = dd.get("_sunroom") or {}
|
||||
fw = sr.get("width_mm") or info["width_mm"] or 4000
|
||||
fd = sr.get("depth_mm") or 3000
|
||||
fh = sr.get("height_mm") or 2800
|
||||
bays = max(2, round(fw / (sr.get("bay_mm") or 1000)))
|
||||
window_desc = (f"Structure: {scene_text}; footprint {fw}×{fd}mm, eave height {fh}mm, "
|
||||
f"{bays} bays with slim aluminum posts")
|
||||
else:
|
||||
scene_tpl = SCENE_DESC.get(scene) or QUICK_SCENE.get(scene) or SCENE_DESC["render"]
|
||||
scene_text = scene_tpl.replace("{style_word}", style_word)
|
||||
window_desc = info["summary"] or "a modern aluminum window"
|
||||
composition = {
|
||||
"portrait": "vertical composition, window fills most of the frame height",
|
||||
"landscape": "horizontal composition, generous wall context around the window",
|
||||
|
||||
@@ -27,6 +27,7 @@ class TakeoffResult:
|
||||
width_mm: int = 0
|
||||
height_mm: int = 0
|
||||
sash_count: int = 0
|
||||
sash_assign_count: int = 0
|
||||
meters: dict = field(default_factory=dict) # 各型材类别总米数 {frame, mullion, sash}
|
||||
|
||||
|
||||
@@ -106,6 +107,23 @@ def takeoff(dd) -> TakeoffResult:
|
||||
if cols:
|
||||
result.bars.append(BarItem("dec_bar", round(bb[3] - bb[1]), cols, "格条-竖"))
|
||||
|
||||
# 逐格指定(自研 assigns 扩展): 开扇五金+扇框料 / 副梃
|
||||
for assign in (shape.get("assigns") or []):
|
||||
if not isinstance(assign, dict):
|
||||
continue
|
||||
ri = int(assign.get("ri", -1))
|
||||
if not (0 <= ri < len(region_bbs)):
|
||||
continue
|
||||
bb = region_bbs[ri]
|
||||
w, h = round(bb[2] - bb[0]), round(bb[3] - bb[1])
|
||||
sash = assign.get("sash") or {}
|
||||
if sash.get("kind") and sash["kind"] != "fixed":
|
||||
result.bars.append(BarItem("sash", w, 2, "指定扇-宽"))
|
||||
result.bars.append(BarItem("sash", h, 2, "指定扇-高"))
|
||||
result.sash_assign_count += 1
|
||||
if assign.get("subBar"):
|
||||
result.bars.append(BarItem("subbar", w, 1, "副梃"))
|
||||
|
||||
# 扇框
|
||||
for sub in (shape.get("sm") or []):
|
||||
bd = sub.get("bd") if isinstance(sub, dict) else None
|
||||
@@ -127,7 +145,7 @@ def takeoff(dd) -> TakeoffResult:
|
||||
result.sash_count = sum(
|
||||
1 for s in dd.get("sm", []) for sub in (s.get("sm") or [])
|
||||
if isinstance(sub, dict) and sub.get("bd") and not sub.get("bd").get("hidden")
|
||||
)
|
||||
) + result.sash_assign_count
|
||||
return result
|
||||
|
||||
|
||||
@@ -167,7 +185,8 @@ def quote(drawing: str | dict, prices: dict | None = None, scripts: dict | None
|
||||
"""
|
||||
from huamenchuang.services.formula import FormulaError, eval_formula
|
||||
|
||||
p = {"frame": 45, "mullion": 40, "sash": 50, "glass": 120, "hardware": 180, "dec_bar": 12}
|
||||
p = {"frame": 45, "mullion": 40, "sash": 50, "glass": 120, "hardware": 180, "dec_bar": 12,
|
||||
"subbar": 25}
|
||||
if prices:
|
||||
p.update(prices)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user