From: azv Date: Wed, 11 Jan 2017 13:24:37 +0000 (+0300) Subject: Eliminate crash in the Mirror constraint (issue #1982) X-Git-Tag: V_2.7.0~346^2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=e6580890c1ac8161e79880b280df523d284652b1;p=modules%2Fshaper.git Eliminate crash in the Mirror constraint (issue #1982) Allow to use Projected entities as objects of constraints --- diff --git a/src/SketchSolver/SketchSolver_Storage.cpp b/src/SketchSolver/SketchSolver_Storage.cpp index 91b36b77c..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. @@ -160,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;