From: azv Date: Fri, 6 May 2016 07:39:47 +0000 (+0300) Subject: Do not fix copies in constraint Mirror to avoid problems with conflicting constraints... X-Git-Tag: V_2.3.0~7 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dd09fdea5a1f4a8775c48bcfc8de6650793d0cf2;p=modules%2Fshaper.git Do not fix copies in constraint Mirror to avoid problems with conflicting constraints (issue #1486) --- diff --git a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp index 509404940..0bccf4f04 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMirror.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMirror.cpp @@ -106,6 +106,9 @@ void SketchSolver_ConstraintMirror::process() } myStorage->addConstraint(myBaseConstraint, aMirConstrList); + // update mirrored features to be in the current group + for (aMIt = aMirrorList.begin(); aMIt != aMirrorList.end(); ++aMIt) + myStorage->update((*aMIt)->baseFeature(), myGroupID); } diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 587a3f31d..8ef9d9c0e 100644 --- a/src/SketchSolver/SketchSolver_Storage.cpp +++ b/src/SketchSolver/SketchSolver_Storage.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include @@ -144,6 +145,30 @@ void SketchSolver_Storage::addEntity(AttributePtr theAttribute, } +static bool isCopyInMulti(std::shared_ptr theFeature, + const std::map >& theConstraints) +{ + 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; + } + } + } + return aResult; +} + bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup) { bool isUpdated = false; @@ -177,7 +202,7 @@ bool SketchSolver_Storage::update(FeaturePtr theFeature, const GroupID& theGroup // Check external feature std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theFeature); - if (aSketchFeature && (aSketchFeature->isExternal() || aSketchFeature->isCopy())) + if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap))) aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createFeature(theFeature, aSubs, aGroup); if (!aRelated) @@ -223,7 +248,7 @@ bool SketchSolver_Storage::update(AttributePtr theAttribute, const GroupID& theG // Check attribute of external features std::shared_ptr aSketchFeature = std::dynamic_pointer_cast(theAttribute->owner()); - if (aSketchFeature && (aSketchFeature->isExternal() || aSketchFeature->isCopy())) + if (aSketchFeature && (aSketchFeature->isExternal() || isCopyInMulti(aSketchFeature, myConstraintMap))) aGroup = GID_OUTOFGROUP; aRelated = aBuilder->createAttribute(anAttribute, aGroup); if (!aRelated)