From: azv Date: Thu, 3 Sep 2015 08:22:33 +0000 (+0300) Subject: Do not recalculate constraints if there are invalid features (issue #874) X-Git-Tag: V_1.4.0_beta4~143 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e1b61137bd30e9e7cb076775540b27c51ee42855;p=modules%2Fshaper.git Do not recalculate constraints if there are invalid features (issue #874) --- diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 8d8b81735..9325a6e1e 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include #include #include @@ -191,6 +193,9 @@ bool SketchSolver_Group::changeConstraint( if (!theConstraint) return false; + if (!checkFeatureValidity(theConstraint)) + return false; + bool isNewConstraint = myConstraints.find(theConstraint) == myConstraints.end(); if (isNewConstraint) { // Add constraint to the current group @@ -280,6 +285,9 @@ bool SketchSolver_Group::changeConstraint( bool SketchSolver_Group::updateFeature(std::shared_ptr theFeature) { + if (!checkFeatureValidity(theFeature)) + return false; + std::set aConstraints = myFeatureStorage->getConstraints(std::dynamic_pointer_cast(theFeature)); if (aConstraints.empty()) @@ -698,3 +706,19 @@ void SketchSolver_Group::setTemporary(SolverConstraintPtr theConstraint) myTempConstraints.insert(theConstraint); } + +// ============================================================================ +// Function: checkFeatureValidity +// Class: SketchSolver_Group +// Purpose: verifies is the feature valid +// ============================================================================ +bool SketchSolver_Group::checkFeatureValidity(FeaturePtr theFeature) +{ + if (!theFeature || !theFeature->data()->isValid()) + return true; + + SessionPtr aMgr = ModelAPI_Session::get(); + ModelAPI_ValidatorsFactory* aFactory = aMgr->validators(); + return aFactory->validate(theFeature); +} + diff --git a/src/SketchSolver/SketchSolver_Group.h b/src/SketchSolver/SketchSolver_Group.h index 13f614c75..e75accd08 100644 --- a/src/SketchSolver/SketchSolver_Group.h +++ b/src/SketchSolver/SketchSolver_Group.h @@ -157,6 +157,9 @@ private: /// \brief Append given constraint to th group of temporary constraints void setTemporary(SolverConstraintPtr theConstraint); + /// \brief Verifies is the feature valid + bool checkFeatureValidity(FeaturePtr theFeature); + private: Slvs_hGroup myID; ///< Index of the group Slvs_hEntity myWorkplaneID; ///< Index of workplane, the group is based on