1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include<GeomAPI_Pnt2d.h>
21 #include<GeomAPI_XY.h>
22 #include<GeomAPI_XYZ.h>
23 #include<GeomAPI_Pnt.h>
24 #include<GeomAPI_Dir.h>
26 #include<gp_Pnt2d.hxx>
28 #include <Precision.hxx>
30 #define MY_PNT2D implPtr<gp_Pnt2d>()
32 GeomAPI_Pnt2d::GeomAPI_Pnt2d(const double theX, const double theY)
33 : GeomAPI_Interface(new gp_Pnt2d(theX, theY))
37 GeomAPI_Pnt2d::GeomAPI_Pnt2d(const std::shared_ptr<GeomAPI_XY>& theCoords)
38 : GeomAPI_Interface(new gp_Pnt2d(theCoords->x(), theCoords->y()))
42 double GeomAPI_Pnt2d::x() const
47 double GeomAPI_Pnt2d::y() const
52 void GeomAPI_Pnt2d::setX(const double theX)
54 return MY_PNT2D->SetX(theX);
57 void GeomAPI_Pnt2d::setY(const double theY)
59 return MY_PNT2D->SetY(theY);
62 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Pnt2d::to3D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
63 const std::shared_ptr<GeomAPI_Dir>& theDirX,
64 const std::shared_ptr<GeomAPI_Dir>& theDirY)
66 std::shared_ptr<GeomAPI_XYZ> aSum = theOrigin->xyz()->added(theDirX->xyz()->multiplied(x()))
67 ->added(theDirY->xyz()->multiplied(y()));
69 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum));
72 const std::shared_ptr<GeomAPI_XY> GeomAPI_Pnt2d::xy()
74 return std::shared_ptr<GeomAPI_XY>(new GeomAPI_XY(MY_PNT2D->X(), MY_PNT2D->Y()));
77 double GeomAPI_Pnt2d::distance(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const
79 return MY_PNT2D->Distance(theOther->impl<gp_Pnt2d>());
82 bool GeomAPI_Pnt2d::isEqual(const std::shared_ptr<GeomAPI_Pnt2d>& theOther) const
84 return distance(theOther) < Precision::Confusion();