]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #1774: Can't select edge for tangent constraint creation
authordbv <dbv@opencascade.com>
Tue, 27 Sep 2016 13:22:18 +0000 (16:22 +0300)
committerdbv <dbv@opencascade.com>
Tue, 27 Sep 2016 13:22:41 +0000 (16:22 +0300)
Now arguments for Tangent constraint can be selected even if they "coincident" through the points.

src/SketchPlugin/SketchPlugin_Validators.cpp

index 4f88df34c2ce296078296b9b8fb52a33a4583db3..5f89c141e793e407b88a327145763feb29861981 100755 (executable)
@@ -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<AttributePtr> aRefsList = theFeature1->data()->refsToMe();
+  for(std::set<AttributePtr>::const_iterator aRefIt = aRefsList.begin();
+      aRefIt != aRefsList.end();
+      ++aRefIt) {
+    // Find constraint 
+    FeaturePtr aRefFeature = std::dynamic_pointer_cast<ModelAPI_Feature>((*aRefIt)->owner());
+    if(aRefFeature->getKind() != SketchPlugin_ConstraintCoincidence::ID())
+      continue;
+    AttributeRefAttrPtr aRefAttr = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(*aRefIt);
+    AttributePtr anAttr = aRefAttr->attr();
+    if(anAttr != aFeature1PointAttr[0] && anAttr != aFeature1PointAttr[1])
+      continue;
+
+    // Get coincides from constraint.
+    std::set<FeaturePtr> 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,