Salome HOME
a7434d711de49ea7348ff2781361539b87c18988
[modules/shaper.git] / src / GeomAPI / GeomAPI_Ax2.cpp
1 // Copyright (C) 2014-2023  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include <GeomAPI_Ax2.h>
21
22 #include <gp_Ax2.hxx>
23
24 #define MY_AX1 implPtr<gp_Ax2>()
25
26 //=================================================================================================
27 GeomAPI_Ax2::GeomAPI_Ax2()
28 : GeomAPI_Interface(new gp_Ax2())
29 {
30 }
31
32 //=================================================================================================
33 GeomAPI_Ax2::GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
34                          std::shared_ptr<GeomAPI_Dir> theN,
35                          std::shared_ptr<GeomAPI_Dir> theVX)
36 : GeomAPI_Interface(new gp_Ax2(theOrigin->impl<gp_Pnt>(),
37                                theN->impl<gp_Dir>(),
38                                theVX->impl<gp_Dir>()))
39 {
40 }
41
42 //=================================================================================================
43 GeomAPI_Ax2::GeomAPI_Ax2(std::shared_ptr<GeomAPI_Pnt> theOrigin,
44                          std::shared_ptr<GeomAPI_Dir> theDir)
45 : GeomAPI_Interface(new gp_Ax2(theOrigin->impl<gp_Pnt>(),
46                                theDir->impl<gp_Dir>()))
47 {
48 }
49
50 //=================================================================================================
51 void GeomAPI_Ax2::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
52 {
53   MY_AX1->SetLocation(theOrigin->impl<gp_Pnt>());
54 }
55
56 //=================================================================================================
57 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax2::origin() const
58 {
59   gp_Pnt aPnt = MY_AX1->Location();
60   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
61 }
62
63 //=================================================================================================
64 void GeomAPI_Ax2::setDir(const std::shared_ptr<GeomAPI_Dir>& theDir)
65 {
66   MY_AX1->SetDirection(theDir->impl<gp_Dir>());
67 }
68
69 //=================================================================================================
70 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax2::dir() const
71 {
72   gp_Dir aDir = MY_AX1->Direction();
73   return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
74 }