From: azv Date: Fri, 17 Apr 2015 09:28:58 +0000 (+0300) Subject: Issue #463: Improve movement of fillet X-Git-Tag: V_1.1.0~13^2~1^2~1^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=85bdf082b2a1bdbd499b0c1cb2f2fab8ea4c3547;p=modules%2Fshaper.git Issue #463: Improve movement of fillet --- diff --git a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp index 4f1b07f8f..721913b19 100644 --- a/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintCoincidence.cpp @@ -68,10 +68,16 @@ void SketchSolver_ConstraintCoincidence::attach( Slvs_hConstraint SketchSolver_ConstraintCoincidence::addConstraint( Slvs_hEntity thePoint1, Slvs_hEntity thePoint2) { + bool hasDuplicated = myStorage->hasDuplicatedConstraint(); Slvs_Constraint aNewConstraint = Slvs_MakeConstraint(SLVS_E_UNKNOWN, myGroup->getId(), SLVS_C_POINTS_COINCIDENT, myGroup->getWorkplaneId(), 0.0, thePoint1, thePoint2, SLVS_E_UNKNOWN, SLVS_E_UNKNOWN); Slvs_hConstraint aNewID = myStorage->addConstraint(aNewConstraint); + if (!hasDuplicated && myStorage->hasDuplicatedConstraint()) { + // the duplicated constraint appears + myStorage->removeConstraint(aNewID); + return SLVS_E_UNKNOWN; + } mySlvsConstraints.push_back(aNewID); return aNewID; } diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index e630978ec..8a5267be2 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -419,7 +419,7 @@ bool SketchSolver_Group::resolveConstraints() aResult = myConstrSolver.solve(); if (aResult == SLVS_RESULT_OKAY || aNbTemp <= 0) break; - aNbTemp = myStorage->removeFirstTemporaryConstraint(); + aNbTemp = myStorage->deleteTemporaryConstraint(); myStorage->initializeSolver(myConstrSolver); } } diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 250ce7e56..63b22bf4c 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -546,12 +546,37 @@ void SketchSolver_Storage::removeTemporaryConstraints() myTemporaryConstraints.clear(); } -int SketchSolver_Storage::removeFirstTemporaryConstraint() +int SketchSolver_Storage::deleteTemporaryConstraint() { if (myTemporaryConstraints.empty()) return 0; - removeConstraint(*myTemporaryConstraints.begin()); - myTemporaryConstraints.erase(myTemporaryConstraints.begin()); + // Search the point-on-line or a non-rigid constraint + std::set::iterator aCIt = myTemporaryConstraints.begin(); + for (; aCIt != myTemporaryConstraints.end(); aCIt++) { + int aPos = Search(*aCIt, myConstraints); + if (myConstraints[aPos].type != SLVS_C_WHERE_DRAGGED) + break; + std::vector::iterator anIt = myConstraints.begin(); + for (; anIt != myConstraints.end(); anIt++) + if (anIt->type == SLVS_C_PT_ON_LINE && anIt->ptA == myConstraints[aPos].ptA) + break; + if (anIt != myConstraints.end()) + break; + } + if (aCIt == myTemporaryConstraints.end()) + aCIt = myTemporaryConstraints.begin(); + bool aNewFixed = (*aCIt == myFixed); + removeConstraint(*aCIt); + myTemporaryConstraints.erase(aCIt); + if (aNewFixed) { + for (aCIt = myTemporaryConstraints.begin(); aCIt != myTemporaryConstraints.end(); aCIt++) { + int aPos = Search(*aCIt, myConstraints); + if (myConstraints[aPos].type == SLVS_C_WHERE_DRAGGED) { + myFixed = *aCIt; + break; + } + } + } return (int)myTemporaryConstraints.size(); } diff --git a/src/SketchSolver/SketchSolver_Storage.h b/src/SketchSolver/SketchSolver_Storage.h index 6a861e5ae..669f2c0ea 100644 --- a/src/SketchSolver/SketchSolver_Storage.h +++ b/src/SketchSolver/SketchSolver_Storage.h @@ -108,9 +108,9 @@ public: void addTemporaryConstraint(const Slvs_hConstraint& theConstraintID); /// \brief Remove all transient constraints void removeTemporaryConstraints(); - /// \brief Remove first temporary constraint + /// \brief Remove one temporary constraint. Preferable to remove the points under Point-on-Line constraint /// \return Number of remaining temporary constraints - int removeFirstTemporaryConstraint(); + int deleteTemporaryConstraint(); /// \brief Checks the constraint is temporary bool isTemporary(const Slvs_hConstraint& theConstraintID) const;