1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomAPI_Ax3.cpp
4 // Created: 16 February 2015
5 // Author: Vitaly SMETANNIKOV
8 #include "GeomAPI_Ax3.h"
9 #include "GeomAPI_XYZ.h"
10 #include "GeomAPI_Pnt2d.h"
15 #include <Precision.hxx>
18 #define MY_AX3 static_cast<gp_Ax3*>(myImpl)
21 GeomAPI_Ax3::GeomAPI_Ax3()
22 : GeomAPI_Interface(new gp_Ax3())
26 GeomAPI_Ax3::GeomAPI_Ax3(std::shared_ptr<GeomAPI_Pnt> theOrigin,
27 std::shared_ptr<GeomAPI_Dir> theDirX,
28 std::shared_ptr<GeomAPI_Dir> theDirY,
29 std::shared_ptr<GeomAPI_Dir> theNorm)
30 : GeomAPI_Interface(new gp_Ax3(theOrigin->impl<gp_Pnt>(),
31 theNorm->impl<gp_Dir>(),
32 theDirX->impl<gp_Dir>()))
34 MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
37 void GeomAPI_Ax3::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
39 gp_Ax1 aAx1 = MY_AX3->Axis();
40 aAx1.SetLocation(theOrigin->impl<gp_Pnt>());
41 MY_AX3->SetAxis(aAx1);
44 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::origin() const
46 gp_Pnt aPnt = MY_AX3->Axis().Location();
47 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
50 void GeomAPI_Ax3::setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX)
52 MY_AX3->SetXDirection(theDirX->impl<gp_Dir>());
55 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirX() const
57 gp_Dir aDir = MY_AX3->XDirection();
58 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
61 void GeomAPI_Ax3::setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY)
63 MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
66 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirY() const
68 gp_Dir aDir = MY_AX3->YDirection();
69 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
72 void GeomAPI_Ax3::setNorm(const std::shared_ptr<GeomAPI_Dir>& theNorm)
74 gp_Ax1 aAx1 = MY_AX3->Axis();
75 aAx1.SetDirection(theNorm->impl<gp_Dir>());
76 MY_AX3->SetAxis(aAx1);
79 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::norm() const
81 gp_Dir aDir = MY_AX3->Axis().Direction();
82 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(),aDir.Y(),aDir.Z()));
86 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::to3D(double theX, double theY) const
88 gp_Pnt aPnt = MY_AX3->Axis().Location();
89 gp_Dir aXDir = MY_AX3->XDirection();
90 gp_Dir aYDir = MY_AX3->YDirection();
91 gp_XYZ aSum = aPnt.XYZ().Added(aXDir.XYZ().Multiplied(theX)).Added(aYDir.XYZ().Multiplied(theY));
93 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum.X(), aSum.Y(), aSum.Z()));
96 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ax3::to2D(double theX, double theY, double theZ) const
98 gp_Pnt anOriginPnt = MY_AX3->Axis().Location();
99 gp_Vec aVec(anOriginPnt, gp_Pnt(0, 0, 0));
101 gp_Dir aXDir = MY_AX3->XDirection();
102 gp_Dir aYDir = MY_AX3->YDirection();
104 double aX = aVec.X() * aXDir.X() + aVec.Y() * aXDir.Y() + aVec.Z() * aXDir.Z();
105 double aY = aVec.X() * aYDir.X() + aVec.Y() * aYDir.Y() + aVec.Z() * aYDir.Y();
106 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));