X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Lin.cpp;h=dba5834abc1b7cb596f0cd088ddb4d954480f437;hb=3d28bcbab2f3ed0e40295e64f4e836caebc19fca;hp=58095f0e8f1432d4b10086ad5a48634549da044d;hpb=8dc74f82810d5f597b78633b457efb0ef4f89f9f;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Lin.cpp b/src/GeomAPI/GeomAPI_Lin.cpp index 58095f0e8..dba5834ab 100644 --- a/src/GeomAPI/GeomAPI_Lin.cpp +++ b/src/GeomAPI/GeomAPI_Lin.cpp @@ -1,9 +1,12 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_Lin.cpp // Created: 29 May 2014 // Author: Artem ZHIDKOV #include #include +#include #include #include @@ -17,7 +20,7 @@ #include #include -#define MY_LIN static_cast(myImpl) +#define MY_LIN implPtr() static gp_Lin* newLine(const double theStartX, const double theStartY, const double theStartZ, const double theEndX, const double theEndY, const double theEndZ) @@ -33,23 +36,35 @@ GeomAPI_Lin::GeomAPI_Lin(const double theStartX, const double theStartY, const d { } -GeomAPI_Lin::GeomAPI_Lin(const boost::shared_ptr& theStart, - const boost::shared_ptr& theEnd) +GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr& theStart, + const std::shared_ptr& theEnd) : GeomAPI_Interface( newLine(theStart->x(), theStart->y(), theStart->z(), theEnd->x(), theEnd->y(), theEnd->z())) { } -double GeomAPI_Lin::distance(const boost::shared_ptr& thePoint) const +std::shared_ptr GeomAPI_Lin::location() +{ + gp_Pnt aLoc = impl().Location(); + return std::shared_ptr(new GeomAPI_Pnt(aLoc.X(), aLoc.Y(), aLoc.Z())); +} + +std::shared_ptr GeomAPI_Lin::direction() +{ + const gp_Dir& aDir = impl().Direction(); + return std::shared_ptr(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z())); +} + +double GeomAPI_Lin::distance(const std::shared_ptr& thePoint) const { return MY_LIN->Distance(thePoint->impl()); } -const boost::shared_ptr GeomAPI_Lin::intersect( - const boost::shared_ptr& theLine) const +const std::shared_ptr GeomAPI_Lin::intersect( + const std::shared_ptr& theLine) const { if (MY_LIN->SquareDistance(theLine->impl()) > Precision::Confusion()) - return boost::shared_ptr(); + return std::shared_ptr(); const gp_Dir& aDir1 = MY_LIN->Direction(); const gp_Dir& aDir2 = theLine->impl().Direction(); @@ -59,18 +74,18 @@ const boost::shared_ptr GeomAPI_Lin::intersect( gp_Lin2d aPrjLine1 = ProjLib::Project(aPlane, *MY_LIN); gp_Lin2d aPrjLine2 = ProjLib::Project(aPlane, theLine->impl()); - IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine1); + IntAna2d_AnaIntersection anInter(aPrjLine1, aPrjLine2); if (!anInter.IsDone() || anInter.IsEmpty()) - return boost::shared_ptr(); - const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value(); + return std::shared_ptr(); + const gp_Pnt2d& anIntPnt2d = anInter.Point(1).Value(); gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane); - return boost::shared_ptr( + return std::shared_ptr( new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); } -const boost::shared_ptr GeomAPI_Lin::project( - const boost::shared_ptr& thePoint) const +const std::shared_ptr GeomAPI_Lin::project( + const std::shared_ptr& thePoint) const { const gp_XYZ& aDir = MY_LIN->Direction().XYZ(); const gp_XYZ& aLoc = MY_LIN->Location().XYZ(); @@ -78,6 +93,6 @@ const boost::shared_ptr GeomAPI_Lin::project( double aParam = aDir.Dot(aPnt - aLoc); gp_XYZ aResult = aPnt + aDir * aParam; - return boost::shared_ptr(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); + return std::shared_ptr(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); }