From: azv Date: Wed, 23 Dec 2015 11:24:35 +0000 (+0300) Subject: Update conditions to add arc into solver (issue #1165) X-Git-Tag: V_2.1.0~96 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=22809d3cb3ae0420c24a6d8282ff2080c714d97d;p=modules%2Fshaper.git Update conditions to add arc into solver (issue #1165) --- diff --git a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp index 4fa74d07e..0d12d6d47 100644 --- a/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp +++ b/src/SketchSolver/PlaneGCSSolver/PlaneGCSSolver_Storage.cpp @@ -968,6 +968,11 @@ void PlaneGCSSolver_Storage::initializeSolver(SolverPtr theSolver) { std::shared_ptr aSolver = std::dynamic_pointer_cast(theSolver); + if (!aSolver) + return; + + if (myExistArc) + processArcs(); // initialize constraints std::map >::const_iterator diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 798935ecf..fed8d3e82 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -184,8 +184,10 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) { -//// myFeatureMap[aFeature] = EntityWrapperPtr(); return SketchSolver_Storage::update(aFeature); + } else { + myFeatureMap[aFeature] = EntityWrapperPtr(); + myExistArc = true; } } } @@ -574,6 +576,22 @@ void SketchSolver_Storage::setSketch(const EntityWrapperPtr& theSketch) addEntity(FeaturePtr(), theSketch); } +void SketchSolver_Storage::processArcs() +{ + myExistArc = false; + std::map::iterator aFIt = myFeatureMap.begin(); + for (; aFIt != myFeatureMap.end(); ++aFIt) + if (!aFIt->second && aFIt->first->getKind() == SketchPlugin_Arc::ID()) { + // Additional checking the attributes are initialized + if (aFIt->first->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && + aFIt->first->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && + aFIt->first->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) + update(aFIt->first); + else + myExistArc = true; + } +} + void SketchSolver_Storage::blockEvents(bool isBlocked) { if (isBlocked == myEventsBlocked) diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index a35a7366b..138c8994f 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -37,7 +37,8 @@ public: SketchSolver_Storage(const GroupID& theGroup) : myGroupID(theGroup), myNeedToResolve(false), - myEventsBlocked(false) + myEventsBlocked(false), + myExistArc(false) {} /// \brief Change mapping between constraint from SketchPlugin and @@ -200,6 +201,9 @@ protected: /// \brief Verify the attribute is used by constraint SKETCHSOLVER_EXPORT bool isUsed(AttributePtr theAttirubute) const; + /// \brief Find arcs without corresponding entity applicable for the solver and build them + SKETCHSOLVER_EXPORT void processArcs(); + private: /// \brief Find the normal of the sketch EntityWrapperPtr getNormal() const; @@ -208,6 +212,7 @@ protected: GroupID myGroupID; ///< identifier of the group, this storage belongs to bool myNeedToResolve; ///< parameters are changed and group needs to be resolved bool myEventsBlocked; ///< indicates that features do not send events + bool myExistArc; ///< the storage has any point of arc but not full arc, need to add it /// map SketchPlugin constraint to a list of solver's constraints std::map > myConstraintMap; diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index 61ceb9304..8cdc22040 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -1134,6 +1134,9 @@ void SolveSpaceSolver_Storage::initializeSolver(SolverPtr theSolver) if (!aSolver) return; + if (myExistArc) + processArcs(); + if (myConstraints.empty()) { // Adjust all arc to place their points correctly std::vector::const_iterator anEntIt = myEntities.begin();