X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Solver.cpp;h=b91d267f61b4625b1402b314787a0253a0850d66;hb=ce77e62550c698202229cb42f5e3486bed235668;hp=f9ed8c37204c788a6de8c685faac995fe3b30af9;hpb=a398103d11950df8cb50eeea49942237eb16edcf;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index f9ed8c372..b91d267f6 100644 --- a/src/SketchSolver/SketchSolver_Solver.cpp +++ b/src/SketchSolver/SketchSolver_Solver.cpp @@ -3,6 +3,7 @@ // Author: Artem ZHIDKOV #include "SketchSolver_Solver.h" +#include SketchSolver_Solver::SketchSolver_Solver() { @@ -16,6 +17,11 @@ 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; @@ -49,6 +55,20 @@ void SketchSolver_Solver::setParameters(const std::vector& theParame myEquationsSystem.param[i] = *aParamIter; } +void SketchSolver_Solver::setDraggedParameters(const std::vector& 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& theEntities) { if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory @@ -73,6 +93,12 @@ void SketchSolver_Solver::setConstraints(const std::vector& the 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 @@ -86,7 +112,9 @@ int SketchSolver_Solver::solve() if (myEquationsSystem.constraints <= 0) return SLVS_RESULT_EMPTY_SET; + Events_LongOp::start(this); Slvs_Solve(&myEquationsSystem, myGroupID); + Events_LongOp::end(this); return myEquationsSystem.result; }