chiark
/
gitweb
/
~ian
/
moebius3.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
curveopt: fix handling of empty lines from findcurve
[moebius3.git]
/
curveopt.py
diff --git
a/curveopt.py
b/curveopt.py
index e07e7250626349cd37838000d81881ba3ff90460..00019762d8f20a01b1c5b93378fa544c8641c16f 100644
(file)
--- a/
curveopt.py
+++ b/
curveopt.py
@@
-18,11
+18,20
@@
from math import atan2, atan, sqrt
import symbolic
class OptimisedCurve():
import symbolic
class OptimisedCurve():
+ counter = 0
+
+ def _dbg(oc, s):
+ dbg('OC#%04d %s' % (oc._counter, s))
+
def __init__(oc, cp, nt):
def __init__(oc, cp, nt):
+ oc._counter = 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))
db = DiscreteBezier(cp, nt, bezier_constructor=BezierSegment)
fc_input = map(db.point_at_it, range(0, nt+1))
- dbg(repr(fc_input))
+
oc._
dbg(repr(fc_input))
for end in (False,True):
ei = nt if end else 0
for end in (False,True):
ei = nt if end else 0
@@
-33,16
+42,16
@@
class OptimisedCurve():
ef_dirn = unit_v(cp[cp1i] - cp[cp0i])
ef_len = np.linalg.norm(np.array(fc_input[fi]) - np.array(fc_input[ei]))
f = e + ef_dirn * ef_len
ef_dirn = unit_v(cp[cp1i] - cp[cp0i])
ef_len = np.linalg.norm(np.array(fc_input[fi]) - np.array(fc_input[ei]))
f = e + ef_dirn * ef_len
- dbg(repr((end, e,f, ef_dirn, ef_len)))
+
oc._
dbg(repr((end, e,f, ef_dirn, ef_len)))
fc_input[ei] = e
fc_input[fi] = f
fc_input[ei] = e
fc_input[fi] = f
- dbg(repr(fc_input))
+
oc._
dbg(repr(fc_input))
findcurve_epsilon = 0.01
cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
findcurve_epsilon = 0.01
cl = ['./findcurve', '%d' % (nt+1), '%.18g' % findcurve_epsilon]
- dbg('STARTING FINDCURVE %s' % cl)
+
oc._
dbg('STARTING FINDCURVE %s' % cl)
subproc = subprocess.Popen(
cl,
bufsize=1,
subproc = subprocess.Popen(
cl,
bufsize=1,
@@
-54,12
+63,12
@@
class OptimisedCurve():
universal_newlines=True,
)
universal_newlines=True,
)
- dbg('RUNNING FINDCURVE')
+
oc._
dbg('RUNNING FINDCURVE')
fc_input = np.hstack(fc_input)
s = ' '.join(map(str, fc_input))
fc_input = np.hstack(fc_input)
s = ' '.join(map(str, fc_input))
- dbg(('>> %s' % s))
+
oc._
dbg(('>> %s' % s))
print(s, file=subproc.stdin)
subproc.stdin.flush()
print(s, file=subproc.stdin)
subproc.stdin.flush()
@@
-71,14
+80,16
@@
class OptimisedCurve():
subproc = oc.subproc
if subproc is None: return
subproc = oc.subproc
if subproc is None: return
- dbg('(awaiting)')
+
oc._
dbg('(awaiting)')
commentary = ''
while True:
l = subproc.stdout.readline()
commentary = ''
while True:
l = subproc.stdout.readline()
+ if not l:
+ oc._dbg('findcurve EOF')
+ vdbg().crashing('findcurve EOF')
l = l.rstrip()
l = l.rstrip()
- dbg('<< ', l)
- if not l: vdbg().crashing('findcurve EOF')
+ oc._dbg('<< ' + l)
if not l.startswith('['):
commentary += ' '
commentary += l
if not l.startswith('['):
commentary += ' '
commentary += l
@@
-87,7
+98,7
@@
class OptimisedCurve():
l = eval(l)
if not l: break
l = eval(l)
if not l: break
- dbg('[%s] %s' % (l, commentary))
+
oc._
dbg('[%s] %s' % (l, commentary))
commentary = ''
findcurve_result = l
commentary = ''
findcurve_result = l
@@
-98,13
+109,13
@@
class OptimisedCurve():
oc.subproc = None
oc._result = np.reshape(findcurve_result, (-1,3), 'C')
oc.subproc = None
oc._result = np.reshape(findcurve_result, (-1,3), 'C')
- dbg(repr(oc._result))
+
oc._
dbg(repr(oc._result))
- vdbg().curve( oc.point_at_t )
+
#
vdbg().curve( oc.point_at_t )
def point_at_it(oc, it):
oc._await_subproc()
def point_at_it(oc, it):
oc._await_subproc()
- dbg(repr((it,)))
+
oc._
dbg(repr((it,)))
return oc._result[it]
def point_at_t(oc, t):
return oc._result[it]
def point_at_t(oc, t):