feat(cadfs): expand selector provenance coverage
This commit is contained in:
@@ -57,7 +57,7 @@ from cdsl_engine.runtime import rebuild_cdsl # noqa: E402
|
||||
|
||||
|
||||
try:
|
||||
from build123d import Face, Plane, Vector # noqa: F401
|
||||
from build123d import Face, Plane, Solid, Vector # noqa: F401
|
||||
_HAS_BUILD123D = True
|
||||
except ImportError:
|
||||
_HAS_BUILD123D = False
|
||||
@@ -137,6 +137,39 @@ class ExtentTrimContractTests(unittest.TestCase):
|
||||
|
||||
self.assertAlmostEqual(trimmed.volume, 500.0, places=5)
|
||||
|
||||
@unittest.skipUnless(_HAS_BUILD123D, "build123d is not available")
|
||||
def test_planar_supporting_surface_accepts_only_a_complete_forward_profile(self) -> None:
|
||||
"""A wholly unreachable planar face may supply its support plane.
|
||||
|
||||
The finite target is deliberately outside the profile's x/y range,
|
||||
so no ray intersects its trim. The underlying z=5 plane still gives
|
||||
one exact +z termination distance. This is distinct from the
|
||||
partial-hit trim contract below.
|
||||
"""
|
||||
profile = Face.make_rect(2, 2, Plane(origin=(8, 0, 0)))
|
||||
target = Face.make_rect(2, 2, Plane(origin=(0, 0, 5)))
|
||||
|
||||
self.assertTrue(all(
|
||||
Build123dGeometryAdapter._forward_intersection_distance(target, point, Vector(0, 0, 1)) is None
|
||||
for point in Build123dGeometryAdapter.profile_sample_points(profile)
|
||||
))
|
||||
self.assertAlmostEqual(
|
||||
Build123dGeometryAdapter.uniform_planar_supporting_surface_distance(target, [profile], (0, 0, 1)),
|
||||
5.0,
|
||||
places=6,
|
||||
)
|
||||
|
||||
@unittest.skipUnless(_HAS_BUILD123D, "build123d is not available")
|
||||
def test_planar_supporting_surface_rejects_parallel_and_non_planar_targets(self) -> None:
|
||||
profile = Face.make_rect(2, 2)
|
||||
parallel = Face.make_rect(2, 2, Plane(origin=(0, 0, 5), z_dir=(1, 0, 0)))
|
||||
cylindrical = next(face for face in Solid.make_cylinder(2, 4).faces() if face.geom_type != Face.make_rect(1, 1).geom_type)
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "parallel"):
|
||||
Build123dGeometryAdapter.uniform_planar_supporting_surface_distance(parallel, [profile], (0, 0, 1))
|
||||
with self.assertRaisesRegex(ValueError, "planar"):
|
||||
Build123dGeometryAdapter.uniform_planar_supporting_surface_distance(cylindrical, [profile], (0, 0, 1))
|
||||
|
||||
@unittest.skipUnless(_HAS_BUILD123D, "build123d is not available")
|
||||
def test_up_to_surface_hanging_profile_is_trimmed_not_rejected(self) -> None:
|
||||
"""集成裁剪契约:profile 悬空超出目标面时不再拒绝,悬空部分被切掉。
|
||||
|
||||
@@ -205,6 +205,15 @@ class MultiBodyContractTests(unittest.TestCase):
|
||||
if r["kind"] == "face" and r.get("body_id", "").startswith("body:cut_1:")
|
||||
}
|
||||
self.assertEqual(member_ids, {"body:cut_1:0", "body:cut_1:1"})
|
||||
cut_delta = next(item for item in rebuilt["topology_deltas"] if item["feature_id"] == "cut_1")
|
||||
self.assertEqual(cut_delta["operation"], "subtract")
|
||||
self.assertEqual(cut_delta["history_status"], "proven")
|
||||
self.assertEqual(cut_delta["history_reason"], "per_member_exact_cut_history")
|
||||
self.assertEqual(
|
||||
{record_id.split(":face:", 1)[0] for relation in cut_delta["relations"]
|
||||
for record_id in relation["source_record_ids"] if ":face:" in record_id},
|
||||
{"body:add_2:0", "body:add_2:1"},
|
||||
)
|
||||
|
||||
def test_face_selector_resolves_on_multi_body_via_prefix_matching(self) -> None:
|
||||
"""多体 + selector resolve 契约:face selector 经前缀匹配命中正确实体。
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user