X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchSolver%2FSketchSolver_Storage.cpp;h=d1f6c4f17bbe88a2619731e5bb59c8c854be1183;hb=4f565b2204d3fba046aa8c851abada2a5a17bf6c;hp=c85b10a4a95bc898453c4bff3d56436064bcef01;hpb=cfbf42387151400387b1783bcf6589ae87118217;p=modules%2Fshaper.git diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index c85b10a4a..d1f6c4f17 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -18,6 +18,7 @@ #include #include #include +#include /// \brief Verify two vectors of constraints are equal. @@ -138,7 +139,8 @@ void SketchSolver_Storage::addEntity(FeaturePtr theFeature, void SketchSolver_Storage::addEntity(AttributePtr theAttribute, EntityWrapperPtr theSolverEntity) { - std::map::const_iterator aFound = myAttributeMap.find(theAttribute); + std::map::const_iterator aFound = + myAttributeMap.find(theAttribute); if (aFound == myAttributeMap.end() || !aFound->second || (theSolverEntity && !aFound->second->isEqual(theSolverEntity))) setNeedToResolve(true); // the entity is new or modified @@ -159,20 +161,14 @@ static bool isCopyInMulti(std::shared_ptr theFeature, return false; bool aResult = theFeature->isCopy(); if (aResult) { - std::map >::const_iterator - anIt = theConstraints.begin(); - for (; anIt != theConstraints.end() && aResult; ++anIt) { - if (anIt->first->getKind() != SketchPlugin_ConstraintMirror::ID()) - continue; - AttributeRefListPtr aRefList = std::dynamic_pointer_cast( - anIt->first->attribute(SketchPlugin_Constraint::ENTITY_C())); - std::list aMirroredList = aRefList->list(); - std::list::const_iterator aMIt = aMirroredList.begin(); - for (; aMIt != aMirroredList.end() && aResult; ++aMIt) { - FeaturePtr aFeat = ModelAPI_Feature::feature(*aMIt); - if (aFeat == theFeature) - aResult = false; - } + const std::set& aRefs = theFeature->data()->refsToMe(); + for (std::set::const_iterator aRefIt = aRefs.begin(); + aRefIt != aRefs.end() && aResult; ++aRefIt) { + FeaturePtr anOwner = ModelAPI_Feature::feature((*aRefIt)->owner()); + if ((anOwner->getKind() == SketchPlugin_ConstraintMirror::ID() && + (*aRefIt)->id() == SketchPlugin_Constraint::ENTITY_C()) || + (anOwner->getKind() == SketchPlugin_Projection::ID())) + aResult = false; } } return aResult; @@ -183,11 +179,12 @@ bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup bool isUpdated = false; EntityWrapperPtr aRelated = entity(theFeature); if (!aRelated) { // Feature is not exist, create it - std::shared_ptr aSketchFeature = + std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theFeature); bool isCopy = isCopyInMulti(aSketchFeature, myConstraintMap); + // the feature is a copy in "Multi" constraint and does not used in other constraints if (!theForce && isCopy && myFeatureMap.find(theFeature) == myFeatureMap.end()) - return false; // the feature is a copy in "Multi" constraint and does not used in other constraints + return false; std::list aSubs; // Reserve the feature in the map of features (do not want to add several copies of it) @@ -256,8 +253,8 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG if (aFeature->getKind() == SketchPlugin_Arc::ID() && myFeatureMap.find(aFeature) == myFeatureMap.end()) { // Additional checking that all attributes are initialized - if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && - aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && + if (aFeature->attribute(SketchPlugin_Arc::CENTER_ID())->isInitialized() && + aFeature->attribute(SketchPlugin_Arc::START_ID())->isInitialized() && aFeature->attribute(SketchPlugin_Arc::END_ID())->isInitialized()) { return SketchSolver_Storage::update(aFeature, theGroup, theForce); } else { @@ -269,9 +266,10 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG BuilderPtr aBuilder = SketchSolver_Manager::instance()->builder(); GroupID aGroup = theGroup != GID_UNKNOWN ? theGroup : myGroupID; // Check attribute of external features - std::shared_ptr aSketchFeature = + std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(anAttribute->owner()); - if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap))) + if (aSketchFeature && (aSketchFeature->isExternal() || + isCopyInMulti(aSketchFeature, myConstraintMap))) aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createAttribute(anAttribute, aGroup); if (!aRelated) @@ -655,7 +653,8 @@ bool SketchSolver_Storage::removeCoincidence(ConstraintWrapperPtr theConstraint) return true; } -void SketchSolver_Storage::replaceEntities(const std::map& theChange) +void SketchSolver_Storage::replaceEntities(const std::map& theChange) { std::set anUpdFeatures; std::map::const_iterator aSubIt; @@ -696,7 +695,8 @@ bool SketchSolver_Storage::remove(ConstraintWrapperPtr theConstraint) if (aBaseFeature) isFullyRemoved = SketchSolver_Storage::removeEntity(aBaseFeature) && isFullyRemoved; else - isFullyRemoved = SketchSolver_Storage::removeEntity((*anIt)->baseAttribute()) && isFullyRemoved; + isFullyRemoved = + SketchSolver_Storage::removeEntity((*anIt)->baseAttribute()) && isFullyRemoved; } return isFullyRemoved; } @@ -753,7 +753,7 @@ bool SketchSolver_Storage::isInteract(const AttributePtr& theAttribute) const if (!theAttribute) return false; - AttributeRefListPtr aRefList = + AttributeRefListPtr aRefList = std::dynamic_pointer_cast(theAttribute); if (aRefList) { std::list anObjects = aRefList->list(); @@ -812,7 +812,8 @@ bool SketchSolver_Storage::isFixed(EntityWrapperPtr theEntity) const return true; } - std::map >::const_iterator aCIt = myConstraintMap.begin(); + std::map >::const_iterator aCIt = + myConstraintMap.begin(); std::list::const_iterator aCWIt; for (; aCIt != myConstraintMap.end(); ++aCIt) { if (aCIt->second.empty()) @@ -894,8 +895,8 @@ void SketchSolver_Storage::processArcs() 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() && + 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 @@ -982,7 +983,8 @@ void resultToFeatureOrAttribute(const ObjectPtr& theResult, // if the feature has several results, we choose which one is referred const std::list& aResults = aFeature->results(); if (aResults.size() > 1 && theResult != aFeature->lastResult()) { - // actually, the attribute refers to center of arc or circle, but not the edge, get correct attributes + // actually, the attribute refers to center of arc or circle, + // but not the edge, get correct attributes std::string anAttrName; if (aFeature->getKind() == SketchPlugin_Arc::ID()) anAttrName = SketchPlugin_Arc::CENTER_ID();