Salome HOME
Updated copyright comment
[modules/shaper.git] / src / GeomAPI / GeomAPI_XY.cpp
1 // Copyright (C) 2014-2024  CEA, EDF
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_XY.h>
21
22 #include<gp_XY.hxx>
23
24 #define MY_XY implPtr<gp_XY>()
25
26 GeomAPI_XY::GeomAPI_XY(const double theX, const double theY)
27     : GeomAPI_Interface(new gp_XY(theX, theY))
28 {
29 }
30
31 double GeomAPI_XY::x() const
32 {
33   return MY_XY->X();
34 }
35
36 double GeomAPI_XY::y() const
37 {
38   return MY_XY->Y();
39 }
40
41 void GeomAPI_XY::setX(const double theX)
42 {
43   return MY_XY->SetX(theX);
44 }
45
46 void GeomAPI_XY::setY(const double theY)
47 {
48   return MY_XY->SetY(theY);
49 }
50
51 const std::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(const std::shared_ptr<GeomAPI_XY>& theArg)
52 {
53   std::shared_ptr<GeomAPI_XY> aResult(new GeomAPI_XY(
54       MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
55   return aResult;
56 }
57
58 const std::shared_ptr<GeomAPI_XY> GeomAPI_XY::decreased(
59     const std::shared_ptr<GeomAPI_XY>& theArg)
60 {
61   std::shared_ptr<GeomAPI_XY> aResult(new GeomAPI_XY(
62       MY_XY->X() - theArg->x(), MY_XY->Y() - theArg->y()));
63   return aResult;
64 }
65
66 const std::shared_ptr<GeomAPI_XY> GeomAPI_XY::multiplied(const double theArg)
67 {
68   std::shared_ptr<GeomAPI_XY> aResult(new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
69   return aResult;
70 }
71
72 double GeomAPI_XY::dot(const std::shared_ptr<GeomAPI_XY>& theArg) const
73 {
74   return MY_XY->Dot(theArg->impl<gp_XY>());
75 }
76
77 double GeomAPI_XY::cross(const std::shared_ptr<GeomAPI_XY>& theArg) const
78 {
79   return MY_XY->Crossed(theArg->impl<gp_XY>());
80 }
81
82 double GeomAPI_XY::distance(const std::shared_ptr<GeomAPI_XY>& theOther) const
83 {
84   gp_XY aResult(theOther->x() - x(), theOther->y() - y());
85   return aResult.Modulus();
86 }
87