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

Function test_operators

tests/test_free_functions.py:566–592  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

564
565# %% bool ops
566def test_operators():
567
568 b1 = box(1, 1, 1).moved(Location(-0.5, -0.5, -0.5)) # small box
569 b2 = box(2, 2, 2).moved(Location(-1, -1, -1)) # large box
570 b3 = b1.moved(Location(0, 0, 1e-4)) # almost b1
571 f = plane(3, 3) # face
572 e = segment((-2, 0), (2, 0)) # edge
573
574 assert (b2 - b1).Volume() == approx(8 - 1)
575
576 assert (b2 * b1).Volume() == approx(1)
577 assert (b1 * f).Area() == approx(1)
578 assert (b1 * e).Length() == approx(1)
579 assert (f * e).Length() == approx(3)
580
581 assert (b2 + b1).Volume() == approx(8)
582
583 assert len((b1 / f).Solids()) == 2
584
585 # test fuzzy ops
586 assert len((b1 + b3).Faces()) == 14
587 assert (b1 - b3).Volume() > 0
588 assert (b1 * b3).Volume() < 1
589
590 assert len(fuse(b1, b3, tol=1e-3).Faces()) == 6
591 assert len(cut(b1, b3, tol=1e-3).Faces()) == 0
592 assert len(intersect(b1, b3, tol=1e-3).Faces()) == 6
593
594
595def test_imprint():

Callers

nothing calls this directly

Calls 13

boxFunction · 0.85
LocationClass · 0.85
planeFunction · 0.85
segmentFunction · 0.85
fuseFunction · 0.85
cutFunction · 0.85
intersectFunction · 0.85
VolumeMethod · 0.80
SolidsMethod · 0.80
movedMethod · 0.45
AreaMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected