- if (isEmpty()) return true;
- ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
- if (aConstraint)
- return myFeatureStorage->isInteract(aConstraint);
- return myFeatureStorage->isInteract(std::dynamic_pointer_cast<ModelAPI_Feature>(theFeature));
-}
-
-// ============================================================================
-// Function: getFeatureId
-// Class: SketchSolver_Group
-// Purpose: Find the identifier of the feature, if it already exists in the group
-// ============================================================================
-Slvs_hEntity SketchSolver_Group::getFeatureId(FeaturePtr theFeature) const
-{
- Slvs_hEntity aResult = SLVS_E_UNKNOWN;
- if (!myFeatureStorage)
- return aResult;
- // Obtain regular constraints interacting with the feature and find its ID
- std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theFeature);
- if (aConstraints.empty())
- return aResult;
- std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
- for (; aConstrIter != aConstraints.end(); ++aConstrIter) {
- ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
- if (aCIter == myConstraints.end())
- continue;
- aResult = aCIter->second->getId(theFeature);
- if (aResult != SLVS_E_UNKNOWN)
- return aResult;
- }
- // The feature is not found, check it in the temporary constraints
- std::set<SolverConstraintPtr>::iterator aTmpCIter = myTempConstraints.begin();
- for (; aTmpCIter != myTempConstraints.end() && aResult == SLVS_E_UNKNOWN; ++aTmpCIter)
- aResult = (*aTmpCIter)->getId(theFeature);
- return aResult;
-}
-
-// ============================================================================
-// Function: getAttributeId
-// Class: SketchSolver_Group
-// Purpose: Find the identifier of the attribute, if it already exists in the group
-// ============================================================================
-Slvs_hEntity SketchSolver_Group::getAttributeId(AttributePtr theAttribute) const
-{
- Slvs_hEntity aResult = SLVS_E_UNKNOWN;
- if (!myFeatureStorage)
- return aResult;
- // Obtain regular constraints interacting with the attribute and find its ID
- std::set<ConstraintPtr> aConstraints = myFeatureStorage->getConstraints(theAttribute);
- if (aConstraints.empty())
- return aResult;
- std::set<ConstraintPtr>::iterator aConstrIter = aConstraints.begin();
- for (; aConstrIter != aConstraints.end(); aConstrIter++) {
- ConstraintConstraintMap::const_iterator aCIter = myConstraints.find(*aConstrIter);
- if (aCIter == myConstraints.end())
- continue;
- aResult = aCIter->second->getId(theAttribute);
- if (aResult != SLVS_E_UNKNOWN)
- return aResult;
- }
- // The attribute is not found, check it in the temporary constraints
- std::set<SolverConstraintPtr>::iterator aTmpCIter = myTempConstraints.begin();
- for (; aTmpCIter != myTempConstraints.end() && aResult == SLVS_E_UNKNOWN; ++aTmpCIter)
- aResult = (*aTmpCIter)->getId(theAttribute);
- return aResult;
+ if (isEmpty())
+ return true;
+ // Check interaction with the storage
+ bool isInteracted = myStorage->isInteract(theFeature);
+ ConstraintConstraintMap::const_iterator anIt = myConstraints.begin();
+ for (; !isInteracted && anIt != myConstraints.end(); ++anIt)
+ if (anIt->first->getKind() == SketchPlugin_MultiRotation::ID() ||
+ anIt->first->getKind() == SketchPlugin_MultiTranslation::ID()) {
+ isInteracted = anIt->second->isUsed(theFeature);
+ if (isInteracted)
+ break;
+ // if theFeature is a constraint, check its attributes
+ ConstraintPtr aConstraint = std::dynamic_pointer_cast<SketchPlugin_Constraint>(theFeature);
+ if (!aConstraint)
+ continue;
+ for (int i = 0; i < 4 && !isInteracted; ++i) {
+ AttributeRefAttrPtr aRefAttr = aConstraint->refattr(aConstraint->ATTRIBUTE(i));
+ if (!aRefAttr)
+ continue;
+ isInteracted = anIt->second->isUsed((AttributePtr)aRefAttr);
+ }
+ }
+ return isInteracted;