feat(cadfs): expand reconstruction capability coverage
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from copy import deepcopy
|
||||
import tempfile, unittest
|
||||
from pathlib import Path
|
||||
from cadfs_to_cdsl.compare import compare_steps
|
||||
@@ -130,6 +131,32 @@ class IntegrationTests(unittest.TestCase):
|
||||
self.assertEqual(outcome["status"], "rebuilt")
|
||||
self.assertEqual(outcome["result"]["solid_count"], 2)
|
||||
|
||||
def test_outward_cap_shells_lower_and_rebuild_prefixes(self):
|
||||
root = Path(__file__).parents[2] / "data/cadfs-sample/CADFS_test"
|
||||
cases = (("00090436", 2.5), ("00107631", 3.8))
|
||||
for sample_id, thickness in cases:
|
||||
with self.subTest(sample_id=sample_id):
|
||||
feature = root / "featurescript_rp" / sample_id[:4] / f"{sample_id}.txt"
|
||||
if not feature.exists(): self.skipTest("CADFS sample is not installed")
|
||||
|
||||
result = lower_model(parse_featurescript(feature.read_text(), sample_id), {})
|
||||
shell_index, shell = next(
|
||||
(index, item)
|
||||
for index, item in enumerate(result.cdsl["features"])
|
||||
if item["id"] == "f_F2"
|
||||
)
|
||||
|
||||
self.assertEqual(shell["atomic_id"], "shell")
|
||||
self.assertEqual(shell["params"], {"thickness_mm": thickness, "inward": False})
|
||||
self.assertNotIn("shell_outward", {item.get("capability") for item in result.diagnostics})
|
||||
|
||||
prefix = deepcopy(result.cdsl)
|
||||
prefix["features"] = prefix["features"][:shell_index + 1]
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
outcome = rebuild_candidate(prefix, Path(tmp) / "outward-shell.step")
|
||||
self.assertEqual(outcome["status"], "rebuilt")
|
||||
self.assertEqual(outcome["result"]["solid_count"], 1)
|
||||
|
||||
def test_sweep_00542223_preserves_its_open_bspline_path(self):
|
||||
root = Path(__file__).parents[2] / "data/cadfs-sample/CADFS_test"
|
||||
feature = root / "featurescript_rp/0054/00542223.txt"
|
||||
@@ -137,13 +164,57 @@ class IntegrationTests(unittest.TestCase):
|
||||
result = lower_model(parse_featurescript(feature.read_text(), "00542223"), {})
|
||||
sweep = next(item for item in result.cdsl["features"] if item["id"] == "f_F5")
|
||||
segment = sweep["params"]["path"]["segment"]
|
||||
self.assertEqual(result.status, "converted_complete")
|
||||
self.assertEqual(sweep["atomic_id"], "sweep_add")
|
||||
self.assertEqual(sweep["sketch_id"], "sketch_F4")
|
||||
self.assertEqual(segment["points"], [[-40.0, -50.0], [-20.0, -14.96], [0.0, 5.0]])
|
||||
self.assertEqual(segment["start_tangent"], [27.94, 92.49])
|
||||
self.assertEqual(segment["end_tangent"], [52.88, 49.52])
|
||||
self.assertNotIn("F2", [item.get("feature_id") for item in result.diagnostics])
|
||||
self.assertNotIn("F5", [item.get("feature_id") for item in result.diagnostics])
|
||||
|
||||
def test_circular_pattern_00542223_preserves_all_sweep_arms(self):
|
||||
root = Path(__file__).parents[2] / "data/cadfs-sample/CADFS_test"
|
||||
feature = root / "featurescript_rp/0054/00542223.txt"
|
||||
if not feature.exists(): self.skipTest("CADFS sample is not installed")
|
||||
result = lower_model(parse_featurescript(feature.read_text(), "00542223"), {})
|
||||
candidate = dict(result.cdsl)
|
||||
candidate["features"] = result.cdsl["features"][:4]
|
||||
|
||||
from engine.cdsl_engine.runtime import rebuild_cdsl
|
||||
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
rebuilt = rebuild_cdsl(candidate, Path(tmp) / "pattern.step")
|
||||
|
||||
self.assertEqual(rebuilt["solid_count"], 1)
|
||||
bbox = rebuilt["bbox_mm"]
|
||||
self.assertAlmostEqual(bbox["min"][0], -52.14101625137758)
|
||||
self.assertAlmostEqual(bbox["min"][1], -57.500000100000065)
|
||||
self.assertAlmostEqual(bbox["max"][0], 52.14101625137762)
|
||||
self.assertAlmostEqual(bbox["max"][1], 37.5000001000001)
|
||||
|
||||
def test_fused_body_circular_copy_faces_bind_and_shell_00542223(self):
|
||||
root = Path(__file__).parents[2] / "data/cadfs-sample/CADFS_test"
|
||||
feature = root / "featurescript_rp/0054/00542223.txt"
|
||||
if not feature.exists(): self.skipTest("CADFS sample is not installed")
|
||||
|
||||
candidate = lower_model(parse_featurescript(feature.read_text(), "00542223"), {}).cdsl
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
outcome = rebuild_candidate(candidate, Path(tmp) / "rebuild.step")
|
||||
|
||||
self.assertEqual(outcome["status"], "rebuilt")
|
||||
result = outcome["result"]
|
||||
self.assertIn("f_F7", [item["feature_id"] for item in result["feature_results"]])
|
||||
shell_selectors = [
|
||||
item for item in result["selector_resolution"]
|
||||
if item["feature_id"] == "f_F7"
|
||||
]
|
||||
self.assertEqual(
|
||||
{item["selector"]["owner_feature_id"] for item in shell_selectors},
|
||||
{"f_F5", "f_F6.c1.f_F5", "f_F6.c2.f_F5", "f_F1"},
|
||||
)
|
||||
self.assertTrue(all(item["status"] == "resolved" for item in shell_selectors))
|
||||
|
||||
def test_face_chamfer_ignores_periodic_seams_00111611(self):
|
||||
root = Path(__file__).parents[2] / "data/cadfs-sample/CADFS_test"
|
||||
feature = root / "featurescript_rp/0011/00111611.txt"
|
||||
|
||||
Reference in New Issue
Block a user