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