Test code simplificatoin for Issue #756

This commit is contained in:
Dalibor Frívaldský 2024-11-07 17:40:51 +01:00
parent e588107bcb
commit 89c29abd07

View file

@ -2567,35 +2567,29 @@ class TestPlane(DirectApiTestCase):
] ]
) )
def face_props(f: Face) -> GProp_GProps:
assert f.wrapped is not None
f_props = GProp_GProps()
BRepGProp.SurfaceProperties_s(f.wrapped, f_props)
return f_props
expected = [ expected = [
# Trapezoid face, negative y coordinate # Trapezoid face, negative y coordinate
( (
lambda f: face_props(f).CentreOfMass(), # plane origin Axis.X.direction, # plane x_dir
lambda f: Axis.X.direction, # plane x_dir Axis.Z.direction, # plane y_dir
lambda f: Axis.Z.direction, # plane y_dir -Axis.Y.direction, # plane z_dir
lambda f: -Axis.Y.direction, # plane z_dir
), ),
# Trapezoid face, positive y coordinate # Trapezoid face, positive y coordinate
( (
lambda f: face_props(f).CentreOfMass(), -Axis.X.direction,
lambda f: -Axis.X.direction, Axis.Z.direction,
lambda f: Axis.Z.direction, Axis.Y.direction,
lambda f: Axis.Y.direction,
), ),
] ]
# assert properties of the trapezoid faces # assert properties of the trapezoid faces
for i, f in enumerate(lofted_solid.faces() | Plane.XZ > Axis.Y): for i, f in enumerate(lofted_solid.faces() | Plane.XZ > Axis.Y):
p = Plane(f) p = Plane(f)
self.assertVectorAlmostEquals(p.origin, expected[i][0](f), 6) f_props = GProp_GProps()
self.assertVectorAlmostEquals(p.x_dir, expected[i][1](f), 6) BRepGProp.SurfaceProperties_s(f.wrapped, f_props)
self.assertVectorAlmostEquals(p.y_dir, expected[i][2](f), 6) self.assertVectorAlmostEquals(p.origin, f_props.CentreOfMass(), 6)
self.assertVectorAlmostEquals(p.z_dir, expected[i][3](f), 6) self.assertVectorAlmostEquals(p.x_dir, expected[i][0], 6)
self.assertVectorAlmostEquals(p.y_dir, expected[i][1], 6)
self.assertVectorAlmostEquals(p.z_dir, expected[i][2], 6)
def test_plane_neg(self): def test_plane_neg(self):
p = Plane( p = Plane(