From: azv Date: Fri, 25 Dec 2015 05:28:30 +0000 (+0300) Subject: Issue #1177: improve removing coincidence of the fixed points X-Git-Tag: V_2.1.0~56 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=86ce6478594c9dbb12c57176b5bee53bba53decf;p=modules%2Fshaper.git Issue #1177: improve removing coincidence of the fixed points --- diff --git a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp index 5ce8df014..012a45423 100644 --- a/src/SketchSolver/SketchSolver_ConstraintFixed.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintFixed.cpp @@ -55,6 +55,9 @@ void SketchSolver_ConstraintFixed::fixFeature(EntityWrapperPtr theFeature) myStorage->update(theFeature->baseAttribute(), GID_OUTOFGROUP); else if (theFeature->baseFeature()) myStorage->update(theFeature->baseFeature(), GID_OUTOFGROUP); + + if (myBaseConstraint) + myStorage->addConstraint(myBaseConstraint, std::list()); } void SketchSolver_ConstraintFixed::getAttributes( diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index b8773d92d..e54aec7e4 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -12,6 +12,7 @@ #include #include #include +#include /// \brief Verify two vectors of constraints are equal. @@ -295,6 +296,22 @@ static bool isUsed(EntityWrapperPtr theFeature, AttributePtr theSubEntity) return false; } +static bool isUsed(ConstraintPtr theConstraint, AttributePtr theAttribute) +{ + if (!theConstraint || !theAttribute) + return false; + std::list anAttrList = theConstraint->data()->attributes(std::string()); + std::list::const_iterator anIt = anAttrList.begin(); + for (; anIt != anAttrList.end(); ++anIt) { + if (*anIt == theAttribute) + return true; + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*anIt); + if (aRefAttr && !aRefAttr->isObject() && aRefAttr->attr() == theAttribute) + return true; + } + return false; +} + bool SketchSolver_Storage::isUsed(FeaturePtr theFeature) const { if (myFeatureMap.find(theFeature) != myFeatureMap.end()) @@ -333,10 +350,15 @@ bool SketchSolver_Storage::isUsed(AttributePtr theAttribute) const std::map >::const_iterator aCIt = myConstraintMap.begin(); std::list::const_iterator aCWIt; - for (; aCIt != myConstraintMap.end(); ++aCIt) + for (; aCIt != myConstraintMap.end(); ++aCIt) { for (aCWIt = aCIt->second.begin(); aCWIt != aCIt->second.end(); ++aCWIt) if (::isUsed(*aCWIt, anAttribute)) return true; + // Additional check for the Fixed constraints, which have no wrapper associated. + if (aCIt->first->getKind() == SketchPlugin_ConstraintRigid::ID() && + ::isUsed(aCIt->first, anAttribute)) + return true; + } // check in features std::map::const_iterator aFIt = myFeatureMap.begin(); for (; aFIt != myFeatureMap.end(); ++aFIt) diff --git a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp index e2cd45ad5..681c96c57 100644 --- a/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp +++ b/src/SketchSolver/SolveSpaceSolver/SolveSpaceSolver_Storage.cpp @@ -1119,12 +1119,12 @@ bool SolveSpaceSolver_Storage::remove(ConstraintWrapperPtr theConstraint) return true; bool isFullyRemoved = removeConstraint((Slvs_hConstraint)aConstraint->id()); + isFullyRemoved = SketchSolver_Storage::remove(theConstraint) && isFullyRemoved; // remove point-point coincidence if (aConstraint->type() == CONSTRAINT_PT_PT_COINCIDENT) - isFullyRemoved = removeCoincidence(theConstraint); - - return SketchSolver_Storage::remove(theConstraint) && isFullyRemoved; + isFullyRemoved = removeCoincidence(theConstraint) && isFullyRemoved; + return isFullyRemoved; } bool SolveSpaceSolver_Storage::remove(EntityWrapperPtr theEntity) @@ -1132,9 +1132,32 @@ bool SolveSpaceSolver_Storage::remove(EntityWrapperPtr theEntity) if (!theEntity) return false; + // Additional check for entity to be used in point-point coincidence + bool isCoincide = false; + if (theEntity->type() == ENTITY_POINT) { + CoincidentPointsMap::const_iterator anIt = myCoincidentPoints.begin(); + std::set::const_iterator aCIt; + for (; anIt != myCoincidentPoints.end(); ++anIt) { + if (anIt->first == theEntity) + break; + for (aCIt = anIt->second.begin(); aCIt != anIt->second.end(); ++aCIt) + if (*aCIt == theEntity) + break; + if (aCIt != anIt->second.end()) + break; + } + if (anIt != myCoincidentPoints.end()) { + if (anIt->first != theEntity && isUsed(anIt->first->baseAttribute())) + isCoincide = true; + for (aCIt = anIt->second.begin(); !isCoincide && aCIt != anIt->second.end(); ++aCIt) + if (*aCIt != theEntity && isUsed((*aCIt)->baseAttribute())) + isCoincide = true; + } + } + std::shared_ptr anEntity = std::dynamic_pointer_cast(theEntity); - bool isFullyRemoved = removeEntity((Slvs_hEntity)anEntity->id()); + bool isFullyRemoved = isCoincide ? true : removeEntity((Slvs_hEntity)anEntity->id()); return SketchSolver_Storage::remove(theEntity) && isFullyRemoved; }