| 166 | |
| 167 | |
| 168 | def test_curve(): |
| 169 | |
| 170 | knots = np.array([0, 0, 0, 0, 1, 1, 1, 1]) |
| 171 | pts = np.array([[0, 0, 0], [0, 0, 1], [0, 1, 2], [0, 2, 0]]) |
| 172 | |
| 173 | crv = Curve(pts, knots, 3, False) |
| 174 | |
| 175 | # sanity check |
| 176 | assert not crv.curve().IsPeriodic() |
| 177 | |
| 178 | # convert to an edge |
| 179 | e = crv.edge() |
| 180 | |
| 181 | assert e.isValid() |
| 182 | assert e.ShapeType() == "Edge" |
| 183 | |
| 184 | # edge to curve |
| 185 | crv2 = Curve.fromEdge(e) |
| 186 | e2 = crv2.edge() |
| 187 | |
| 188 | assert e2.isValid() |
| 189 | |
| 190 | # check roundtrip |
| 191 | crv3 = Curve.fromEdge(e2) |
| 192 | |
| 193 | assert np.allclose(crv2.knots, crv3.knots) |
| 194 | assert np.allclose(crv2.pts, crv3.pts) |
| 195 | |
| 196 | # eval |
| 197 | pt = crv(0) |
| 198 | assert np.allclose(pt, pts[0]) |
| 199 | |
| 200 | # eval der |
| 201 | der = crv.der(0, 1) |
| 202 | |
| 203 | ga = e._geomAdaptor() |
| 204 | |
| 205 | tmp = gp_Pnt() |
| 206 | res = gp_Vec() |
| 207 | |
| 208 | ga.D1(0, tmp, res) |
| 209 | |
| 210 | assert np.allclose(der[0, 1], np.array(Vector(res).toTuple())) |
| 211 | |
| 212 | |
| 213 | def test_surface(): |