]> SALOME platform Git repositories - modules/shaper.git/blobdiff - src/SketchPlugin/SketchPlugin_Validators.cpp
Salome HOME
"2.11 Constraint with a point from the intersection between an outer edge and plane...
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_Validators.cpp
index b07e90ac46a1b4cbe0eda9a7cd4dd605f90f5aa8..a00da25cbba418085e8771ae67d651002576b460 100755 (executable)
@@ -696,14 +696,15 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut
     theError = "The attribute with the " + theAttribute->attributeType() + " type is not processed";
     return false;
   }
-  AttributeSelectionPtr anAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
-  ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anAttr->context());
-  if (!aResult) {
-    theError = "The attribute " + theAttribute->id() + " should be an object";
-    return false;
+  AttributeSelectionPtr aLineAttr =
+                              std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(theAttribute);
+  std::shared_ptr<GeomAPI_Edge> anEdge;
+  if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->value()));
+  } else if(aLineAttr->context() && aLineAttr->context()->shape() && aLineAttr->context()->shape()->isEdge()) {
+    anEdge = std::shared_ptr<GeomAPI_Edge>(new GeomAPI_Edge(aLineAttr->context()->shape()));
   }
 
-  std::shared_ptr<GeomAPI_Edge> anEdge = std::dynamic_pointer_cast<GeomAPI_Edge>(aResult->shape());
   if (!anEdge || !anEdge->isLine()) {
     theError = "The attribute " + theAttribute->id() + " should be a line";
     return false;
@@ -713,7 +714,7 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut
 
   // find a sketch
   std::shared_ptr<SketchPlugin_Sketch> aSketch;
-  std::set<AttributePtr> aRefs = anAttr->owner()->data()->refsToMe();
+  std::set<AttributePtr> aRefs = aLineAttr->owner()->data()->refsToMe();
   std::set<AttributePtr>::const_iterator anIt = aRefs.begin();
   for (; anIt != aRefs.end(); ++anIt) {
     CompositeFeaturePtr aComp =
@@ -730,5 +731,5 @@ bool SketchPlugin_IntersectionValidator::isValid(const AttributePtr& theAttribut
 
   std::shared_ptr<GeomAPI_Pln> aPlane = aSketch->plane();
   std::shared_ptr<GeomAPI_Dir> aNormal = aPlane->direction();
-  return true;//fabs(aNormal->dot(aLineDir)) > tolerance * tolerance;
+  return fabs(aNormal->dot(aLineDir)) > tolerance * tolerance;
 }