Sketcher: avoid duplicate code and unnecessary arguments
This commit is contained in:
@@ -96,8 +96,9 @@ void Sketch::clear(void)
|
||||
Conflicting.clear();
|
||||
}
|
||||
|
||||
int Sketch::setUpSketch(const std::vector<Part::Geometry *> &GeoList, const std::vector<Constraint *> &ConstraintList,
|
||||
bool withDiagnose, int extGeoCount)
|
||||
int Sketch::setUpSketch(const std::vector<Part::Geometry *> &GeoList,
|
||||
const std::vector<Constraint *> &ConstraintList,
|
||||
int extGeoCount)
|
||||
{
|
||||
clear();
|
||||
|
||||
@@ -121,11 +122,7 @@ int Sketch::setUpSketch(const std::vector<Part::Geometry *> &GeoList, const std:
|
||||
GCSsys.clearByTag(-1);
|
||||
GCSsys.clearByTag(-2);
|
||||
GCSsys.initSolution(Parameters);
|
||||
|
||||
if (withDiagnose)
|
||||
return diagnose();
|
||||
else
|
||||
return 0;
|
||||
return diagnose();
|
||||
}
|
||||
|
||||
const char* nameByType(Sketch::GeoType type)
|
||||
@@ -1606,7 +1603,7 @@ int Sketch::solve(void)
|
||||
break;
|
||||
}
|
||||
|
||||
// if successfully solved try write the parameters back
|
||||
// if successfully solved try to write the parameters back
|
||||
if (ret == GCS::Success) {
|
||||
GCSsys.applySolution();
|
||||
valid_solution = updateGeometry();
|
||||
|
||||
@@ -53,9 +53,21 @@ public:
|
||||
int solve(void);
|
||||
/// delete all geometry and constraints, leave an empty sketch
|
||||
void clear(void);
|
||||
/// set the sketch up with geoms and constraints
|
||||
/** set the sketch up with geoms and constraints
|
||||
*
|
||||
* returns the degree of freedom of a sketch and calculates a list of
|
||||
* conflicting constraints
|
||||
*
|
||||
* 0 degrees of freedom correspond to a fully constrained sketch
|
||||
* -1 degrees of freedom correspond to an over-constrained sketch
|
||||
* positive degrees of freedom correspond to an under-constrained sketch
|
||||
*
|
||||
* an over-constrained sketch will always contain conflicting constraints
|
||||
* a fully constrained or under-constrained sketch may contain conflicting
|
||||
* constraints or may not
|
||||
*/
|
||||
int setUpSketch(const std::vector<Part::Geometry *> &GeoList, const std::vector<Constraint *> &ConstraintList,
|
||||
bool withDiagnose=true, int extGeoCount=0);
|
||||
int extGeoCount=0);
|
||||
/// return the actual geometry of the sketch a TopoShape
|
||||
Part::TopoShape toShape(void) const;
|
||||
/// add unspecified geometry
|
||||
|
||||
@@ -97,7 +97,7 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
|
||||
rebuildExternalGeometry();
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
getExternalGeometryCount());
|
||||
if (dofs < 0) { // over-constrained sketch
|
||||
std::string msg="Over-constrained sketch\n";
|
||||
appendConflictMsg(sketch.getConflicting(), msg);
|
||||
@@ -128,7 +128,7 @@ int SketchObject::hasConflicts(void) const
|
||||
// set up a sketch (including dofs counting and diagnosing of conflicts)
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
getExternalGeometryCount());
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
return -2;
|
||||
if (sketch.hasConflicts()) // conflicting constraints
|
||||
@@ -166,7 +166,7 @@ int SketchObject::setDatum(int ConstrId, double Datum)
|
||||
// set up a sketch (including dofs counting and diagnosing of conflicts)
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
getExternalGeometryCount());
|
||||
int err=0;
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
err = -3;
|
||||
@@ -192,7 +192,7 @@ int SketchObject::movePoint(int GeoId, PointPos PosId, const Base::Vector3d& toP
|
||||
{
|
||||
Sketch sketch;
|
||||
int dofs = sketch.setUpSketch(getCompleteGeometry(), Constraints.getValues(),
|
||||
true, getExternalGeometryCount());
|
||||
getExternalGeometryCount());
|
||||
if (dofs < 0) // over-constrained sketch
|
||||
return -1;
|
||||
if (sketch.hasConflicts()) // conflicting constraints
|
||||
|
||||
Reference in New Issue
Block a user