From e6580890c1ac8161e79880b280df523d284652b1 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 11 Jan 2017 16:24:37 +0300 Subject: [PATCH] Eliminate crash in the Mirror constraint (issue #1982) Allow to use Projected entities as objects of constraints --- src/SketchSolver/SketchSolver_Storage.cpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) 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; -- 2.39.2