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>
11 #include<GeomAPI_Pln.h>
17 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
19 GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ)
20 : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
24 GeomAPI_Pnt::GeomAPI_Pnt(const std::shared_ptr<GeomAPI_XYZ>& theCoords)
25 : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z()))
29 double GeomAPI_Pnt::x() const
34 double GeomAPI_Pnt::y() const
39 double GeomAPI_Pnt::z() const
44 void GeomAPI_Pnt::setX(const double theX)
46 return MY_PNT->SetX(theX);
49 void GeomAPI_Pnt::setY(const double theY)
51 return MY_PNT->SetY(theY);
54 void GeomAPI_Pnt::setZ(const double theZ)
56 return MY_PNT->SetZ(theZ);
59 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
61 return std::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
64 double GeomAPI_Pnt::distance(const std::shared_ptr<GeomAPI_Pnt>& theOther) const
66 return MY_PNT->Distance(theOther->impl<gp_Pnt>());
69 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
70 const std::shared_ptr<GeomAPI_Dir>& theDirX, const std::shared_ptr<GeomAPI_Dir>& theDirY)
72 gp_Pnt anOriginPnt(theOrigin->x(), theOrigin->y(), theOrigin->z());
73 gp_Vec aVec(anOriginPnt, impl<gp_Pnt>());
75 double aX = aVec.X() * theDirX->x() + aVec.Y() * theDirX->y() + aVec.Z() * theDirX->z();
76 double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
77 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
81 void GeomAPI_Pnt::translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist)
83 gp_Vec aVec(theDir->impl<gp_Dir>());
85 aVec.Multiply(theDist);
86 MY_PNT->Translate(aVec);
89 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pln>& thePln) const
91 double aA, aB, aC, aD;
92 thePln->coefficients(aA, aB, aC, aD);
93 gp_Pln aPln(aA, aB, aC, aD);
95 gp_Pnt2d aRes = ProjLib::Project(aPln, *MY_PNT);
96 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aRes.X(), aRes.Y()));