Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / GeomAPI / GeomAPI_Ax1.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomAPI_Ax1.cpp
4 // Created:     12 May 2015
5 // Author:      Dmitry Bobylev
6
7 #include <GeomAPI_Ax1.h>
8
9 #include <gp_Ax1.hxx>
10
11 #define MY_AX1 implPtr<gp_Ax1>()
12
13 //=================================================================================================
14 GeomAPI_Ax1::GeomAPI_Ax1()
15 : GeomAPI_Interface(new gp_Ax1())
16 {
17 }
18
19 //=================================================================================================
20 GeomAPI_Ax1::GeomAPI_Ax1(std::shared_ptr<GeomAPI_Pnt> theOrigin,
21                          std::shared_ptr<GeomAPI_Dir> theDir)
22 : GeomAPI_Interface(new gp_Ax1(theOrigin->impl<gp_Pnt>(),
23                                theDir->impl<gp_Dir>()))
24 {
25 }
26
27 //=================================================================================================
28 void GeomAPI_Ax1::setOrigin(const std::shared_ptr<GeomAPI_Pnt>& theOrigin)
29 {
30   MY_AX1->SetLocation(theOrigin->impl<gp_Pnt>());
31 }
32
33 //=================================================================================================
34 std::shared_ptr<GeomAPI_Pnt> GeomAPI_Ax1::origin() const
35 {
36   gp_Pnt aPnt = MY_AX1->Location();
37   return std::shared_ptr<GeomAPI_Pnt>(new GeomAPI_Pnt(aPnt.X(),aPnt.Y(),aPnt.Z()));
38 }
39
40 //=================================================================================================
41 void GeomAPI_Ax1::setDir(const std::shared_ptr<GeomAPI_Dir>& theDir)
42 {
43   MY_AX1->SetDirection(theDir->impl<gp_Dir>());
44 }
45
46 //=================================================================================================
47 std::shared_ptr<GeomAPI_Dir> GeomAPI_Ax1::dir() const
48 {
49   gp_Dir aDir = MY_AX1->Direction();
50   return std::shared_ptr<GeomAPI_Dir>(new GeomAPI_Dir(aDir.X(), aDir.Y(), aDir.Z()));
51 }
52
53 //=================================================================================================
54 void GeomAPI_Ax1::reverse()
55 {
56   MY_AX1->Reverse();
57 }
58
59 //=================================================================================================
60 std::shared_ptr<GeomAPI_Ax1> GeomAPI_Ax1::reversed()
61 {
62   gp_Ax1 anAxis = MY_AX1->Reversed();
63   std::shared_ptr<GeomAPI_Pnt> aPnt(
64     new GeomAPI_Pnt(anAxis.Location().X(), anAxis.Location().Y(), anAxis.Location().Z()));
65   std::shared_ptr<GeomAPI_Dir> aDir(
66     new GeomAPI_Dir(anAxis.Direction().X(), anAxis.Direction().Y(), anAxis.Direction().Z()));
67   return std::shared_ptr<GeomAPI_Ax1>(new GeomAPI_Ax1(aPnt, aDir));
68 }