X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FGeomAPI%2FGeomAPI_Pnt2d.cpp;h=2bd8e3937982f62d42bc0f6c734cc4712ab2cd3d;hb=3960b241ef14948d0ec99a010263e3643e08a762;hp=f1cbb8e22d4d7c7b8a36f78a5822831dc8973496;hpb=8f2fef811ec343cd840bef38e56f3658178f442c;p=modules%2Fshaper.git diff --git a/src/GeomAPI/GeomAPI_Pnt2d.cpp b/src/GeomAPI/GeomAPI_Pnt2d.cpp index f1cbb8e22..2bd8e3937 100644 --- a/src/GeomAPI/GeomAPI_Pnt2d.cpp +++ b/src/GeomAPI/GeomAPI_Pnt2d.cpp @@ -1,17 +1,30 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: GeomAPI_Pnt2d.cpp // Created: 29 May 2014 // Author: Artem ZHIDKOV #include +#include #include +#include +#include #include +#include + #define MY_PNT2D static_cast(myImpl) GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY) - : GeomAPI_Interface(new gp_Pnt2d(theX, theY)) -{} + : GeomAPI_Interface(new gp_Pnt2d(theX, theY)) +{ +} + +GeomAPI_Pnt2d::GeomAPI_Pnt2d(const std::shared_ptr& theCoords) + : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y())) +{ +} double GeomAPI_Pnt2d::x() const { @@ -33,7 +46,27 @@ void GeomAPI_Pnt2d::setY(const double theY) return MY_PNT2D->SetY(theY); } -double GeomAPI_Pnt2d::distance(const boost::shared_ptr& theOther) const +std::shared_ptr GeomAPI_Pnt2d::to3D(const std::shared_ptr& theOrigin, + const std::shared_ptr& theDirX, + const std::shared_ptr& theDirY) +{ + std::shared_ptr aSum = theOrigin->xyz()->added(theDirX->xyz()->multiplied(x())) + ->added(theDirY->xyz()->multiplied(y())); + + return std::shared_ptr(new GeomAPI_Pnt(aSum)); +} + +const std::shared_ptr GeomAPI_Pnt2d::xy() +{ + return std::shared_ptr(new GeomAPI_XY(MY_PNT2D->X(), MY_PNT2D->Y())); +} + +double GeomAPI_Pnt2d::distance(const std::shared_ptr& theOther) const { return MY_PNT2D->Distance(theOther->impl()); } + +bool GeomAPI_Pnt2d::isEqual(const std::shared_ptr& theOther) const +{ + return distance(theOther) < Precision::Confusion(); +}