X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Lin.cpp;h=348bf01a803c5b2d43e10934bc77c689c451aab3;hb=b5893b0a30fac08134c24de4565cb513a43affa6;hp=8b64190ba21c78a21df5824d9c4d04d5161122e9;hpb=3a5be0c5d1edb60a71f9daab6dd834ffa45eb550;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Lin.cpp b/src/GeomAPI/GeomAPI_Lin.cpp index 8b64190ba..348bf01a8 100644 --- a/src/GeomAPI/GeomAPI_Lin.cpp +++ b/src/GeomAPI/GeomAPI_Lin.cpp @@ -20,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) @@ -43,6 +43,15 @@ GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr& theStart, { } +GeomAPI_Lin::GeomAPI_Lin(const std::shared_ptr& theOrigin, + const std::shared_ptr& theDirection) + : GeomAPI_Interface(newLine(theOrigin->x(), theOrigin->y(), theOrigin->z(), + theOrigin->x() + theDirection->x(), + theOrigin->y() + theDirection->y(), + theOrigin->z() + theDirection->z())) +{ +} + std::shared_ptr GeomAPI_Lin::location() { gp_Pnt aLoc = impl().Location(); @@ -74,10 +83,10 @@ const std::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 std::shared_ptr(); - const gp_Pnt2d& anIntPnt2d = anInter.Point(0).Value(); + const gp_Pnt2d& anIntPnt2d = anInter.Point(1).Value(); gp_Pnt aResult = ElSLib::Value(anIntPnt2d.X(), anIntPnt2d.Y(), aPlane); return std::shared_ptr( @@ -92,7 +101,31 @@ const std::shared_ptr GeomAPI_Lin::project( const gp_XYZ& aPnt = thePoint->impl().XYZ(); double aParam = aDir.Dot(aPnt - aLoc); - gp_XYZ aResult = aPnt + aDir * aParam; + gp_XYZ aResult = aLoc + aDir * aParam; return std::shared_ptr(new GeomAPI_Pnt(aResult.X(), aResult.Y(), aResult.Z())); } +bool GeomAPI_Lin::contains(const std::shared_ptr thePoint, + const double theLinearTolerance) const +{ + if(!thePoint.get()) { + return false; + } + + return MY_LIN->Contains(thePoint->impl(), theLinearTolerance) == Standard_True; +} + +bool GeomAPI_Lin::isParallel(const std::shared_ptr theLin) const +{ + return MY_LIN->Direction().IsParallel(theLin->impl().Direction(), + Precision::Confusion()) == Standard_True; +} + +bool GeomAPI_Lin::isCoplanar(const std::shared_ptr theLin) const +{ + if(MY_LIN->SquareDistance(theLin->impl()) > Precision::Confusion()) { + return false; + } + + return true; +}