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

Method testParametricCurve

tests/test_cadquery.py:3959–3987  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

3957 self.assertLessEqual(rt_bb.ymax, 0)
3958
3959 def testParametricCurve(self):
3960
3961 from math import sin, cos, pi
3962
3963 k = 4
3964 r = 1
3965
3966 func = lambda t: (
3967 r * (k + 1) * cos(t) - r * cos((k + 1) * t),
3968 r * (k + 1) * sin(t) - r * sin((k + 1) * t),
3969 )
3970
3971 res_open = Workplane("XY").parametricCurve(func).extrude(3)
3972
3973 # open profile generates an invalid solid
3974 self.assertFalse(res_open.solids().val().isValid())
3975
3976 res_closed = (
3977 Workplane("XY").parametricCurve(func, start=0, stop=2 * pi).extrude(3)
3978 )
3979
3980 # closed profile will generate a valid solid with 3 faces
3981 self.assertTrue(res_closed.solids().val().isValid())
3982 self.assertEqual(len(res_closed.faces().vals()), 3)
3983
3984 res_edge = Workplane("XY").parametricCurve(func, makeWire=False)
3985
3986 self.assertEqual(len(res_edge.ctx.pendingEdges), 1)
3987 self.assertEqual(len(res_edge.ctx.pendingWires), 0)
3988
3989 def testMakeShellSolid(self):
3990

Callers

nothing calls this directly

Calls 8

WorkplaneClass · 0.85
extrudeMethod · 0.80
parametricCurveMethod · 0.80
isValidMethod · 0.80
valMethod · 0.45
solidsMethod · 0.45
valsMethod · 0.45
facesMethod · 0.45

Tested by

no test coverage detected