From: dbv Date: Tue, 27 Sep 2016 13:22:18 +0000 (+0300) Subject: Issue #1774: Can't select edge for tangent constraint creation X-Git-Tag: V_2.5.1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=05cb54cb247bda099b1dc9218e3382e79becb40c;p=modules%2Fshaper.git Issue #1774: Can't select edge for tangent constraint creation Now arguments for Tangent constraint can be selected even if they "coincident" through the points. --- diff --git a/src/SketchPlugin/SketchPlugin_Validators.cpp b/src/SketchPlugin/SketchPlugin_Validators.cpp index 4f88df34c..5f89c141e 100755 --- a/src/SketchPlugin/SketchPlugin_Validators.cpp +++ b/src/SketchPlugin/SketchPlugin_Validators.cpp @@ -107,12 +107,55 @@ bool SketchPlugin_DistanceAttrValidator::isValid(const AttributePtr& theAttribut return true; } +static bool isCoincident(FeaturePtr theFeature1, FeaturePtr theFeature2) +{ + AttributePtr aFeature1PointAttr[2]; + if(theFeature1->getKind() == SketchPlugin_Line::ID()) { + aFeature1PointAttr[0] = theFeature1->attribute(SketchPlugin_Line::START_ID()); + aFeature1PointAttr[1] = theFeature1->attribute(SketchPlugin_Line::END_ID()); + } else if(theFeature1->getKind() == SketchPlugin_Arc::ID()) { + aFeature1PointAttr[0] = theFeature1->attribute(SketchPlugin_Arc::START_ID()); + aFeature1PointAttr[1] = theFeature1->attribute(SketchPlugin_Arc::END_ID()); + } + + std::set aRefsList = theFeature1->data()->refsToMe(); + for(std::set::const_iterator aRefIt = aRefsList.begin(); + aRefIt != aRefsList.end(); + ++aRefIt) { + // Find constraint + FeaturePtr aRefFeature = std::dynamic_pointer_cast((*aRefIt)->owner()); + if(aRefFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID()) + continue; + AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast(*aRefIt); + AttributePtr anAttr = aRefAttr->attr(); + if(anAttr != aFeature1PointAttr[0] && anAttr != aFeature1PointAttr[1]) + continue; + + // Get coincides from constraint. + std::set aCoinsides; + SketchPlugin_Tools::findCoincidences(aRefFeature, + SketchPlugin_ConstraintCoincidence::ENTITY_A(), + aCoinsides); + SketchPlugin_Tools::findCoincidences(aRefFeature, + SketchPlugin_ConstraintCoincidence::ENTITY_B(), + aCoinsides); + + if(aCoinsides.find(theFeature2) != aCoinsides.end()) { + return true; + } + } + + return false; +} static bool hasCoincidentPoint(FeaturePtr theFeature1, FeaturePtr theFeature2) { - FeaturePtr aCoincidenceFeature = SketchPlugin_ConstraintCoincidence::findCoincidenceFeature - (theFeature1, theFeature2); - return aCoincidenceFeature.get() != NULL; + if(theFeature1->getKind() == SketchPlugin_Circle::ID() || + theFeature2->getKind() == SketchPlugin_Circle::ID()) { + return false; + } + + return (isCoincident(theFeature1, theFeature2) && isCoincident(theFeature2, theFeature1)); } bool SketchPlugin_TangentAttrValidator::isValid(const AttributePtr& theAttribute,