Sketcher, Issue #0000691: detect redundant constraints and skip them if necessary

This commit is contained in:
logari81
2012-05-14 11:28:05 +02:00
parent 63b2b239b1
commit ce5d9a332a
8 changed files with 386 additions and 201 deletions

View File

@@ -108,6 +108,11 @@ App::DocumentObjectExecReturn *SketchObject::execute(void)
appendConflictMsg(sketch.getConflicting(), msg);
return new App::DocumentObjectExecReturn(msg.c_str(),this);
}
if (sketch.hasRedundancies()) { // redundant constraints
std::string msg="Sketch with redundant constraints\n";
appendRedundantMsg(sketch.getRedundant(), msg);
return new App::DocumentObjectExecReturn(msg.c_str(),this);
}
// solve the sketch
if (sketch.solve() != 0)
@@ -1396,6 +1401,20 @@ void SketchObject::appendConflictMsg(const std::vector<int> &conflicting, std::s
msg = ss.str();
}
void SketchObject::appendRedundantMsg(const std::vector<int> &redundant, std::string &msg)
{
std::stringstream ss;
if (msg.length() > 0)
ss << msg;
if (redundant.size() > 0) {
ss << "The following constraints were identified as redundant and should be removed:\n" << redundant[0];
for (unsigned int i=1; i < redundant.size(); i++)
ss << ", " << redundant[i];
ss << "\n";
}
msg = ss.str();
}
PyObject *SketchObject::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {