import symbolic
-findcurve_subprocs = { }
-
class OptimisedCurve():
def __init__(oc, cp, nt):
db = DiscreteBezier(cp, nt, bezier_constructor=BezierSegment)
findcurve_epsilon = 0.01
- try:
- subproc = findcurve_subprocs[nt]
- except KeyError:
- cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
- dbg('STARTING FINDCURVE %s' % cl)
- subproc = subprocess.Popen(
- cl,
- bufsize=1,
- stdin=subprocess.PIPE,
- stdout=subprocess.PIPE,
- stderr=None,
- close_fds=False,
- # restore_signals=True, // want python2 compat, nnng
- universal_newlines=True,
- )
- findcurve_subprocs[nt] = subproc
+ cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
+ dbg('STARTING FINDCURVE %s' % cl)
+ subproc = subprocess.Popen(
+ cl,
+ bufsize=1,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=None,
+ close_fds=False,
+ # restore_signals=True, // want python2 compat, nnng
+ universal_newlines=True,
+ )
dbg('RUNNING FINDCURVE')
findcurve_result = l
+ subproc.stdin.close()
+ subproc.wait()
+ assert(subproc.returncode == 0)
+
oc.nt = nt
oc._result = np.reshape(findcurve_result, (-1,3), 'C')
dbg(repr(oc._result))