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

Function test_prism

tests/test_free_functions.py:765–829  ·  view source on GitHub ↗
(box_shape)

Source from the content-addressed store, hash-verified

763
764
765def test_prism(box_shape):
766
767 ftop = box_shape.faces(">Z")
768 c = circle(0.2).moved(ftop)
769
770 # additive prism
771 res1 = prism(box_shape, ftop, c, 0.1, (0, 0, 1))
772
773 assert res1.isValid()
774 assert res1.Volume() > box_shape.Volume()
775 assert res1.faces().size() == 6 + 2
776
777 # subtractive prism
778 res2 = prism(box_shape, ftop, c, -0.1, (0, 0, 1), False)
779
780 assert res2.isValid()
781 assert res2.Volume() < box_shape.Volume()
782 assert res2.faces().size() == 6 + 2
783
784 # subtractive prism with tilt
785 res3 = prism(box_shape, None, c, box_shape.face("<Z"), (0, 0.1, 1), False)
786
787 assert res3.isValid()
788 assert res3.Volume() < box_shape.Volume()
789 assert res3.faces().size() == 6 + 1
790
791 # subtractive prism without base through all
792 res4 = prism(box_shape, None, c, None, (0, 0, 1), False)
793
794 assert res4.isValid()
795 assert res4.Volume() < box_shape.Volume()
796 assert res4.faces().size() == 6 + 1
797 assert len(res4.face(">Z").innerWires()) == 1
798 assert len(res4.face("<Z").innerWires()) == 1
799
800 # additive prism from/to face
801 tri = face(
802 polygon(
803 ftop.edge("<<X").Center(),
804 ftop.edge(">>X").Center(),
805 ftop.Center() + Vector(0, 0, 1),
806 )
807 )
808
809 res5 = prism(
810 box_shape,
811 None,
812 tri,
813 (box_shape.face("<Y").extend(10), box_shape.face(">Y").extend(10)),
814 )
815
816 assert res5.isValid()
817 assert res5.faces("|Z").size() == 1
818
819 # additive prism from/to face using different overload
820 res6 = prism(
821 box_shape,
822 None,

Callers

nothing calls this directly

Calls 15

circleFunction · 0.85
prismFunction · 0.85
faceFunction · 0.85
polygonFunction · 0.85
VectorClass · 0.85
isValidMethod · 0.80
VolumeMethod · 0.80
innerWiresMethod · 0.80
extendMethod · 0.80
facesMethod · 0.45
movedMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected