Use prepare-solve idiom

This commit is contained in:
Val Erastov 2015-08-13 22:03:05 -07:00
parent f9cc184d15
commit 1ac5417ae9
3 changed files with 6 additions and 7 deletions

View file

@ -876,7 +876,11 @@ TCAD.TWO.DragTool.prototype.mousewheel = function(e) {
};
TCAD.TWO.DragTool.prototype.solveRequest = function(rough) {
this.solver.solve(rough, 1);
this.solver.sync();
};
TCAD.TWO.DragTool.prototype.prepareSolver = function() {
var locked;
if (this.obj._class === 'TCAD.TWO.EndPoint') {
locked = [this.obj._x, this.obj._y];
@ -892,10 +896,4 @@ TCAD.TWO.DragTool.prototype.solveRequest = function(rough) {
locked = [];
}
this.solver = this.viewer.parametricManager.prepare(locked);
this.solver.solve(rough, 1);
this.solver.sync();
};
TCAD.TWO.DragTool.prototype.prepareSolver = function() {
};

View file

@ -70,6 +70,7 @@ TCAD.constraints.Weighted = function(constr, weight) {
this.weight = weight;
this.params = constr.params;
this.constr = constr;
this.error = function() {
return constr.error() * this.weight;

View file

@ -272,7 +272,7 @@ TCAD.parametric.prepare = function(constrs, locked, aux, alg) {
solveSystem : solve,
updateLock : function(values) {
for (var i = 0; i < values.length; ++i) {
lockingConstrs[i].value = values[i];
lockingConstrs[i].constr.value = values[i];
}
}
};