MCPcopy
hub / github.com/CadQuery/cadquery / test_mirror_workplane

Method test_mirror_workplane

tests/test_workplanes.py:186–206  ·  view source on GitHub ↗

Create a unit box and mirror it so that it doubles in size

(self)

Source from the content-addressed store, hash-verified

184 self.assertAlmostEqual(b2.findSolid().Volume(), 2, 5)
185
186 def test_mirror_workplane(self):
187 """Create a unit box and mirror it so that it doubles in size"""
188 b2 = Workplane().box(1, 1, 1)
189
190 # double in Z plane
191 b2 = b2.mirror(b2.faces(">Z"), union=True)
192 bbBox = b2.findSolid().BoundingBox()
193 assert [bbBox.xlen, bbBox.ylen, bbBox.zlen] == [1.0, 1.0, 2]
194 self.assertAlmostEqual(b2.findSolid().Volume(), 2, 5)
195
196 # double in Y plane
197 b2 = b2.mirror(b2.faces(">Y"), union=True)
198 bbBox = b2.findSolid().BoundingBox()
199 assert [bbBox.xlen, bbBox.ylen, bbBox.zlen] == [1.0, 2.0, 2]
200 self.assertAlmostEqual(b2.findSolid().Volume(), 4, 5)
201
202 # double in X plane
203 b2 = b2.mirror(b2.faces(">X"), union=True)
204 bbBox = b2.findSolid().BoundingBox()
205 assert [bbBox.xlen, bbBox.ylen, bbBox.zlen] == [2.0, 2.0, 2]
206 self.assertAlmostEqual(b2.findSolid().Volume(), 8, 5)
207
208 def test_mirror_equivalence(self):
209 """test that the plane string, plane normal and face object perform a mirror operation in the same way"""

Callers

nothing calls this directly

Calls 7

WorkplaneClass · 0.85
boxMethod · 0.80
findSolidMethod · 0.80
VolumeMethod · 0.80
mirrorMethod · 0.45
facesMethod · 0.45
BoundingBoxMethod · 0.45

Tested by

no test coverage detected