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

Function test_surface

tests/test_nurbs.py:213–245  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

211
212
213def test_surface():
214
215 uknots = vknots = np.array([0, 0, 1, 1])
216 pts = np.array([[[0, 0, 0], [0, 1, 0]], [[1, 0, 0], [1, 1, 0]]])
217
218 srf = Surface(pts, uknots, vknots, 1, 1, False, False)
219
220 # convert to a face
221 f = srf.face()
222
223 assert f.isValid()
224 assert f.Area() == approx(1)
225
226 # roundtrip
227 srf2 = Surface.fromFace(f)
228
229 assert np.allclose(srf.uknots, srf2.uknots)
230 assert np.allclose(srf.vknots, srf2.vknots)
231 assert np.allclose(srf.pts, srf2.pts)
232
233 # eval
234 pt = srf(0, 0)
235 assert np.allclose(pt, pts[0, 0])
236
237 # eval der
238 der = srf.der(0, 0, 1)
239 assert np.allclose(der[0, 1, 0], np.array([1, 0, 0]))
240 assert np.allclose(der[0, 0, 1], np.array([0, 1, 0]))
241
242 # eval normal
243 n, pos = srf.normal(0, 0)
244 assert np.allclose(n, np.array([[0, 0, 1]]))
245 assert np.allclose(pos, np.array([[0, 0, 0]]))
246
247
248def test_approximate():

Callers

nothing calls this directly

Calls 7

faceMethod · 0.95
derMethod · 0.95
normalMethod · 0.95
SurfaceClass · 0.90
isValidMethod · 0.80
fromFaceMethod · 0.80
AreaMethod · 0.45

Tested by

no test coverage detected