Added Face.is_coplanar

This commit is contained in:
Roger Maitland 2023-03-03 21:03:25 -05:00
parent 74bc452ad9
commit 593ca4719e
2 changed files with 22 additions and 2 deletions

View file

@ -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

View file

@ -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):