Added check for open wires in Face constructor
Some checks are pending
benchmarks / benchmarks (macos-14, 3.12) (push) Waiting to run
benchmarks / benchmarks (macos-15-intel, 3.12) (push) Waiting to run
benchmarks / benchmarks (ubuntu-latest, 3.12) (push) Waiting to run
benchmarks / benchmarks (windows-latest, 3.12) (push) Waiting to run
Upload coverage reports to Codecov / run (push) Waiting to run
pylint / lint (3.10) (push) Waiting to run
Wheel building and publishing / Build wheel on ubuntu-latest (push) Waiting to run
Wheel building and publishing / upload_pypi (push) Blocked by required conditions
tests / tests (macos-14, 3.10) (push) Waiting to run
tests / tests (macos-14, 3.14) (push) Waiting to run
tests / tests (macos-15-intel, 3.10) (push) Waiting to run
tests / tests (macos-15-intel, 3.14) (push) Waiting to run
tests / tests (ubuntu-latest, 3.10) (push) Waiting to run
tests / tests (ubuntu-latest, 3.14) (push) Waiting to run
tests / tests (windows-latest, 3.10) (push) Waiting to run
tests / tests (windows-latest, 3.14) (push) Waiting to run
Run type checking / typecheck (3.10) (push) Waiting to run
Run type checking / typecheck (3.14) (push) Waiting to run

This commit is contained in:
Roger Maitland 2026-03-22 11:11:12 -04:00
parent aa05d578f0
commit 1603ead57b
2 changed files with 14 additions and 1 deletions

View file

@ -764,6 +764,11 @@ class Face(Mixin2D[TopoDS_Face]):
inner_topods_wires = (
[w.wrapped for w in inner_wires] if inner_wires is not None else []
)
if any(
not BRep_Tool.IsClosed_s(w)
for w in [outer_wire.wrapped] + inner_topods_wires
):
raise ValueError("Face can only be created with closed wires")
obj = _make_topods_face_from_wires(outer_wire.wrapped, inner_topods_wires)
super().__init__(

View file

@ -1280,8 +1280,16 @@ class TestFace(unittest.TestCase):
self.assertTrue(isinstance(revolved, Shell))
self.assertAlmostEqual(revolved.edges().sort_by(Axis.Y)[-1].radius, 2, 5)
def test_open_wire(self):
perimeter = Polyline((0, 0), (1, 0), (1, 1), (0, 1))
with self.assertRaises(ValueError):
Face(perimeter)
class TestAxesOfSymmetrySplitNone(unittest.TestCase):
with self.assertRaises(ValueError):
Face(Wire.make_circle(5), [perimeter])
class TestAxesOfSysmmetrySplitNone(unittest.TestCase):
def test_split_returns_none(self):
# Create a rectangle face for testing.
rect = Rectangle(10, 5).face()