Bug fix: General reduction solution / new sketch solving model
================================================================= The new solving architecture focus all the solving on the SketchObject. Actions that change the DoF can call execute() (i.e. recompute) or Solve() depending on whether a full recompute of dependent features is required or not. In both calls the geometry of the solver is updated with the geometry of the SketchObject. The only additional call that calls the solver is MovePoint. This function may or may not update the geometry of the SketchObject (as now it is intended for UI related solving, like dragging, rubberbands, ...). In operations that do not involve a change of DoF and therefore do not require a sketch solving, it may happen that as a side effect of moving a point, the geometry changes to old behaviour. In order to avoid that, those SketchObject operations, as for example setConstruction or ToggleConstruction, must set a flag "bool solverNeedsUpdate" to true. In case a movePoint is executed before any other solver execution, the geometry is first updated and then the moving is performed. So to keep in mind when programming sketcher operations: -> Need recompute (UpdateActive) -> Need solving because DoF changed (solve()) -> The operation does not change DoF (set solverNeedsUpdate to true)
This commit is contained in:
@@ -89,6 +89,8 @@ SketchObject::SketchObject()
|
||||
lastSolverStatus=0;
|
||||
lastSolveTime=0;
|
||||
|
||||
solverNeedsUpdate=false;
|
||||
|
||||
noRecomputes=false;
|
||||
}
|
||||
|
||||
@@ -127,7 +129,9 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
|
||||
lastHasConflict = solvedSketch.hasConflicts();
|
||||
lastHasRedundancies = solvedSketch.hasRedundancies();
|
||||
lastConflicting=solvedSketch.getConflicting();
|
||||
lastRedundant=solvedSketch.getRedundant();
|
||||
lastRedundant=solvedSketch.getRedundant();
|
||||
|
||||
solverNeedsUpdate=false;
|
||||
|
||||
if (lastDoF < 0) { // over-constrained sketch
|
||||
std::string msg="Over-constrained sketch\n";
|
||||
@@ -195,6 +199,8 @@ int SketchObject::solve()
|
||||
lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
getExternalGeometryCount());
|
||||
|
||||
solverNeedsUpdate=false;
|
||||
|
||||
lastHasConflict = solvedSketch.hasConflicts();
|
||||
|
||||
int err=0;
|
||||
@@ -362,14 +368,16 @@ int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toP
|
||||
// of SketchObject upon moving. => use updateGeometry parameter = true then
|
||||
|
||||
|
||||
if(updateGeometry) {
|
||||
if(updateGeometry || solverNeedsUpdate) {
|
||||
lastDoF = solvedSketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
getExternalGeometryCount());
|
||||
|
||||
lastHasConflict = solvedSketch.hasConflicts();
|
||||
lastHasRedundancies = solvedSketch.hasRedundancies();
|
||||
lastConflicting=solvedSketch.getConflicting();
|
||||
lastRedundant=solvedSketch.getRedundant();
|
||||
lastRedundant=solvedSketch.getRedundant();
|
||||
|
||||
solverNeedsUpdate=false;
|
||||
}
|
||||
|
||||
if (lastDoF < 0) // over-constrained sketch
|
||||
@@ -583,6 +591,7 @@ int SketchObject::toggleConstruction(int GeoId)
|
||||
|
||||
this->Geometry.setValues(newVals);
|
||||
//this->Constraints.acceptGeometry(getCompleteGeometry()); <= This is not necessary for a toggle. Reducing redundant solving. Abdullah
|
||||
solverNeedsUpdate=true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -600,6 +609,7 @@ int SketchObject::setConstruction(int GeoId, bool on)
|
||||
|
||||
this->Geometry.setValues(newVals);
|
||||
//this->Constraints.acceptGeometry(getCompleteGeometry()); <= This is not necessary for a toggle. Reducing redundant solving. Abdullah
|
||||
solverNeedsUpdate=true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user