chiark / gitweb /
fix python incompatibilities
[moebius3.git] / curveopt.py
index ab27e4458cc98e5fa41b4314229c58e0e07b99a2..234b2750417512bf3c0821b3523f2dd39d2ed5e3 100644 (file)
@@ -12,6 +12,7 @@ import math
 from moedebug import *
 from moenp import *
 from moebez import *
+from schequeue import ScheduledTask
 
 from math import atan2, atan, sqrt
 
@@ -21,16 +22,17 @@ class OptimisedCurve():
   counter = 0
 
   def _dbg(oc, s):
-    dbg('OC#%04d %s' % (oc._counter, s))
+    dbg('%s %s' % (oc._desc, s))
 
   def __init__(oc, cp, nt):
-    oc._counter = OptimisedCurve.counter
+    oc._desc = 'OC#%04d' % OptimisedCurve.counter
     OptimisedCurve.counter += 1
+
     oc._dbg('cp= ' + ' '.join(map(vec2dbg, cp)))
 
     db = DiscreteBezier(cp, nt, bezier_constructor=BezierSegment)
 
-    fc_input = map(db.point_at_it, range(0, nt+1))
+    fc_input = [ x for x in map(db.point_at_it, range(0, nt+1)) ]
     oc._dbg(repr(fc_input))
 
     for end in (False,True):
@@ -48,7 +50,10 @@ class OptimisedCurve():
 
     oc._dbg(repr(fc_input))
 
-    findcurve_epsilon = 0.0001
+    findcurve_epsilon = 0.01
+
+    oc.sched = ScheduledTask(oc._await_subproc, oc._desc)
+    oc.sched.pre_spawn()
 
     cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
     oc._dbg('STARTING FINDCURVE %s' % cl)
@@ -76,6 +81,7 @@ class OptimisedCurve():
     oc.subproc = subproc
     oc.nt = nt
 
+    oc.sched.post_spawn()
     #oc._await_subproc()
 
   def _await_subproc(oc):
@@ -110,6 +116,8 @@ class OptimisedCurve():
     assert(subproc.returncode == 0)
     oc.subproc = None
 
+    oc.sched.post_reap()
+
     oc._result = np.reshape(findcurve_result, (-1,3), 'C')
     oc._dbg(repr(oc._result))