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

Function test_curve

tests/test_nurbs.py:168–210  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

166
167
168def 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
213def test_surface():

Callers

nothing calls this directly

Calls 11

curveMethod · 0.95
edgeMethod · 0.95
derMethod · 0.95
CurveClass · 0.90
VectorClass · 0.90
isValidMethod · 0.80
fromEdgeMethod · 0.80
ShapeTypeMethod · 0.45
edgeMethod · 0.45
_geomAdaptorMethod · 0.45
toTupleMethod · 0.45

Tested by

no test coverage detected