生成无重叠的 0.2 mm Xynova 笔画图案
在打印页毫米坐标中筛选候选笔画,更新双 UV 产物。38 项测试通过;SVG 检查无交叠。
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
"""Check laser-mark clearance in physical page coordinates."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "blender" / "scripts"))
|
||||
|
||||
from stroke_geometry import has_clearance # noqa: E402
|
||||
|
||||
|
||||
def test_crossing_capsules_are_rejected() -> None:
|
||||
existing = [((-0.2, 0), (0.2, 0), 0.1)]
|
||||
assert not has_clearance(((0, -0.2), (0, 0.2), 0.1), existing, 0.03)
|
||||
|
||||
|
||||
def test_near_parallel_capsules_need_edge_spacing() -> None:
|
||||
existing = [((-0.2, 0), (0.2, 0), 0.1)]
|
||||
assert not has_clearance(((-0.2, 0.22), (0.2, 0.22), 0.1), existing, 0.03)
|
||||
assert has_clearance(((-0.2, 0.24), (0.2, 0.24), 0.1), existing, 0.03)
|
||||
|
||||
|
||||
def test_disjoint_collinear_capsules_can_clear() -> None:
|
||||
existing = [((0, 0), (0.2, 0), 0.1)]
|
||||
assert has_clearance(((0.45, 0), (0.65, 0), 0.1), existing, 0.03)
|
||||
@@ -114,6 +114,8 @@ def test_boolean_is_not_a_number() -> None:
|
||||
("coverage_cap", 0.0, "within (0, 1]"),
|
||||
("coverage_cap", 1.5, "within (0, 1]"),
|
||||
("neighbourhood_mm", 0.0, "must be > 0"),
|
||||
("clearance_mm", -0.01, "must be >= 0"),
|
||||
("candidate_count", 0, "must be >= 1"),
|
||||
],
|
||||
)
|
||||
def test_range_rules(key: str, value, expected: str) -> None:
|
||||
@@ -173,10 +175,14 @@ def test_written_params_round_trip(tmp_path: Path) -> None:
|
||||
|
||||
|
||||
@pytest.mark.parametrize("sensor", ["finger", "finger-xynova"])
|
||||
def test_shipped_revisions_declare_the_block_at_the_defaults(sensor: str) -> None:
|
||||
"""The yaml documents the shipped values, so an untouched revision changes nothing."""
|
||||
def test_shipped_revisions_declare_the_expected_block(sensor: str) -> None:
|
||||
"""The YAML records both legacy and Xynova manufacturing settings."""
|
||||
paths = RevisionPaths.from_revision_dir(repo_root() / "sensors" / sensor / "r01")
|
||||
design = yaml.safe_load(paths.design_yaml.read_text(encoding="utf-8"))
|
||||
block = design.get("stroke_pattern")
|
||||
assert block is not None, f"{sensor}/r01 has no stroke_pattern block"
|
||||
assert stroke_pattern.resolve_stroke_settings(block) == stroke_pattern.STROKE_DEFAULTS
|
||||
resolved = stroke_pattern.resolve_stroke_settings(block)
|
||||
expected = dict(stroke_pattern.STROKE_DEFAULTS)
|
||||
if sensor == "finger-xynova":
|
||||
expected.update(width_min_mm=0.20, clearance_mm=0.03, candidate_count=12)
|
||||
assert resolved == expected
|
||||
|
||||
Reference in New Issue
Block a user