1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Pnt.cpp
4 // Created: 23 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #include<GeomAPI_Pnt.h>
8 #include<GeomAPI_XYZ.h>
9 #include<GeomAPI_Pnt2d.h>
10 #include<GeomAPI_Dir.h>
14 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
16 GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ)
17 : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
21 GeomAPI_Pnt::GeomAPI_Pnt(const std::shared_ptr<GeomAPI_XYZ>& theCoords)
22 : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z()))
26 double GeomAPI_Pnt::x() const
31 double GeomAPI_Pnt::y() const
36 double GeomAPI_Pnt::z() const
41 void GeomAPI_Pnt::setX(const double theX)
43 return MY_PNT->SetX(theX);
46 void GeomAPI_Pnt::setY(const double theY)
48 return MY_PNT->SetY(theY);
51 void GeomAPI_Pnt::setZ(const double theZ)
53 return MY_PNT->SetZ(theZ);
56 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
58 return std::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
61 double GeomAPI_Pnt::distance(const std::shared_ptr<GeomAPI_Pnt>& theOther) const
63 return MY_PNT->Distance(theOther->impl<gp_Pnt>());
66 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
67 const std::shared_ptr<GeomAPI_Dir>& theDirX, const std::shared_ptr<GeomAPI_Dir>& theDirY)
69 gp_Pnt anOriginPnt(theOrigin->x(), theOrigin->y(), theOrigin->z());
70 gp_Vec aVec(anOriginPnt, impl<gp_Pnt>());
72 double aX = aVec.X() * theDirX->x() + aVec.Y() * theDirX->y() + aVec.Z() * theDirX->z();
73 double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
74 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
78 void GeomAPI_Pnt::translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist)
80 gp_Vec aVec(theDir->impl<gp_Dir>());
82 aVec.Multiply(theDist);
83 MY_PNT->Translate(aVec);