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

Function test_face_interface

tests/test_sketch.py:20–65  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

18
19
20def test_face_interface():
21
22 s1 = Sketch().rect(1, 2, 45)
23
24 assert s1._faces.Area() == approx(2)
25 assert s1.vertices(">X")._selection[0].toTuple()[0] == approx(1.5 / sqrt(2))
26
27 s2 = Sketch().circle(1)
28
29 assert s2._faces.Area() == approx(pi)
30
31 s3 = Sketch().ellipse(2, 0.5)
32
33 assert s3._faces.Area() == approx(pi)
34
35 s4 = Sketch().trapezoid(2, 0.5, 45)
36
37 assert s4._faces.Area() == approx(0.75)
38
39 s4 = Sketch().trapezoid(2, 0.5, 45)
40
41 assert s4._faces.Area() == approx(0.75)
42
43 s5 = Sketch().slot(3, 2)
44
45 assert s5._faces.Area() == approx(6 + pi)
46 assert s5.edges(">Y")._selection[0].Length() == approx(3)
47
48 s6 = Sketch().regularPolygon(1, 5)
49
50 assert len(s6.vertices()._selection) == 5
51 assert s6.vertices(">Y")._selection[0].toTuple()[1] == approx(1)
52
53 s7 = Sketch().polygon([(0, 0), (0, 1), (1, 0)])
54
55 assert len(s7.vertices()._selection) == 3
56 assert s7._faces.Area() == approx(0.5)
57
58 s8 = Sketch().face(Sketch().rect(1, 1).val())
59 assert s8._faces.Area() == approx(1)
60
61 s9 = Sketch().face(Sketch().rect(1, 1))
62 assert s9._faces.Area() == approx(1)
63
64 with raises(ValueError):
65 Sketch().face(1234)
66
67
68def test_modes():

Callers

nothing calls this directly

Calls 15

SketchClass · 0.90
trapezoidMethod · 0.80
slotMethod · 0.80
regularPolygonMethod · 0.80
rectMethod · 0.45
AreaMethod · 0.45
toTupleMethod · 0.45
verticesMethod · 0.45
circleMethod · 0.45
ellipseMethod · 0.45
LengthMethod · 0.45
edgesMethod · 0.45

Tested by

no test coverage detected