| 211 | |
| 212 | |
| 213 | def 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 | |
| 248 | def test_approximate(): |