Salome HOME
Issue #2126: Fatal error when create fillet
authorazv <azv@opencascade.com>
Wed, 12 Apr 2017 09:15:37 +0000 (12:15 +0300)
committerazv <azv@opencascade.com>
Wed, 12 Apr 2017 09:15:37 +0000 (12:15 +0300)
Avoid to select point-on-entity as a fillet vertex

src/SketchPlugin/SketchPlugin_Validators.cpp

index 96b01f6d59868bce8aad3c3bfc4f89524fa978ea..5246988b80959019e7088bd582f5eba81536084a 100755 (executable)
@@ -487,6 +487,24 @@ static bool hasSameTangentFeature(const std::set<AttributePtr>& theRefsList,
   return false;
 }
 
+static bool isPointPointCoincidence(const FeaturePtr& theCoincidence)
+{
+  AttributeRefAttrPtr aRefAttr[2] = {
+      theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_A()),
+      theCoincidence->refattr(SketchPlugin_Constraint::ENTITY_B())
+  };
+
+  bool arePoints = true;
+  for (int i = 0; i < 2 && arePoints; ++i) {
+    if (aRefAttr[i]->isObject()) {
+      FeaturePtr aFeature = ModelAPI_Feature::feature(aRefAttr[i]->object());
+      arePoints = aFeature.get() && aFeature->getKind() == SketchPlugin_Point::ID();
+    } else
+      arePoints = aRefAttr[i]->attr().get();
+  }
+  return arePoints;
+}
+
 bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribute,
                                                  const std::list<std::string>& theArguments,
                                                  Events_InfoMessage& theError) const
@@ -514,23 +532,24 @@ bool SketchPlugin_FilletVertexValidator::isValid(const AttributePtr& theAttribut
     std::shared_ptr<ModelAPI_Attribute> aAttr = (*anIt);
     FeaturePtr aConstrFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aAttr->owner());
     if (aConstrFeature->getKind() == SketchPlugin_ConstraintCoincidence::ID()) {
+      if (!isPointPointCoincidence(aConstrFeature))
+        continue;
+
       AttributeRefAttrPtr anAttrRefA = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
         aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_A()));
       AttributeRefAttrPtr anAttrRefB = std::dynamic_pointer_cast<ModelAPI_AttributeRefAttr>(
         aConstrFeature->attribute(SketchPlugin_ConstraintCoincidence::ENTITY_B()));
-      if(anAttrRefA.get() && !anAttrRefA->isObject()) {
-        AttributePtr anAttrA = anAttrRefA->attr();
-        if(aPointAttribute == anAttrA) {
-          aConstraintCoincidence = aConstrFeature;
-          break;
-        }
+
+      AttributePtr anAttrA = anAttrRefA->attr();
+      if(aPointAttribute == anAttrA) {
+        aConstraintCoincidence = aConstrFeature;
+        break;
       }
-      if(anAttrRefB.get() && !anAttrRefB->isObject()) {
-        AttributePtr anAttrB = anAttrRefB->attr();
-        if(aPointAttribute == anAttrB) {
-          aConstraintCoincidence = aConstrFeature;
-          break;
-        }
+
+      AttributePtr anAttrB = anAttrRefB->attr();
+      if(aPointAttribute == anAttrB) {
+        aConstraintCoincidence = aConstrFeature;
+        break;
       }
     }
   }