Salome HOME
Debugging Translation feature.
[modules/shaper.git] / src / GeomData / GeomData_Dir.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomData_Dir.cxx
4 // Created:     2 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "GeomData_Dir.h"
8 #include <GeomAPI_Dir.h>
9 #include <GeomAPI_XYZ.h>
10 #include <gp_Dir.hxx>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Data.h>
13
14 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
15 {
16   if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
17       || myCoords->Value(2) != theZ) {
18     myCoords->SetValue(0, theX);
19     myCoords->SetValue(1, theY);
20     myCoords->SetValue(2, theZ);
21     owner()->data()->sendAttributeUpdated(this);
22   }
23 }
24
25 void GeomData_Dir::setValue(const std::shared_ptr<GeomAPI_Dir>& theDir)
26 {
27   setValue(theDir->x(), theDir->y(), theDir->z());
28 }
29
30 double GeomData_Dir::x() const
31 {
32   return myCoords->Value(0);
33 }
34
35 double GeomData_Dir::y() const
36 {
37   return myCoords->Value(1);
38 }
39
40 double GeomData_Dir::z() const
41 {
42   return myCoords->Value(2);
43 }
44
45 std::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
46 {
47   return std::shared_ptr<GeomAPI_Dir>(
48       new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
49 }
50
51 std::shared_ptr<GeomAPI_XYZ> GeomData_Dir::xyz()
52 {
53   return std::shared_ptr<GeomAPI_XYZ>(
54       new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
55 }
56
57 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
58 {
59   myLab = theLabel;
60   reinit();
61 }
62
63 void GeomData_Dir::reinit()
64 {
65   myIsInitialized = myLab.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
66   if (!myIsInitialized) {
67     // create attribute: not initialized by value yet, just zero
68     myCoords = TDataStd_RealArray::Set(myLab, 0, 2);
69   }
70 }