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"
10 #include <ModelAPI_Feature.h>
11 #include <ModelAPI_Data.h>
15 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
17 if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
18 || myCoords->Value(2) != theZ) {
19 myCoords->SetValue(0, theX);
20 myCoords->SetValue(1, theY);
21 myCoords->SetValue(2, theZ);
22 owner()->data()->sendAttributeUpdated(this);
26 void GeomData_Dir::setValue(const std::shared_ptr<GeomAPI_Dir>& theDir)
28 setValue(theDir->x(), theDir->y(), theDir->z());
31 double GeomData_Dir::x() const
33 return myCoords->Value(0);
36 double GeomData_Dir::y() const
38 return myCoords->Value(1);
41 double GeomData_Dir::z() const
43 return myCoords->Value(2);
46 std::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
48 return std::shared_ptr<GeomAPI_Dir>(
49 new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
52 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
54 myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
55 if (!myIsInitialized) {
56 // create attribute: not initialized by value yet, just zero
57 myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);