Salome HOME
Changes for modifying of GeomData objects by GeomAPI objects
[modules/shaper.git] / src / GeomAPI / GeomAPI_XY.cpp
1 // File:        GeomAPI_XY.cpp
2 // Created:     30 May 2014
3 // Author:      Artem ZHIDKOV
4
5 #include<GeomAPI_XY.h>
6
7 #include<gp_XY.hxx>
8
9 #define MY_XY static_cast<gp_XY*>(myImpl)
10
11 GeomAPI_XY::GeomAPI_XY(const double theX, const double theY)
12   : GeomAPI_Interface(new gp_XY(theX, theY))
13 {}
14
15 double GeomAPI_XY::x() const
16 {
17   return MY_XY->X();
18 }
19
20 double GeomAPI_XY::y() const
21 {
22   return MY_XY->Y();
23 }
24
25 void GeomAPI_XY::setX(const double theX)
26 {
27   return MY_XY->SetX(theX);
28 }
29
30 void GeomAPI_XY::setY(const double theY)
31 {
32   return MY_XY->SetY(theY);
33 }
34
35 const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::added(
36   const boost::shared_ptr<GeomAPI_XY>& theArg)
37 {
38   boost::shared_ptr<GeomAPI_XY> aResult(
39     new GeomAPI_XY(MY_XY->X() + theArg->x(), MY_XY->Y() + theArg->y()));
40   return aResult;
41 }
42
43 const boost::shared_ptr<GeomAPI_XY> GeomAPI_XY::multiplied(const double theArg)
44 {
45   boost::shared_ptr<GeomAPI_XY> aResult(
46     new GeomAPI_XY(MY_XY->X() * theArg, MY_XY->Y() * theArg));
47   return aResult;
48 }
49
50 double GeomAPI_XY::dot(const boost::shared_ptr<GeomAPI_XY>& theArg) const
51 {
52   return MY_XY->Dot(theArg->impl<gp_XY>());
53 }
54
55 double GeomAPI_XY::cross(const boost::shared_ptr<GeomAPI_XY>& theArg) const
56 {
57   return MY_XY->Crossed(theArg->impl<gp_XY>());
58 }
59
60 double GeomAPI_XY::distance(const boost::shared_ptr<GeomAPI_XY>& theOther) const
61 {
62   gp_XY aResult(theOther->x() - x(), theOther->y() - y());
63   return aResult.Modulus();
64 }
65