Salome HOME
Merge branch 'master' of newgeom:newgeom
[modules/shaper.git] / src / GeomAPI / GeomAPI_XYZ.cpp
1 // File:        GeomAPI_XYZ.cpp
2 // Created:     23 Apr 2014
3 // Author:      Mikhail PONIKAROV
4
5 #include<GeomAPI_XYZ.h>
6
7 #include<gp_XYZ.hxx>
8
9 #define MY_XYZ static_cast<gp_XYZ*>(myImpl)
10
11 GeomAPI_XYZ::GeomAPI_XYZ(const double theX, const double theY, const double theZ)
12   : GeomAPI_Interface(new gp_XYZ(theX, theY, theZ))
13 {}
14
15 double GeomAPI_XYZ::x() const
16 {
17   return MY_XYZ->X();
18 }
19
20 double GeomAPI_XYZ::y() const
21 {
22   return MY_XYZ->Y();
23 }
24
25 double GeomAPI_XYZ::z() const
26 {
27   return MY_XYZ->Z();
28 }
29
30 void GeomAPI_XYZ::setX(const double theX)
31 {
32   return MY_XYZ->SetX(theX);
33 }
34
35 void GeomAPI_XYZ::setY(const double theY)
36 {
37   return MY_XYZ->SetY(theY);
38 }
39
40 void GeomAPI_XYZ::setZ(const double theZ)
41 {
42   return MY_XYZ->SetZ(theZ);
43 }
44
45 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::added(
46   const boost::shared_ptr<GeomAPI_XYZ>& theArg)
47 {
48   boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() + theArg->x(),
49     MY_XYZ->Y() + theArg->y(), MY_XYZ->Z() + theArg->z()));
50   return aResult;
51 }
52
53 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::decreased(
54   const boost::shared_ptr<GeomAPI_XYZ>& theArg)
55 {
56   boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() - theArg->x(),
57     MY_XYZ->Y() - theArg->y(), MY_XYZ->Z() - theArg->z()));
58   return aResult;
59 }
60
61 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::multiplied(const double theArg)
62 {
63   boost::shared_ptr<GeomAPI_XYZ> aResult(new GeomAPI_XYZ(MY_XYZ->X() * theArg,
64     MY_XYZ->Y() * theArg, MY_XYZ->Z() * theArg));
65   return aResult;
66 }
67
68 double GeomAPI_XYZ::dot(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
69 {
70   return MY_XYZ->Dot(theArg->impl<gp_XYZ>());
71 }
72
73 const boost::shared_ptr<GeomAPI_XYZ> GeomAPI_XYZ::cross(const boost::shared_ptr<GeomAPI_XYZ>& theArg) const
74 {
75   gp_XYZ aResult = MY_XYZ->Crossed(theArg->impl<gp_XYZ>());
76   return boost::shared_ptr<GeomAPI_XYZ>(new GeomAPI_XYZ(aResult.X(), aResult.Y(), aResult.Z()));
77 }
78
79 double GeomAPI_XYZ::distance(const boost::shared_ptr<GeomAPI_XYZ>& theOther) const
80 {
81   gp_XYZ aResult(theOther->x() - x(), theOther->y() - y(), theOther->z() - z());
82   return aResult.Modulus();
83 }
84