// Author: Artem ZHIDKOV
#include "SketchSolver_Solver.h"
+#include <Events_LongOp.h>
SketchSolver_Solver::SketchSolver_Solver()
{
myEquationsSystem.failed = 0;
myEquationsSystem.faileds = 0;
+ myEquationsSystem.dragged[0] = 0;
+ myEquationsSystem.dragged[1] = 0;
+ myEquationsSystem.dragged[2] = 0;
+ myEquationsSystem.dragged[3] = 0;
+
// If the set of constraints is inconsistent,
// the failed field will contain wrong constraints
myEquationsSystem.calculateFaileds = 1;
myEquationsSystem.param[i] = *aParamIter;
}
+void SketchSolver_Solver::setDraggedParameters(const std::vector<Slvs_hParam>& theDragged)
+{
+ if (theDragged.size() == 0)
+ {
+ myEquationsSystem.dragged[0] = 0;
+ myEquationsSystem.dragged[1] = 0;
+ myEquationsSystem.dragged[2] = 0;
+ myEquationsSystem.dragged[3] = 0;
+ return;
+ }
+ for (unsigned int i = 0; i < theDragged.size(); i++)
+ myEquationsSystem.dragged[i] = theDragged[i];
+}
+
void SketchSolver_Solver::setEntities(const std::vector<Slvs_Entity>& theEntities)
{
if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory
delete [] myEquationsSystem.constraint;
myEquationsSystem.constraints = theConstraints.size();
myEquationsSystem.constraint = new Slvs_Constraint[theConstraints.size()];
+
+ // Assign the memory for the failed constraints
+ if (myEquationsSystem.failed)
+ delete [] myEquationsSystem.failed;
+ myEquationsSystem.failed = new Slvs_hConstraint[theConstraints.size()];
+ myEquationsSystem.faileds = theConstraints.size();
}
// Copy data
if (myEquationsSystem.constraints <= 0)
return SLVS_RESULT_EMPTY_SET;
+ Events_LongOp::start(this);
Slvs_Solve(&myEquationsSystem, myGroupID);
+ Events_LongOp::end(this);
return myEquationsSystem.result;
}