Tests the boudingbox center of a model
(self)
| 1752 | Workplane().intersect(toIntersect) |
| 1753 | |
| 1754 | def testBoundingBox(self): |
| 1755 | """ |
| 1756 | Tests the boudingbox center of a model |
| 1757 | """ |
| 1758 | result0 = ( |
| 1759 | Workplane("XY") |
| 1760 | .moveTo(10, 0) |
| 1761 | .lineTo(5, 0) |
| 1762 | .threePointArc((3.9393, 0.4393), (3.5, 1.5)) |
| 1763 | .threePointArc((3.0607, 2.5607), (2, 3)) |
| 1764 | .lineTo(1.5, 3) |
| 1765 | .threePointArc((0.4393, 3.4393), (0, 4.5)) |
| 1766 | .lineTo(0, 13.5) |
| 1767 | .threePointArc((0.4393, 14.5607), (1.5, 15)) |
| 1768 | .lineTo(28, 15) |
| 1769 | .lineTo(28, 13.5) |
| 1770 | .lineTo(24, 13.5) |
| 1771 | .lineTo(24, 11.5) |
| 1772 | .lineTo(27, 11.5) |
| 1773 | .lineTo(27, 10) |
| 1774 | .lineTo(22, 10) |
| 1775 | .lineTo(22, 13.2) |
| 1776 | .lineTo(14.5, 13.2) |
| 1777 | .lineTo(14.5, 10) |
| 1778 | .lineTo(12.5, 10) |
| 1779 | .lineTo(12.5, 13.2) |
| 1780 | .lineTo(5.5, 13.2) |
| 1781 | .lineTo(5.5, 2) |
| 1782 | .threePointArc((5.793, 1.293), (6.5, 1)) |
| 1783 | .lineTo(10, 1) |
| 1784 | .close() |
| 1785 | ) |
| 1786 | result = result0.extrude(100) |
| 1787 | bb_center = result.val().BoundingBox().center |
| 1788 | self.saveModel(result) |
| 1789 | self.assertAlmostEqual(14.0, bb_center.x, 3) |
| 1790 | self.assertAlmostEqual(7.5, bb_center.y, 3) |
| 1791 | self.assertAlmostEqual(50.0, bb_center.z, 3) |
| 1792 | |
| 1793 | # The following will raise with the default tolerance of TOL 1e-2 |
| 1794 | bb = result.val().BoundingBox(tolerance=1e-3) |
| 1795 | self.assertAlmostEqual(0.0, bb.xmin, 2) |
| 1796 | self.assertAlmostEqual(28, bb.xmax, 2) |
| 1797 | self.assertAlmostEqual(0.0, bb.ymin, 2) |
| 1798 | self.assertAlmostEqual(15.0, bb.ymax, 2) |
| 1799 | self.assertAlmostEqual(0.0, bb.zmin, 2) |
| 1800 | self.assertAlmostEqual(100.0, bb.zmax, 2) |
| 1801 | |
| 1802 | def testBoundBoxEnlarge(self): |
| 1803 | """ |
nothing calls this directly
no test coverage detected