1 // File: GeomAPI_Pnt.cpp
2 // Created: 23 Apr 2014
3 // Author: Mikhail PONIKAROV
5 #include<GeomAPI_Pnt.h>
6 #include<GeomAPI_XYZ.h>
7 #include<GeomAPI_Pnt2d.h>
8 #include<GeomAPI_Dir.h>
12 #define MY_PNT static_cast<gp_Pnt*>(myImpl)
14 GeomAPI_Pnt::GeomAPI_Pnt(const double theX, const double theY, const double theZ)
15 : GeomAPI_Interface(new gp_Pnt(theX, theY, theZ))
19 GeomAPI_Pnt::GeomAPI_Pnt(const boost::shared_ptr<GeomAPI_XYZ>& theCoords)
20 : GeomAPI_Interface(new gp_Pnt(theCoords->x(), theCoords->y(), theCoords->z()))
24 double GeomAPI_Pnt::x() const
29 double GeomAPI_Pnt::y() const
34 double GeomAPI_Pnt::z() const
39 void GeomAPI_Pnt::setX(const double theX)
41 return MY_PNT->SetX(theX);
44 void GeomAPI_Pnt::setY(const double theY)
46 return MY_PNT->SetY(theY);
49 void GeomAPI_Pnt::setZ(const double theZ)
51 return MY_PNT->SetZ(theZ);
54 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_Pnt::xyz()
56 return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(MY_PNT->X(), MY_PNT->Y(), MY_PNT->Z()));
59 double GeomAPI_Pnt::distance(const boost::shared_ptr<GeomAPI_Pnt>& theOther) const
61 return MY_PNT->Distance(theOther->impl<gp_Pnt>());
64 boost::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Pnt::to2D(const boost::shared_ptr<GeomAPI_Pnt>& theOrigin,
65 const boost::shared_ptr<GeomAPI_Dir>& theDirX, const boost::shared_ptr<GeomAPI_Dir>& theDirY)
67 gp_Pnt anOriginPnt(theOrigin->x(), theOrigin->y(), theOrigin->z());
68 gp_Vec aVec(anOriginPnt, impl<gp_Pnt>());
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 boost::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));