diff --git a/src/build123d/topology.py b/src/build123d/topology.py index 0941eab..7da7b28 100644 --- a/src/build123d/topology.py +++ b/src/build123d/topology.py @@ -3962,12 +3962,16 @@ class Face(Shape): @overload @classmethod - def make_ruled_surface(cls, edge1: Edge, edge2: Edge) -> Face: # pragma: no cover + def make_surface_from_curves( + cls, edge1: Edge, edge2: Edge + ) -> Face: # pragma: no cover ... @overload @classmethod - def make_ruled_surface(cls, wire1: Wire, wire2: Wire) -> Face: # pragma: no cover + def make_surface_from_curves( + cls, wire1: Wire, wire2: Wire + ) -> Face: # pragma: no cover ... @classmethod @@ -4316,6 +4320,15 @@ class Face(Shape): return plane + def is_coplanar(self, plane: Plane) -> bool: + """Is this planar face coplanar with the provided plane""" + return self.geom_type() == "PLANE" and all( + [ + plane.contains(pnt) + for pnt in self.outer_wire().positions([i / 7 for i in range(8)]) + ] + ) + def thicken(self, depth: float, normal_override: VectorLike = None) -> Solid: """Thicken Face diff --git a/tests/test_direct_api.py b/tests/test_direct_api.py index 947edeb..c2fd8b3 100644 --- a/tests/test_direct_api.py +++ b/tests/test_direct_api.py @@ -971,6 +971,13 @@ class TestFace(unittest.TestCase): self.assertAlmostEqual(imported_torus.area, torus.area, 0) os.remove("test_torus.stl") + def test_is_coplanar(self): + square = Face.make_rect(1, 1, plane=Plane.XZ) + self.assertTrue(square.is_coplanar(Plane.XZ)) + self.assertFalse(square.is_coplanar(Plane.XY)) + surface: Face = Solid.make_sphere(1).faces()[0] + self.assertFalse(surface.is_coplanar(Plane.XY)) + class TestFunctions(unittest.TestCase): def test_edges_to_wires(self):