test that the plane string, plane normal and face object perform a mirror operation in the same way
(self)
| 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""" |
| 210 | boxes = [] |
| 211 | boxDims = 1 |
| 212 | for i in range(3): # create 3 sets of identical boxes |
| 213 | boxTmp = Workplane("XY").box(boxDims, boxDims, boxDims) |
| 214 | boxTmp = boxTmp.translate([i * 2, 0, boxDims / 2]) |
| 215 | boxes.append(boxTmp) |
| 216 | |
| 217 | # 3 different types of plane definition |
| 218 | planeArg = ["XY", (0, 0, 1), boxes[0].faces("<Z")] |
| 219 | planeOffset = (0, 0, 0.5) # use the safe offset for each |
| 220 | boxResults = [] # store the resulting mirrored objects |
| 221 | for b, p in zip(boxes, planeArg): |
| 222 | boxResults.append(b.mirror(p, planeOffset, union=True)) |
| 223 | |
| 224 | # all resulting boxes should be equal to each other |
| 225 | for i in range(len(boxResults) - 1): |
| 226 | curBoxDims = boxResults[i].findSolid().BoundingBox() # get bbox dims |
| 227 | nextBoxDims = boxResults[i + 1].findSolid().BoundingBox() # get bbox dims |
| 228 | cbd = (curBoxDims.xlen, curBoxDims.ylen, curBoxDims.zlen) |
| 229 | nbd = (nextBoxDims.xlen, nextBoxDims.ylen, nextBoxDims.zlen) |
| 230 | self.assertTupleAlmostEquals(cbd, nbd, 4) |
| 231 | self.assertAlmostEqual( |
| 232 | boxResults[i].findSolid().Volume(), |
| 233 | boxResults[i + 1].findSolid().Volume(), |
| 234 | 5, |
| 235 | ) |
| 236 | |
| 237 | def test_mirror_face(self): |
| 238 | """Create a triangle and mirror into a unit box""" |
nothing calls this directly
no test coverage detected