Tests the interpPlate() functionalities Numerical values of Areas and Volumes were obtained with the Area() and Volume() functions on a Linux machine under Debian 10 with python 3.7.
(self)
| 4387 | self.assertEqual(0, result2.compounds(tag="4 objs").size()) |
| 4388 | |
| 4389 | def test_interpPlate(self): |
| 4390 | """ |
| 4391 | Tests the interpPlate() functionalities |
| 4392 | Numerical values of Areas and Volumes were obtained with the Area() and Volume() functions on a Linux machine under Debian 10 with python 3.7. |
| 4393 | """ |
| 4394 | |
| 4395 | # example from PythonOCC core_geometry_geomplate.py, use of thickness = 0 returns 2D surface. |
| 4396 | thickness = 0 |
| 4397 | edge_points = [ |
| 4398 | (0.0, 0.0, 0.0), |
| 4399 | (0.0, 10.0, 0.0), |
| 4400 | (0.0, 10.0, 10.0), |
| 4401 | (0.0, 0.0, 10.0), |
| 4402 | ] |
| 4403 | surface_points = [(5.0, 5.0, 5.0)] |
| 4404 | plate_0 = Workplane("XY").interpPlate(edge_points, surface_points, thickness) |
| 4405 | self.assertTrue(plate_0.val().isValid()) |
| 4406 | self.assertAlmostEqual(plate_0.val().Area(), 141.218823892, 1) |
| 4407 | |
| 4408 | # Plate with 5 sides and 2 bumps, one side is not co-planar with the other sides |
| 4409 | thickness = 0.1 |
| 4410 | edge_points = [ |
| 4411 | (-7.0, -7.0, 0.0), |
| 4412 | (-3.0, -10.0, 3.0), |
| 4413 | (7.0, -7.0, 0.0), |
| 4414 | (7.0, 7.0, 0.0), |
| 4415 | (-7.0, 7.0, 0.0), |
| 4416 | ] |
| 4417 | edge_wire = Workplane("XY").polyline( |
| 4418 | [(-7.0, -7.0), (7.0, -7.0), (7.0, 7.0), (-7.0, 7.0)] |
| 4419 | ) |
| 4420 | # edge_wire = edge_wire.add(Workplane('YZ').workplane().transformed(offset=Vector(0, 0, -7), rotate=Vector(45, 0, 0)).polyline([(-7.,0.), (3,-3), (7.,0.)])) |
| 4421 | # In CadQuery Sept-2019 it worked with rotate=Vector(0, 45, 0). In CadQuery Dec-2019 rotate=Vector(45, 0, 0) only closes the wire. |
| 4422 | edge_wire = edge_wire.add( |
| 4423 | Workplane("YZ") |
| 4424 | .workplane() |
| 4425 | .transformed(offset=Vector(0, 0, -7), rotate=Vector(45, 0, 0)) |
| 4426 | .spline([(-7.0, 0.0), (3, -3), (7.0, 0.0)]) |
| 4427 | ) |
| 4428 | surface_points = [(-3.0, -3.0, -3.0), (3.0, 3.0, 3.0)] |
| 4429 | plate_1 = Workplane("XY").interpPlate(edge_wire, surface_points, thickness) |
| 4430 | self.assertTrue(plate_1.val().isValid()) |
| 4431 | self.assertAlmostEqual(plate_1.val().Volume(), 26.124970206, 2) |
| 4432 | |
| 4433 | # Embossed star, need to change optional parameters to obtain nice looking result. |
| 4434 | r1 = 3.0 |
| 4435 | r2 = 10.0 |
| 4436 | fn = 6 |
| 4437 | thickness = 0.1 |
| 4438 | edge_points = [ |
| 4439 | (r1 * math.cos(i * math.pi / fn), r1 * math.sin(i * math.pi / fn)) |
| 4440 | if i % 2 == 0 |
| 4441 | else (r2 * math.cos(i * math.pi / fn), r2 * math.sin(i * math.pi / fn)) |
| 4442 | for i in range(2 * fn + 1) |
| 4443 | ] |
| 4444 | edge_wire = Workplane("XY").polyline(edge_points) |
| 4445 | r2 = 4.5 |
| 4446 | surface_points = [ |
nothing calls this directly
no test coverage detected