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 implPtr<gp_Ax3>()
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> theNorm)
29 : GeomAPI_Interface(new gp_Ax3(theOrigin->impl<gp_Pnt>(),
30 theNorm->impl<gp_Dir>(),
31 theDirX->impl<gp_Dir>()))
35 void GeomAPI_Ax3::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
37 gp_Ax1 aAx1 = MY_AX3->Axis();
38 aAx1.SetLocation(theOrigin->impl<gp_Pnt>());
39 MY_AX3->SetAxis(aAx1);
42 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::origin() const
44 gp_Pnt aPnt = MY_AX3->Axis().Location();
45 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
48 void GeomAPI_Ax3::setDirX(const std::shared_ptr<GeomAPI_Dir>& theDirX)
50 MY_AX3->SetXDirection(theDirX->impl<gp_Dir>());
53 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirX() const
55 gp_Dir aDir = MY_AX3->XDirection();
56 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
59 void GeomAPI_Ax3::setDirY(const std::shared_ptr<GeomAPI_Dir>& theDirY)
61 MY_AX3->SetYDirection(theDirY->impl<gp_Dir>());
64 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::dirY() const
66 gp_Dir aDir = MY_AX3->YDirection();
67 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
70 void GeomAPI_Ax3::setNormal(const std::shared_ptr<GeomAPI_Dir>& theNorm)
72 gp_Ax1 aAx1 = MY_AX3->Axis();
73 aAx1.SetDirection(theNorm->impl<gp_Dir>());
74 MY_AX3->SetAxis(aAx1);
77 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax3::normal() const
79 gp_Dir aDir = MY_AX3->Axis().Direction();
80 return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(),aDir.Y(),aDir.Z()));
84 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax3::to3D(double theX, double theY) const
86 gp_Pnt aPnt = MY_AX3->Axis().Location();
87 gp_Dir aXDir = MY_AX3->XDirection();
88 gp_Dir aYDir = MY_AX3->YDirection();
89 gp_XYZ aSum = aPnt.XYZ().Added(aXDir.XYZ().Multiplied(theX)).Added(aYDir.XYZ().Multiplied(theY));
91 return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aSum.X(), aSum.Y(), aSum.Z()));
94 std::shared_ptr<GeomAPI_Pnt2d> GeomAPI_Ax3::to2D(double theX, double theY, double theZ) const
96 gp_Pnt anOriginPnt = MY_AX3->Axis().Location();
97 gp_Vec aVec(anOriginPnt, gp_Pnt(0, 0, 0));
99 gp_Dir aXDir = MY_AX3->XDirection();
100 gp_Dir aYDir = MY_AX3->YDirection();
102 double aX = aVec.X() * aXDir.X() + aVec.Y() * aXDir.Y() + aVec.Z() * aXDir.Z();
103 double aY = aVec.X() * aYDir.X() + aVec.Y() * aYDir.Y() + aVec.Z() * aYDir.Y();
104 return std::shared_ptr<GeomAPI_Pnt2d>(new GeomAPI_Pnt2d(aX, aY));