feat(cadfs): expand selector provenance coverage

This commit is contained in:
2026-09-14 11:00:14 +08:00
parent 994d06aaea
commit de21ee8a5b
45 changed files with 19837 additions and 842 deletions
@@ -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 悬空超出目标面时不再拒绝,悬空部分被切掉。