MCPcopy Index your code
hub / github.com/CadQuery/cadquery / test_constructors

Function test_constructors

tests/test_free_functions.py:183–228  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

181
182
183def test_constructors():
184
185 # wire
186 e1 = segment((0, 0), (0, 1))
187 e2 = segment((0, 1), (1, 1))
188 e3 = segment((1, 1), (1, 0))
189 e4 = segment((1, 0), (0, 0))
190
191 w1 = wire(e1, e2, e3, e4)
192 w2 = wire((e1, e2, e3, e4))
193
194 assert w1.Length() == approx(4)
195 assert w2.Length() == approx(4)
196
197 # face
198 f1 = face(w1, circle(0.1).moved(Location(0.5, 0.5, 0)))
199 f2 = face((w1,))
200
201 assert f1.Area() < 1
202 assert len(f1.Wires()) == 2
203 assert f2.Area() == approx(1)
204 assert len(f2.Wires()) == 1
205
206 with raises(ValueError):
207 face(e1)
208
209 # shell
210 b = box(1, 1, 1)
211
212 sh1 = shell(b.Faces())
213 sh2 = shell(*b.Faces())
214 sh3 = shell(torus(1, 0.1).Faces()) # check for issues when sewing single face
215
216 assert sh1.Area() == approx(6)
217 assert sh2.Area() == approx(6)
218 assert sh3.isValid()
219
220 # compound
221 c1 = compound(b.Faces())
222 c2 = compound(*b.Faces())
223
224 assert len(list(c1)) == 6
225 assert len(list(c2)) == 6
226
227 for f in list(c1) + list(c2):
228 assert f.ShapeType() == "Face"
229
230
231def test_sewing():

Callers

nothing calls this directly

Calls 15

segmentFunction · 0.85
wireFunction · 0.85
faceFunction · 0.85
circleFunction · 0.85
LocationClass · 0.85
boxFunction · 0.85
shellFunction · 0.85
torusFunction · 0.85
compoundFunction · 0.85
WiresMethod · 0.80
isValidMethod · 0.80
LengthMethod · 0.45

Tested by

no test coverage detected