From 35f780e05b0abb99b7ae43c5bbbbe438d7a273a2 Mon Sep 17 00:00:00 2001 From: azv Date: Fri, 18 Dec 2015 08:16:30 +0300 Subject: [PATCH] Update for correct movement of sketch elements, when the sketch contains arcs and coincidences. --- src/SketchSolver/SketchSolver_Storage.cpp | 4 ++-- .../SolveSpaceSolver/SolveSpaceSolver_Solver.cpp | 4 ++-- .../SolveSpaceSolver/SolveSpaceSolver_Storage.cpp | 12 ++++++++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index af6b022be..8db3eaa5c 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -50,7 +50,7 @@ void SketchSolver_Storage::addEntity(FeaturePtr theFeature, EntityWrapperPtr theSolverEntity) { std::map::const_iterator aFound = myFeatureMap.find(theFeature); - if (aFound == myFeatureMap.end() || !aFound->second->isEqual(theSolverEntity)) + if (aFound == myFeatureMap.end() || !aFound->second || !aFound->second->isEqual(theSolverEntity)) setNeedToResolve(true); // the entity is new or modified myFeatureMap[theFeature] = theSolverEntity; @@ -60,7 +60,7 @@ void SketchSolver_Storage::addEntity(AttributePtr theAttribute, EntityWrapperPtr theSolverEntity) { std::map::const_iterator aFound = myAttributeMap.find(theAttribute); - if (aFound == myAttributeMap.end() || !aFound->second->isEqual(theSolverEntity)) + if (aFound == myAttributeMap.end() || !aFound->second || !aFound->second->isEqual(theSolverEntity)) setNeedToResolve(true); // the entity is new or modified myAttributeMap[theAttribute] = theSolverEntity; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp index de1cc3edd..a46a7c0b3 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Solver.cpp @@ -82,8 +82,8 @@ void SolveSpaceSolver_Solver::setConstraints(Slvs_Constraint* theConstraints, in SketchSolver_SolveStatus SolveSpaceSolver_Solver::solve() { - if (myEquationsSystem.constraints <= 0) - return STATUS_EMPTYSET; + //if (myEquationsSystem.constraints <= 0) + // return STATUS_EMPTYSET; myEquationsSystem.calculateFaileds = myFindFaileds ? 1 : 0; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index c8113afb8..5fe40328e 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -19,6 +19,7 @@ #include #include #include +#include /** \brief Search the entity/parameter with specified ID in the list of elements * \param[in] theEntityID unique ID of the element @@ -174,7 +175,18 @@ bool SolveSpaceSolver_Storage::update(EntityWrapperPtr& theEntity) if (anEntity->type() == ENTITY_SKETCH) storeWorkplane(anEntity); + + // For the correct work with arcs we will add them if their parameter is added + if (theEntity->baseAttribute()) { + FeaturePtr aFeature = ModelAPI_Feature::feature(theEntity->baseAttribute()->owner()); + if (aFeature->getKind() == SketchPlugin_Arc::ID() && + myFeatureMap.find(aFeature) == myFeatureMap.end()) { + myFeatureMap[aFeature] = EntityWrapperPtr(); + return SketchSolver_Storage::update(aFeature, myGroupID); + } + } } + return isUpdated; } -- 2.39.2