Salome HOME
Update copyrights
[modules/shaper.git] / src / GeomAPI / GeomAPI_Ax1.cpp
1 // Copyright (C) 2014-2019  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_Ax1.h>
21
22 #include <gp_Ax1.hxx>
23
24 #define MY_AX1 implPtr<gp_Ax1>()
25
26 //=================================================================================================
27 GeomAPI_Ax1::GeomAPI_Ax1()
28 : GeomAPI_Interface(new gp_Ax1())
29 {
30 }
31
32 //=================================================================================================
33 GeomAPI_Ax1::GeomAPI_Ax1(std::shared_ptr<GeomAPI_Pnt> theOrigin,
34                          std::shared_ptr<GeomAPI_Dir> theDir)
35 : GeomAPI_Interface(new gp_Ax1(theOrigin->impl<gp_Pnt>(),
36                                theDir->impl<gp_Dir>()))
37 {
38 }
39
40 //=================================================================================================
41 void GeomAPI_Ax1::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
42 {
43   MY_AX1->SetLocation(theOrigin->impl<gp_Pnt>());
44 }
45
46 //=================================================================================================
47 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax1::origin() const
48 {
49   gp_Pnt aPnt = MY_AX1->Location();
50   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
51 }
52
53 //=================================================================================================
54 void GeomAPI_Ax1::setDir(const std::shared_ptr<GeomAPI_Dir>& theDir)
55 {
56   MY_AX1->SetDirection(theDir->impl<gp_Dir>());
57 }
58
59 //=================================================================================================
60 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax1::dir() const
61 {
62   gp_Dir aDir = MY_AX1->Direction();
63   return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
64 }
65
66 //=================================================================================================
67 void GeomAPI_Ax1::reverse()
68 {
69   MY_AX1->Reverse();
70 }
71
72 //=================================================================================================
73 std::shared_ptr<GeomAPI_Ax1> GeomAPI_Ax1::reversed()
74 {
75   gp_Ax1 anAxis = MY_AX1->Reversed();
76   std::shared_ptr<GeomAPI_Pnt> aPnt(
77     new GeomAPI_Pnt(anAxis.Location().X(), anAxis.Location().Y(), anAxis.Location().Z()));
78   std::shared_ptr<GeomAPI_Dir> aDir(
79     new GeomAPI_Dir(anAxis.Direction().X(), anAxis.Direction().Y(), anAxis.Direction().Z()));
80   return std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(aPnt, aDir));
81 }