propagate solved variables back to shapes

This commit is contained in:
Josh Holtrop 2011-03-28 18:59:56 -04:00
parent 094e4edd9f
commit 55a96bbc3f

View File

@ -15,6 +15,7 @@ class Sketch(object):
def solve(self): def solve(self):
shape_vars = {} shape_vars = {}
varid_to_shape_var = []
varid = 0 varid = 0
equations = [] equations = []
for c in self.constraints: for c in self.constraints:
@ -26,6 +27,7 @@ class Sketch(object):
if not shape_var in shape_vars: if not shape_var in shape_vars:
shape_vars[shape_var] = varid shape_vars[shape_var] = varid
varid += 1 varid += 1
varid_to_shape_var.append(shape_var)
C = empty((len(equations), len(shape_vars))) C = empty((len(equations), len(shape_vars)))
d = empty(len(equations)) d = empty(len(equations))
for i in range(len(equations)): for i in range(len(equations)):
@ -37,3 +39,6 @@ class Sketch(object):
d[i] = e[1] d[i] = e[1]
s = SLE(C, d) s = SLE(C, d)
r = s.solve() r = s.solve()
solved_vars = r.xf
for i in range(len(solved_vars)):
varid_to_shape_var[i].setVar(solved_vars[i])