X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Solver.cpp;h=975588bbb18084947a2bbcdeb457c1f68864f614;hb=cdd9efd8fbc75f120188ae16eed7471dc6492ac3;hp=40c76d1a772b5a863d13af4c711a1fe65ee8f6a3;hpb=fd6e8847c7c7e43594a91c68ec9153bc8067c8ac;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Solver.cpp b/src/SketchSolver/SketchSolver_Solver.cpp index 40c76d1a7..975588bbb 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() { @@ -29,21 +30,21 @@ SketchSolver_Solver::SketchSolver_Solver() SketchSolver_Solver::~SketchSolver_Solver() { if (myEquationsSystem.param) - delete [] myEquationsSystem.param; + delete[] myEquationsSystem.param; if (myEquationsSystem.entity) - delete [] myEquationsSystem.entity; + delete[] myEquationsSystem.entity; if (myEquationsSystem.constraint) - delete [] myEquationsSystem.constraint; + delete[] myEquationsSystem.constraint; if (myEquationsSystem.failed) - delete [] myEquationsSystem.failed; + delete[] myEquationsSystem.failed; } void SketchSolver_Solver::setParameters(const std::vector& theParameters) { - if (theParameters.size() != myEquationsSystem.params) // number of parameters was changed => reallocate the memory - { + if (theParameters.size() != myEquationsSystem.params) // number of parameters was changed => reallocate the memory + { if (myEquationsSystem.param) - delete [] myEquationsSystem.param; + delete[] myEquationsSystem.param; myEquationsSystem.params = theParameters.size(); myEquationsSystem.param = new Slvs_Param[theParameters.size()]; } @@ -56,8 +57,7 @@ void SketchSolver_Solver::setParameters(const std::vector& theParame void SketchSolver_Solver::setDraggedParameters(const std::vector& theDragged) { - if (theDragged.size() == 0) - { + if (theDragged.size() == 0) { myEquationsSystem.dragged[0] = 0; myEquationsSystem.dragged[1] = 0; myEquationsSystem.dragged[2] = 0; @@ -70,10 +70,10 @@ void SketchSolver_Solver::setDraggedParameters(const std::vector& t void SketchSolver_Solver::setEntities(const std::vector& theEntities) { - if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory - { + if (theEntities.size() != myEquationsSystem.entities) // number of entities was changed => reallocate the memory + { if (myEquationsSystem.entity) - delete [] myEquationsSystem.entity; + delete[] myEquationsSystem.entity; myEquationsSystem.entities = theEntities.size(); myEquationsSystem.entity = new Slvs_Entity[theEntities.size()]; } @@ -86,16 +86,16 @@ void SketchSolver_Solver::setEntities(const std::vector& theEntitie void SketchSolver_Solver::setConstraints(const std::vector& theConstraints) { - if (theConstraints.size() != myEquationsSystem.constraints) // number of constraints was changed => reallocate the memory - { + if (theConstraints.size() != myEquationsSystem.constraints) // number of constraints was changed => reallocate the memory + { if (myEquationsSystem.constraint) - delete [] myEquationsSystem.constraint; + 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; + delete[] myEquationsSystem.failed; myEquationsSystem.failed = new Slvs_hConstraint[theConstraints.size()]; myEquationsSystem.faileds = theConstraints.size(); } @@ -111,7 +111,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; } @@ -122,13 +124,12 @@ bool SketchSolver_Solver::getResult(std::vector& theParameters) return false; if (theParameters.size() != myEquationsSystem.params) - return false; // number of parameters is not the same + return false; // number of parameters is not the same std::vector::iterator aParamIter = theParameters.begin(); - for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) - { + for (int i = 0; i < myEquationsSystem.params; i++, aParamIter++) { if (myEquationsSystem.param[i].h != aParamIter->h) - return false; // sequence of parameters was changed + return false; // sequence of parameters was changed aParamIter->val = myEquationsSystem.param[i].val; }