feat: 接入 SCDM 优先编辑闭环并支持阵列局部间距
接入 SCDM probe/edit/cache/校验链路,增强孔组、阵列、关系式和参数表交互。 支持阵列相邻段间距、移动意图切换、结果回滚校验,并补充对应回归脚本。
This commit is contained in:
@@ -144,6 +144,44 @@ def evaluate_relation_formula(
|
||||
return _coerce_formula_value(value)
|
||||
|
||||
|
||||
def validate_relation_formula_graph(formulas: Iterable[RelationFormula]) -> None:
|
||||
target_to_formula: dict[str, RelationFormula] = {}
|
||||
for formula in formulas:
|
||||
target_token = formula.target.token
|
||||
if target_token in target_to_formula:
|
||||
raise RelationFormulaError(f"同一目标参数只能由一条关系式控制:{target_token}。")
|
||||
target_to_formula[target_token] = formula
|
||||
|
||||
target_tokens = set(target_to_formula)
|
||||
graph: dict[str, list[str]] = {}
|
||||
for target_token, formula in target_to_formula.items():
|
||||
reference_tokens = [ref.token for ref in formula.references]
|
||||
if target_token in reference_tokens:
|
||||
raise RelationFormulaError(f"关系式不能引用自身:{target_token}。")
|
||||
graph[target_token] = [ref_token for ref_token in reference_tokens if ref_token in target_tokens]
|
||||
|
||||
visit_state: dict[str, str] = {}
|
||||
stack: list[str] = []
|
||||
|
||||
def visit(token: str) -> None:
|
||||
state = visit_state.get(token)
|
||||
if state == "visiting":
|
||||
start_index = stack.index(token) if token in stack else 0
|
||||
cycle = [*stack[start_index:], token]
|
||||
raise RelationFormulaError(f"关系式存在循环依赖:{' -> '.join(cycle)}。")
|
||||
if state == "visited":
|
||||
return
|
||||
visit_state[token] = "visiting"
|
||||
stack.append(token)
|
||||
for dependency in graph.get(token, []):
|
||||
visit(dependency)
|
||||
stack.pop()
|
||||
visit_state[token] = "visited"
|
||||
|
||||
for target_token in graph:
|
||||
visit(target_token)
|
||||
|
||||
|
||||
def relation_value_to_text(value: object) -> str:
|
||||
value = _coerce_formula_value(value)
|
||||
if isinstance(value, Vector3):
|
||||
|
||||
Reference in New Issue
Block a user