feat(spatial): 近贴合家族与容差扫描
稳定性家族加 clearance 参数(把上块抬离底座 0/1/2/4 格,1 格 = 0.25mm), 新增 area.gap1/2/4。extract 加 tol 子命令:对每个间隙扫容差,问两件事——会不会 提取出一条不存在的 T-P 接触,以及这条假边会不会被检查器接受为有效凭证。
This commit is contained in:
1 parent
e798d8fc43
commit
b46c76ce9a
2 files changed
+59
-5
No files matched your search
+17
-4
@@ -32,6 +32,9 @@ FAMILIES = {
|
||||
"area.free": {"domain": "stability", "n_blocks": 2, "hidden": 0, "free": 1},
|
||||
"area.sup3h": {"domain": "stability", "n_blocks": 3, "hidden": 1},
|
||||
"area.sup2d": {"domain": "stability", "n_blocks": 2, "hidden": 0, "notch": 1},
|
||||
"area.gap1": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 1},
|
||||
"area.gap2": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 2},
|
||||
"area.gap4": {"domain": "stability", "n_blocks": 2, "hidden": 0, "clearance": 4},
|
||||
"dof.c6": {"domain": "freedom", "n_cons": 6, "hidden": 0},
|
||||
"dof.c6r": {"domain": "freedom", "n_cons": 7, "hidden": 0},
|
||||
"dof.c6h": {"domain": "freedom", "n_cons": 6, "hidden": 1},
|
||||
@@ -129,7 +132,8 @@ def _build_connection(rng, n_paths: int, hidden: int):
|
||||
# stability: stacked blocks, optional hidden pedestal
|
||||
|
||||
|
||||
def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int = 0):
|
||||
def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int = 0,
|
||||
clearance: int = 0):
|
||||
if free:
|
||||
# the minimal pair against area.sup2h: here T has exactly one contact and
|
||||
# that contact leads to a block which itself hangs in the air. Nothing
|
||||
@@ -156,16 +160,22 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int
|
||||
# is exactly what the report kept showing.
|
||||
dx = rng.choice((-13, -6, 0, 3, 6, 13))
|
||||
dy = rng.choice((-9, 0, 0, 0, 9))
|
||||
# clearance lifts the upper block off its pedestal by a few grid units (one
|
||||
# grid unit is 0.25mm). At 0 the two surfaces touch exactly; at 1 they are
|
||||
# 0.25mm apart, which is the regime real assemblies live in and the regime a
|
||||
# distance tolerance actually has to decide.
|
||||
cl = int(clearance)
|
||||
ents = [Entity("G", "ground", attrs={"plane": 0}),
|
||||
Entity("P", "block", attrs={"box": [40, 40, 0, 60, 60, 20]}),
|
||||
Entity("T", "block", attrs={"box": [42 + dx, 42 + dy, 20, 58 + dx, 58 + dy, 36]}),
|
||||
Entity("T", "block", attrs={"box": [42 + dx, 42 + dy, 20 + cl,
|
||||
58 + dx, 58 + dy, 36 + cl]}),
|
||||
Entity("D", "block", attrs={"box": [80, 40, 0, 100, 60, 16]})]
|
||||
edges = [Edge("kPG", "contact", "P", "G"), Edge("kPT", "contact", "T", "P"),
|
||||
Edge("kDG", "contact", "D", "G")]
|
||||
top = None
|
||||
if n_blocks >= 3:
|
||||
ents.append(Entity("U", "block",
|
||||
attrs={"box": [44 + dx, 44 + dy, 36, 56 + dx, 56 + dy, 48]}))
|
||||
attrs={"box": [44 + dx, 44 + dy, 36 + cl, 56 + dx, 56 + dy, 48 + cl]}))
|
||||
edges.append(Edge("kTU", "contact", "U", "T"))
|
||||
top = "U"
|
||||
vis_edges = {e.eid for e in edges}
|
||||
@@ -195,6 +205,8 @@ def _build_stability(rng, n_blocks: int, hidden: int, free: int = 0, notch: int
|
||||
# that removes P, so "removed something" no longer implies "answer false"
|
||||
query = Query(kind="stability", a="T")
|
||||
r = rng.random()
|
||||
if clearance:
|
||||
return ents, edges, query, vis_edges, vis_ents, layers, ["front", "iso"], {"length": "mm", "per_unit": 1}
|
||||
if not hidden:
|
||||
harmless = top or "D"
|
||||
if r < 0.4:
|
||||
@@ -264,7 +276,8 @@ def _build_freedom(rng, n_cons: int, hidden: int, no_edit: int = 0, notch: int =
|
||||
_BUILDERS = {
|
||||
"connection": lambda rng, spec: _build_connection(rng, spec["n_paths"], spec["hidden"]),
|
||||
"stability": lambda rng, spec: _build_stability(rng, spec["n_blocks"], spec["hidden"],
|
||||
spec.get("free", 0), spec.get("notch", 0)),
|
||||
spec.get("free", 0), spec.get("notch", 0),
|
||||
spec.get("clearance", 0)),
|
||||
"freedom": lambda rng, spec: _build_freedom(rng, spec["n_cons"], spec["hidden"],
|
||||
spec.get("no_edit", 0), spec.get("notch", 0)),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user