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

Method testCompoundCenter

tests/test_cad_objects.py:268–293  ·  view source on GitHub ↗

Tests whether or not a proper weighted center can be found for a compound

(self)

Source from the content-addressed store, hash-verified

266 pass
267
268 def testCompoundCenter(self):
269 """
270 Tests whether or not a proper weighted center can be found for a compound
271 """
272
273 def cylinders(self, radius, height):
274
275 c = Solid.makeCylinder(radius, height, Vector())
276
277 # Combine all the cylinders into a single compound
278 r = self.eachpoint(lambda loc: c.located(loc), True).union()
279
280 return r
281
282 Workplane.cyl = cylinders
283
284 # Now test. here we want weird workplane to see if the objects are transformed right
285 s = (
286 Workplane("XY")
287 .rect(2.0, 3.0, forConstruction=True)
288 .vertices()
289 .cyl(0.25, 0.5)
290 )
291
292 self.assertEqual(4, len(s.val().Solids()))
293 self.assertTupleAlmostEquals((0.0, 0.0, 0.25), s.val().Center().toTuple(), 3)
294
295 def testDot(self):
296 v1 = Vector(2, 2, 2)

Callers

nothing calls this directly

Calls 8

WorkplaneClass · 0.85
SolidsMethod · 0.80
verticesMethod · 0.45
rectMethod · 0.45
valMethod · 0.45
toTupleMethod · 0.45
CenterMethod · 0.45

Tested by

no test coverage detected