From: azv Date: Tue, 29 Sep 2015 11:01:30 +0000 (+0300) Subject: Correct checking directions of lines used in the Angle constraint (issue #1023) X-Git-Tag: V_1.4.0_demo1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=333f62b3ecd0a14ba4001abf0ab126fd08f6fc5a;p=modules%2Fshaper.git Correct checking directions of lines used in the Angle constraint (issue #1023) --- diff --git a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp index 895f99e62..10dbae165 100644 --- a/src/SketchSolver/SketchSolver_ConstraintAngle.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintAngle.cpp @@ -47,8 +47,11 @@ void SketchSolver_ConstraintAngle::adjustConstraint() return; double aDist[2][2]; for (int i = 0; i < 2; i++) { - for (int j = 0; j < 2; j++) + for (int j = 0; j < 2; j++) { aDist[i][j] = anIntersection->distance(aPoints[i][j]); + if (fabs(aDist[i][j]) <= tolerance) + aDist[i][j] = 0.0; + } if (aDist[i][0] > tolerance && aDist[i][1] > tolerance && aDist[i][0] + aDist[i][1] < aPoints[i][0]->distance(aPoints[i][1]) + 2.0 * tolerance) { // the intersection point is an inner point of the line, @@ -66,8 +69,10 @@ void SketchSolver_ConstraintAngle::adjustConstraint() aDir[i] = std::shared_ptr(new GeomAPI_Dir2d( aPoints[i][0]->xy()->decreased(anIntersection->xy()))); // main direction is opposite => change signs - aDist[i][0] *= -1.0; - aDist[i][1] *= -1.0; + if (aDist[i][0] < 0.0) { + aDist[i][0] *= -1.0; + aDist[i][1] *= -1.0; + } } aConstraint.other = false; diff --git a/src/SketchSolver/SketchSolver_Group.cpp b/src/SketchSolver/SketchSolver_Group.cpp index 52b3d34b7..67b9d31dd 100644 --- a/src/SketchSolver/SketchSolver_Group.cpp +++ b/src/SketchSolver/SketchSolver_Group.cpp @@ -149,14 +149,8 @@ Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const if (!myFeatureStorage) return aResult; // Obtain regular constraints interacting with the feature and find its ID - std::set aConstraints = myFeatureStorage->getConstraints(theFeature); - if (aConstraints.empty()) - return aResult; - std::set::iterator aConstrIter = aConstraints.begin(); - for (; aConstrIter != aConstraints.end(); ++aConstrIter) { - ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter); - if (aCIter == myConstraints.end()) - continue; + ConstraintConstraintMap::const_iterator aCIter = myConstraints.begin(); + for (; aCIter != myConstraints.end(); ++aCIter) { aResult = aCIter->second->getId(theFeature); if (aResult != SLVS_E_UNKNOWN) return aResult; @@ -179,12 +173,8 @@ Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const if (!myFeatureStorage) return aResult; // Obtain regular constraints interacting with the attribute and find its ID - std::set aConstraints = myFeatureStorage->getConstraints(theAttribute); - std::set::iterator aConstrIter = aConstraints.begin(); - for (; aConstrIter != aConstraints.end(); aConstrIter++) { - ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter); - if (aCIter == myConstraints.end()) - continue; + ConstraintConstraintMap::const_iterator aCIter = myConstraints.begin(); + for (; aCIter != myConstraints.end(); ++aCIter) { aResult = aCIter->second->getId(theAttribute); if (aResult != SLVS_E_UNKNOWN) return aResult; @@ -773,6 +763,9 @@ void SketchSolver_Group::removeConstraint(ConstraintPtr theConstraint) if (aCIter == myConstraints.end()) return; + // Remove entities not used by constraints + myStorage->removeUnusedEntities(); + if (isFullyRemoved) myConstraints.erase(aCIter); else if (aCIter != myConstraints.end() &&