1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Pnt2d.cpp
4 // Created: 29 May 2014
5 // Author: Artem ZHIDKOV
7 #include<GeomAPI_Pnt2d.h>
9 #include<GeomAPI_XYZ.h>
10 #include<GeomAPI_Pnt.h>
11 #include<GeomAPI_Dir.h>
13 #include<gp_Pnt2d.hxx>
15 #include <Precision.hxx>
17 #define MY_PNT2D implPtr<gp_Pnt2d>()
19 GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY)
20 : GeomAPI_Interface(new gp_Pnt2d(theX, theY))
24 GeomAPI_Pnt2d::GeomAPI_Pnt2d(const std::shared_ptr<GeomAPI_XY>& theCoords)
25 : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
29 double GeomAPI_Pnt2d::x() const
34 double GeomAPI_Pnt2d::y() const
39 void GeomAPI_Pnt2d::setX(const double theX)
41 return MY_PNT2D->SetX(theX);
44 void GeomAPI_Pnt2d::setY(const double theY)
46 return MY_PNT2D->SetY(theY);
49 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Pnt2d::to3D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
50 const std::shared_ptr<GeomAPI_Dir>& theDirX,
51 const std::shared_ptr<GeomAPI_Dir>& theDirY)
53 std::shared_ptr<GeomAPI_XYZ> aSum = theOrigin->xyz()->added(theDirX->xyz()->multiplied(x()))
54 ->added(theDirY->xyz()->multiplied(y()));
56 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
59 const std::shared_ptr<GeomAPI_XY> GeomAPI_Pnt2d::xy()
61 return std::shared_ptr<GeomAPI_XY>(new GeomAPI_XY(MY_PNT2D->X(), MY_PNT2D->Y()));
64 double GeomAPI_Pnt2d::distance(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const
66 return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
69 bool GeomAPI_Pnt2d::isEqual(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const
71 return distance(theOther) < Precision::Confusion();