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