Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / GeomAPI / GeomAPI_XYZ.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_XYZ.h>
22
23 #include<gp_XYZ.hxx>
24
25 #define MY_XYZ implPtr<gp_XYZ>()
26
27 GeomAPI_XYZ::GeomAPI_XYZ(const double theX, const double theY, const double theZ)
28     : GeomAPI_Interface(new gp_XYZ(theX, theY, theZ))
29 {
30 }
31
32 double GeomAPI_XYZ::x() const
33 {
34   return MY_XYZ->X();
35 }
36
37 double GeomAPI_XYZ::y() const
38 {
39   return MY_XYZ->Y();
40 }
41
42 double GeomAPI_XYZ::z() const
43 {
44   return MY_XYZ->Z();
45 }
46
47 void GeomAPI_XYZ::setX(const double theX)
48 {
49   return MY_XYZ->SetX(theX);
50 }
51
52 void GeomAPI_XYZ::setY(const double theY)
53 {
54   return MY_XYZ->SetY(theY);
55 }
56
57 void GeomAPI_XYZ::setZ(const double theZ)
58 {
59   return MY_XYZ->SetZ(theZ);
60 }
61
62 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::added(
63     const std::shared_ptr<GeomAPI_XYZ>& theArg)
64 {
65   std::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() + theArg->x(),
66   MY_XYZ->Y() + theArg->y(), MY_XYZ->Z() + theArg->z()));
67   return aResult;
68 }
69
70 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::decreased(
71     const std::shared_ptr<GeomAPI_XYZ>& theArg)
72 {
73   std::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() - theArg->x(),
74   MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z()));
75   return aResult;
76 }
77
78 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::multiplied(const double theArg)
79 {
80   std::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg,
81   MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg));
82   return aResult;
83 }
84
85 double GeomAPI_XYZ::dot(const std::shared_ptr<GeomAPI_XYZ>& theArg) const
86 {
87   return MY_XYZ->Dot(theArg->impl<gp_XYZ>());
88 }
89
90 const std::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::cross(
91     const std::shared_ptr<GeomAPI_XYZ>& theArg) const
92 {
93   gp_XYZ aResult = MY_XYZ->Crossed(theArg->impl<gp_XYZ>());
94   return std::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z()));
95 }
96
97 double GeomAPI_XYZ::distance(const std::shared_ptr<GeomAPI_XYZ>& theOther) const
98 {
99   gp_XYZ aResult(theOther->x() - x(), theOther->y() - y(), theOther->z() - z());
100   return aResult.Modulus();
101 }
102
103 double GeomAPI_XYZ::squareModulus() const
104 {
105   return MY_XYZ->SquareModulus();
106 }