X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_PositionMgr.cpp;h=7aacd2002093c332c992a444deaac12f75898e03;hb=c02fae5493cc6d56c9a1db3bdcf6d872f88fea07;hp=1670661528bda4efd13a656e7a4fc8535ab4d79f;hpb=97917d3698f5a2f7fc9596e7c755ff8f6751e373;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp index 167066152..7aacd2002 100644 --- a/src/SketcherPrs/SketcherPrs_PositionMgr.cpp +++ b/src/SketcherPrs/SketcherPrs_PositionMgr.cpp @@ -20,21 +20,23 @@ #include "SketcherPrs_PositionMgr.h" #include "SketcherPrs_Tools.h" -#include -#include -#include -#include #include #include +#include +#include +#include +#include #include +#include #include -#include -#include #include -#include +#include +#include +#include #include +#include #include #include @@ -150,14 +152,17 @@ const std::array& SketcherPrs_PositionMgr::getPositionIndex(GeomPointPtr if (aUseFeature) { DataPtr aData = aFeature->data(); AttributeRefAttrPtr aObjRef = aData->refattr(SketchPlugin_Constraint::ENTITY_A()); - FeaturePtr aObj = ModelAPI_Feature::feature(aObjRef->object()); + FeaturePtr aObj; + if (aObjRef) + aObj = ModelAPI_Feature::feature(aObjRef->object()); bool aContains = false; - if (containsPoint(aObj, aPnt2d, thePos)) { + if (aObj && containsPoint(aObj, aPnt2d, thePos)) { aContains = true; } else { aObjRef = aData->refattr(SketchPlugin_Constraint::ENTITY_B()); - aObj = ModelAPI_Feature::feature(aObjRef->object()); - if (containsPoint(aObj, aPnt2d, thePos)) { + if (aObjRef) + aObj = ModelAPI_Feature::feature(aObjRef->object()); + if (aObj && containsPoint(aObj, aPnt2d, thePos)) { aContains = true; } } @@ -186,7 +191,7 @@ gp_Vec getVector(ObjectPtr theShape, GeomDirPtr theDir, gp_Pnt theP) std::shared_ptr aCurve = std::shared_ptr(new GeomAPI_Curve(aShape)); - if (aCurve->isCircle()) { + if (aCurve->isCircle() || aCurve->isEllipse()) { Handle(Geom_Curve) aCurv = aCurve->impl(); GeomAPI_ProjectPointOnCurve anExtr(theP, aCurv); double aParam = anExtr.LowerDistanceParameter(); @@ -325,8 +330,7 @@ std::list getCurves(const GeomPointPtr& thePnt, const SketcherPrs_Sym if (aDist <= Precision::Confusion()) aList.push_back(aFeature->firstResult()); } - } else if ((aFeature->getKind() == SketchPlugin_Circle::ID()) || - (aFeature->getKind() == SketchPlugin_Arc::ID())) { + } else { GeomCurvePtr aCurve; ObjectPtr aResObj; std::list aResults = aFeature->results(); @@ -340,10 +344,16 @@ std::list getCurves(const GeomPointPtr& thePnt, const SketcherPrs_Sym } } if (aCurve.get()) { - double aStart = aCurve->startParam(); - double aEnd = aCurve->endParam(); - GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve)); - GeomPointPtr aProjPnt = aCircle->project(thePnt); + GeomPointPtr aProjPnt; + if (aFeature->getKind() == SketchPlugin_Circle::ID() || + aFeature->getKind() == SketchPlugin_Arc::ID()) { + GeomCirclePtr aCircle = GeomCirclePtr(new GeomAPI_Circ(aCurve)); + aProjPnt = aCircle->project(thePnt); + } + else if (aFeature->getKind() == SketchPlugin_Ellipse::ID()) { + GeomEllipsePtr anEllipse = GeomEllipsePtr(new GeomAPI_Ellipse(aCurve)); + aProjPnt = anEllipse->project(thePnt); + } if (aProjPnt && thePnt->distance(aProjPnt) <= Precision::Confusion()) aList.push_back(aResObj); } @@ -358,6 +368,8 @@ gp_Pnt SketcherPrs_PositionMgr::getPointPosition( double theStep, GeomPointPtr thePnt) { gp_Pnt aP = thePnt->impl(); + if (!thePrs->plane().get()) + return aP; GeomDirPtr aNormal = thePrs->plane()->normal(); gp_Dir aNormDir = aNormal->impl();