X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSketcherPrs%2FSketcherPrs_Tangent.cpp;h=bf998d8120b5e8fe1c17ed3d932ab56567ee012c;hb=2cb8023bec0da9fc7b138da0a467bca74d4b825c;hp=74ee2ed6910eb2b0978f1ceb9624cce8972e05a5;hpb=1ded0e810dc406dc9bc3abe7f470d06f0d74ff0e;p=modules%2Fshaper.git diff --git a/src/SketcherPrs/SketcherPrs_Tangent.cpp b/src/SketcherPrs/SketcherPrs_Tangent.cpp index 74ee2ed69..bf998d812 100644 --- a/src/SketcherPrs/SketcherPrs_Tangent.cpp +++ b/src/SketcherPrs/SketcherPrs_Tangent.cpp @@ -23,6 +23,9 @@ #include "SketcherPrs_PositionMgr.h" #include +#include +#include +#include #include @@ -37,8 +40,9 @@ IMPLEMENT_STANDARD_RTTIEXT(SketcherPrs_Tangent, SketcherPrs_SymbolPrs); static Handle(Image_AlienPixMap) MyPixMap; SketcherPrs_Tangent::SketcherPrs_Tangent(ModelAPI_Feature* theConstraint, + ModelAPI_CompositeFeature* theSketcher, const std::shared_ptr& thePlane) - : SketcherPrs_SymbolPrs(theConstraint, thePlane) + : SketcherPrs_SymbolPrs(theConstraint, theSketcher, thePlane) { } @@ -74,23 +78,27 @@ bool SketcherPrs_Tangent::updateIfReadyToDisplay(double theStep, bool withColor) GeomCurvePtr aCurv1 = std::shared_ptr(new GeomAPI_Curve(aShp1)); GeomCurvePtr aCurv2 = std::shared_ptr(new GeomAPI_Curve(aShp2)); - GeomPointPtr aPnt1_1 = aCurv1->getPoint(aCurv1->startParam()); - GeomPointPtr aPnt1_2 = aCurv1->getPoint(aCurv1->endParam()); - - GeomPointPtr aPnt2_1 = aCurv2->getPoint(aCurv2->startParam()); - GeomPointPtr aPnt2_2 = aCurv2->getPoint(aCurv2->endParam()); - GeomPointPtr aPnt; - if (aPnt1_1->isEqual(aPnt2_1) || aPnt1_1->isEqual(aPnt2_2)) - aPnt = aPnt1_1; - else if (aPnt1_2->isEqual(aPnt2_1) || aPnt1_2->isEqual(aPnt2_2)) - aPnt = aPnt1_2; + GeomShapePtr aIntPnt = aShp1->intersect(aShp2); + if (aIntPnt.get() && aIntPnt->isVertex()) { + GeomVertexPtr aVetrex(new GeomAPI_Vertex(aIntPnt)); + aPnt = aVetrex->point(); + } // Compute points coordinates - SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); - gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep, aPnt); - myPntArray = new Graphic3d_ArrayOfPoints(1, withColor); - myPntArray->AddVertex(aP1); + if (aPnt.get()) { + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep, aPnt); + myPntArray = new Graphic3d_ArrayOfPoints(1, withColor); + myPntArray->AddVertex(aP1); + } else { + SketcherPrs_PositionMgr* aMgr = SketcherPrs_PositionMgr::get(); + gp_Pnt aP1 = aMgr->getPosition(aObj1, this, theStep); + gp_Pnt aP2 = aMgr->getPosition(aObj2, this, theStep); + myPntArray = new Graphic3d_ArrayOfPoints(2, withColor); + myPntArray->AddVertex(aP1); + myPntArray->AddVertex(aP2); + } return true; }