MCPcopy Index your code
hub / github.com/CadQuery/cadquery / testWedgeCentering

Method testWedgeCentering

tests/test_cadquery.py:2668–2707  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

2666 self.assertEqual(5, s.vertices().size())
2667
2668 def testWedgeCentering(self):
2669 s = Workplane("XY").wedge(
2670 10, 10, 10, 5, 5, 5, 5, centered=(False, False, False)
2671 )
2672 # self.saveModel(s)
2673 self.assertEqual(1, s.solids().size())
2674 self.assertEqual(5, s.faces().size())
2675 self.assertEqual(5, s.vertices().size())
2676
2677 # check that the bottom corner is where we expect it for all possible combinations of centered
2678 x, y, z = 10, 11, 12
2679 b = [True, False]
2680 expected_x = [-x / 2, 0]
2681 expected_y = [-y / 2, 0]
2682 expected_z = [-z / 2, 0]
2683 for (xopt, xval), (yopt, yval), (zopt, zval) in product(
2684 zip(b, expected_x), zip(b, expected_y), zip(b, expected_z)
2685 ):
2686 s = (
2687 Workplane()
2688 .wedge(x, y, z, 2, 2, x - 2, z - 2, centered=(xopt, yopt, zopt))
2689 .vertices("<X and <Y and <Z")
2690 )
2691 self.assertEqual(s.size(), 1)
2692 self.assertTupleAlmostEquals(s.val().toTuple(), (xval, yval, zval), 3)
2693 # check centered=True produces the same result as centered=(True, True, True)
2694 for val in b:
2695 s0 = (
2696 Workplane()
2697 .wedge(x, y, z, 2, 2, x - 2, z - 2, centered=val)
2698 .vertices(">X and >Z")
2699 )
2700 self.assertEqual(s0.size(), 1)
2701 s1 = (
2702 Workplane()
2703 .wedge(x, y, z, 2, 2, x - 2, z - 2, centered=(val, val, val))
2704 .vertices(">X and >Z")
2705 )
2706 self.assertEqual(s0.size(), 1)
2707 self.assertTupleAlmostEquals(s0.val().toTuple(), s1.val().toTuple(), 3)
2708
2709 def testWedgePointList(self):
2710 s = (

Callers

nothing calls this directly

Calls 9

WorkplaneClass · 0.85
wedgeMethod · 0.80
sizeMethod · 0.45
solidsMethod · 0.45
facesMethod · 0.45
verticesMethod · 0.45
toTupleMethod · 0.45
valMethod · 0.45

Tested by

no test coverage detected