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 implPtr<gp_Pnt>()
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 bool GeomAPI_Pnt::isEqual(const std::shared_ptr<GeomAPI_Pnt>& theOther) const
71 return distance(theOther) < Precision::Confusion();
74 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
75 const std::shared_ptr<GeomAPI_Dir>& theDirX, const std::shared_ptr<GeomAPI_Dir>& theDirY)
77 gp_Pnt anOriginPnt(theOrigin->x(), theOrigin->y(), theOrigin->z());
78 gp_Vec aVec(anOriginPnt, impl<gp_Pnt>());
80 double aX = aVec.X() * theDirX->x() + aVec.Y() * theDirX->y() + aVec.Z() * theDirX->z();
81 double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
82 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
86 void GeomAPI_Pnt::translate(const std::shared_ptr<GeomAPI_Dir>& theDir, double theDist)
88 gp_Vec aVec(theDir->impl<gp_Dir>());
90 aVec.Multiply(theDist);
91 MY_PNT->Translate(aVec);
94 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pln>& thePln) const
96 double aA, aB, aC, aD;
97 thePln->coefficients(aA, aB, aC, aD);
98 gp_Pln aPln(aA, aB, aC, aD);
100 gp_Pnt2d aRes = ProjLib::Project(aPln, *MY_PNT);
101 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aRes.X(), aRes.Y()));