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