Sketcher: Move autoremoveredundants method from SketchAnalyser to SketchObject

This commit is contained in:
Abdullah Tahiri
2018-08-18 02:47:04 +02:00
committed by wmayer
parent 96f6c46949
commit dc1bb7eb87
4 changed files with 20 additions and 22 deletions

View File

@@ -367,7 +367,7 @@ void SketchAnalysis::makeMissingPointOnPointCoincident(bool onebyone)
solvesketch(status,dofs,true);
if(status == -2) { //redundant constraints
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}
@@ -446,7 +446,7 @@ void SketchAnalysis::makeMissingVerticalHorizontal(bool onebyone)
solvesketch(status,dofs,true);
if(status == -2) { //redundant constraints
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}
@@ -641,7 +641,7 @@ void SketchAnalysis::makeMissingEquality(bool onebyone)
solvesketch(status,dofs,true);
if(status == -2) { //redundant constraints
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}
@@ -687,16 +687,6 @@ void SketchAnalysis::solvesketch(int &status, int &dofs, bool updategeo)
}
}
void SketchAnalysis::autoRemoveRedundants(bool updategeo)
{
auto redundants = sketch->getLastRedundant();
for(size_t i=0;i<redundants.size();i++) // getLastRedundant is base 1, while delConstraints is base 0
redundants[i]--;
sketch->delConstraints(redundants,updategeo);
}
int SketchAnalysis::autoconstraint(double precision, double angleprecision, bool includeconstruction)
{
App::Document* doc = sketch->getDocument();
@@ -743,7 +733,7 @@ int SketchAnalysis::autoconstraint(double precision, double angleprecision, bool
solvesketch(status,dofs,true);
if(status == -2) { // redundants
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}
@@ -765,7 +755,7 @@ int SketchAnalysis::autoconstraint(double precision, double angleprecision, bool
solvesketch(status,dofs,true);
if(status == -2) { // redundants
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}
@@ -793,7 +783,7 @@ int SketchAnalysis::autoconstraint(double precision, double angleprecision, bool
solvesketch(status,dofs,true);
if(status == -2) { // redundants
autoRemoveRedundants(false);
sketch->autoRemoveRedundants(false);
solvesketch(status,dofs,false);
}

View File

@@ -116,8 +116,6 @@ public:
/// solves the sketch and retrieves the error status, and the degrees of freedom.
/// It enables to solve updating the geometry (so moving the geometry to match the constraints) or preserving the geometry.
void solvesketch(int &status, int &dofs, bool updategeo);
/// It gets the redundant constraints from the solver and deletes them
void autoRemoveRedundants(bool updategeo);
protected:
Sketcher::SketchObject* sketch;

View File

@@ -6354,10 +6354,19 @@ void SketchObject::makeMissingEquality(bool onebyone)
analyser->makeMissingEquality(onebyone);
}
void SketchObject::autoRemoveRedundants(bool updategeo)
int SketchObject::autoRemoveRedundants(bool updategeo)
{
if(analyser)
analyser->autoRemoveRedundants(updategeo);
auto redundants = getLastRedundant();
if(redundants.size() == 0)
return 0;
for(size_t i=0;i<redundants.size();i++) // getLastRedundant is base 1, while delConstraints is base 0
redundants[i]--;
delConstraints(redundants,updategeo);
return redundants.size();
}
// Python Sketcher feature ---------------------------------------------------------

View File

@@ -387,7 +387,8 @@ public:
void makeMissingEquality(bool onebyone = true);
// helper
void autoRemoveRedundants(bool updategeo);
/// returns the number of redundant constraints detected
int autoRemoveRedundants(bool updategeo = true);
protected:
/// get called by the container when a property has changed