1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomData_Dir.cxx
5 // Author: Mikhail PONIKAROV
7 #include "GeomData_Dir.h"
8 #include <GeomAPI_Dir.h>
9 #include <GeomAPI_XYZ.h>
11 #include <ModelAPI_Feature.h>
12 #include <ModelAPI_Data.h>
14 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
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);
25 void GeomData_Dir::setValue(const std::shared_ptr<GeomAPI_Dir>& theDir)
27 setValue(theDir->x(), theDir->y(), theDir->z());
30 double GeomData_Dir::x() const
32 return myCoords->Value(0);
35 double GeomData_Dir::y() const
37 return myCoords->Value(1);
40 double GeomData_Dir::z() const
42 return myCoords->Value(2);
45 std::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
47 return std::shared_ptr<GeomAPI_Dir>(
48 new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
51 std::shared_ptr<GeomAPI_XYZ> GeomData_Dir::xyz()
53 return std::shared_ptr<GeomAPI_XYZ>(
54 new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
57 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
63 void GeomData_Dir::reinit()
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);