]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomAPI/GeomAPI_Pnt.cpp
Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / GeomAPI / GeomAPI_Pnt.cpp
1 // File:        GeomAPI_Pnt.cpp
2 // Created:     23 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include<GeomAPI_Pnt.h>
6 #include<GeomAPI_XYZ.h>
7 #include<GeomAPI_Pnt2d.h>
8 #include<GeomAPI_Dir.h>
9
10 #include<gp_Pnt.hxx>
11
12 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
13
14 GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ)
15     : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
16 {
17 }
18
19 GeomAPI_Pnt::GeomAPI_Pnt(const std::shared_ptr<GeomAPI_XYZ>& theCoords)
20     : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z()))
21 {
22 }
23
24 double GeomAPI_Pnt::x() const
25 {
26   return MY_PNT->X();
27 }
28
29 double GeomAPI_Pnt::y() const
30 {
31   return MY_PNT->Y();
32 }
33
34 double GeomAPI_Pnt::z() const
35 {
36   return MY_PNT->Z();
37 }
38
39 void GeomAPI_Pnt::setX(const double theX)
40 {
41   return MY_PNT->SetX(theX);
42 }
43
44 void GeomAPI_Pnt::setY(const double theY)
45 {
46   return MY_PNT->SetY(theY);
47 }
48
49 void GeomAPI_Pnt::setZ(const double theZ)
50 {
51   return MY_PNT->SetZ(theZ);
52 }
53
54 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
55 {
56   return std::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
57 }
58
59 double GeomAPI_Pnt::distance(const std::shared_ptr<GeomAPI_Pnt>& theOther) const
60 {
61   return MY_PNT->Distance(theOther->impl<gp_Pnt>());
62 }
63
64 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const std::shared_ptr<GeomAPI_Pnt>& theOrigin,
65   const std::shared_ptr<GeomAPI_Dir>& theDirX, const std::shared_ptr<GeomAPI_Dir>& theDirY)
66 {
67   gp_Pnt anOriginPnt(theOrigin->x(), theOrigin->y(), theOrigin->z());
68   gp_Vec aVec(anOriginPnt, impl<gp_Pnt>());
69
70   double aX = aVec.X() * theDirX->x() + aVec.Y() * theDirX->y() + aVec.Z() * theDirX->z();
71   double aY = aVec.X() * theDirY->x() + aVec.Y() * theDirY->y() + aVec.Z() * theDirY->z();
72   return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));
73 }