+void SketchPlugin_ConstraintSplit::updateTangentConstraintsToFeature(
+ const std::map<std::shared_ptr<ModelAPI_Feature>, IdToPointPair>& theTangentFeatures,
+ const std::set<std::shared_ptr<GeomDataAPI_Point2D> >& theFurtherCoincidences)
+{
+ if (theTangentFeatures.empty())
+ return;
+
+ std::map<FeaturePtr, IdToPointPair>::const_iterator aTIt = theTangentFeatures.begin(),
+ aTLast = theTangentFeatures.end();
+#ifdef DEBUG_SPLIT
+ std::cout << std::endl;
+ std::cout << "Tangencies to feature(modified):"<< std::endl;
+#endif
+ for (; aTIt != aTLast; aTIt++) {
+ FeaturePtr aTangentFeature = aTIt->first;
+ std::string anAttributeId = aTIt->second.first;
+ AttributePoint2DPtr aTangentPoint = aTIt->second.second;
+ std::set<AttributePoint2DPtr>::const_iterator aFCIt = theFurtherCoincidences.begin(),
+ aFCLast = theFurtherCoincidences.end();
+ std::shared_ptr<GeomAPI_Pnt2d> aCoincPnt = aTangentPoint->pnt();
+ AttributePoint2DPtr aFeaturePointAttribute;
+ /// here we rely on created coincidence between further coincidence point and tangent result
+ for (; aFCIt != aFCLast && !aFeaturePointAttribute.get(); aFCIt++) {
+ AttributePoint2DPtr aFCAttribute = *aFCIt;
+ if (aCoincPnt->isEqual(aFCAttribute->pnt()))
+ aFeaturePointAttribute = aFCAttribute;
+ }
+ if (aFeaturePointAttribute.get()) {
+ FeaturePtr aFeature =
+ std::dynamic_pointer_cast<ModelAPI_Feature>(aFeaturePointAttribute->owner());
+ aTangentFeature->refattr(anAttributeId)->setObject(getFeatureResult(aFeature));
+ }
+#ifdef DEBUG_SPLIT
+ std::cout << " -" << getFeatureInfo(aTangentFeature) << std::endl;
+#endif
+ }
+}
+
+void SketchPlugin_ConstraintSplit::updateRefFeatureConstraints(
+ const ResultPtr& theFeatureBaseResult,
+ const std::list<AttributePtr>& theRefsToFeature)
+{
+ std::list<AttributePtr>::const_iterator anIt = theRefsToFeature.begin(),
+ aLast = theRefsToFeature.end();
+ for (; anIt != aLast; anIt++) {
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*anIt);
+ if (aRefAttr.get())
+ aRefAttr->setObject(theFeatureBaseResult);
+ }
+}
+
+void SketchPlugin_ConstraintSplit::updateRefAttConstraints(
+ const std::map<AttributePtr, std::list<AttributePtr> >& theBaseRefAttributes,
+ const std::set<std::pair<AttributePtr, AttributePtr> >& theModifiedAttributes)
+{
+#ifdef DEBUG_SPLIT
+ std::cout << "SketchPlugin_ConstraintSplit::updateRefAttConstraints" << std::endl;
+#endif
+
+ std::set<std::pair<AttributePtr, AttributePtr> >::const_iterator
+ anIt = theModifiedAttributes.begin(), aLast = theModifiedAttributes.end();
+ for (; anIt != aLast; anIt++) {
+ AttributePtr anAttribute = anIt->first;
+
+ /// not found in references
+ if (theBaseRefAttributes.find(anAttribute) == theBaseRefAttributes.end())
+ continue;
+ std::list<AttributePtr> aRefAttributes = theBaseRefAttributes.at(anAttribute);
+ std::list<AttributePtr>::const_iterator aRefIt = aRefAttributes.begin(),
+ aRLast = aRefAttributes.end();
+
+ AttributePtr aNewAttribute = anIt->second;
+ for (; aRefIt != aRLast; aRefIt++) {
+ AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*aRefIt);
+ if (aRefAttr.get()) {
+ aRefAttr->setAttr(aNewAttribute);
+#ifdef DEBUG_SPLIT
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr->owner());
+ std::cout << " -" << getFeatureInfo(aFeature) << std::endl;
+#endif
+ }
+ }
+ }
+}
+