X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketchPlugin%2FSketchPlugin_IntersectionPoint.cpp;h=a71c02499b3d20b8a3c95fcaab2fdbaed182e4a8;hb=b5893b0a30fac08134c24de4565cb513a43affa6;hp=5c411427c1463dcaab3d427ace30188f567beb2b;hpb=963b1b8ffcfaab221409c7e0540d8de7eb1297a9;p=modules%2Fshaper.git diff --git a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp index 5c411427c..a71c02499 100644 --- a/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp +++ b/src/SketchPlugin/SketchPlugin_IntersectionPoint.cpp @@ -6,7 +6,9 @@ #include "SketchPlugin_IntersectionPoint.h" -#include +#include +#include +#include #include #include @@ -19,7 +21,7 @@ SketchPlugin_IntersectionPoint::SketchPlugin_IntersectionPoint() void SketchPlugin_IntersectionPoint::initDerivedClassAttributes() { - data()->addAttribute(EXTERNAL_LINE_ID(), ModelAPI_AttributeRefAttr::typeId()); + data()->addAttribute(EXTERNAL_LINE_ID(), ModelAPI_AttributeSelection::typeId()); SketchPlugin_Point::initDerivedClassAttributes(); } @@ -50,22 +52,27 @@ void SketchPlugin_IntersectionPoint::attributeChanged(const std::string& theID) void SketchPlugin_IntersectionPoint::computePoint() { - AttributeRefAttrPtr aLineRefAttr = - std::dynamic_pointer_cast(attribute(EXTERNAL_LINE_ID())); - ResultPtr aLineResult = std::dynamic_pointer_cast(aLineRefAttr->object()); - if (!aLineResult) + AttributeSelectionPtr aLineAttr = + std::dynamic_pointer_cast(attribute(EXTERNAL_LINE_ID())); + + std::shared_ptr anEdge; + if(aLineAttr && aLineAttr->value() && aLineAttr->value()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->value())); + } else if(aLineAttr->context() && aLineAttr->context()->shape() && + aLineAttr->context()->shape()->isEdge()) { + anEdge = std::shared_ptr(new GeomAPI_Edge(aLineAttr->context()->shape())); + } + if(!anEdge.get()) return; - std::shared_ptr aLinearEdge = - std::dynamic_pointer_cast(aLineResult->shape()); - std::shared_ptr aLine = aLinearEdge->line(); + std::shared_ptr aLine = anEdge->line(); std::shared_ptr aSketchPlane = sketch()->plane(); std::shared_ptr anIntersection = aSketchPlane->intersect(aLine); if (!anIntersection) return; - std::shared_ptr aCoordAttr = + std::shared_ptr aCoordAttr = std::dynamic_pointer_cast(attribute(COORD_ID())); aCoordAttr->setValue(sketch()->to2D(anIntersection)); }