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>
16 void GeomData_Dir::setValue(const double theX, const double theY, const double theZ)
18 if (!myIsInitialized || myCoords->Value(0) != theX || myCoords->Value(1) != theY
19 || myCoords->Value(2) != theZ) {
20 myCoords->SetValue(0, theX);
21 myCoords->SetValue(1, theY);
22 myCoords->SetValue(2, theZ);
23 owner()->data()->sendAttributeUpdated(this);
27 void GeomData_Dir::setValue(const std::shared_ptr<GeomAPI_Dir>& theDir)
29 setValue(theDir->x(), theDir->y(), theDir->z());
32 double GeomData_Dir::x() const
34 return myCoords->Value(0);
37 double GeomData_Dir::y() const
39 return myCoords->Value(1);
42 double GeomData_Dir::z() const
44 return myCoords->Value(2);
47 std::shared_ptr<GeomAPI_Dir> GeomData_Dir::dir()
49 return std::shared_ptr<GeomAPI_Dir>(
50 new GeomAPI_Dir(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
53 std::shared_ptr<GeomAPI_XYZ> GeomData_Dir::xyz()
55 return std::shared_ptr<GeomAPI_XYZ>(
56 new GeomAPI_XYZ(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
59 GeomData_Dir::GeomData_Dir(TDF_Label& theLabel)
61 myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
62 if (!myIsInitialized) {
63 // create attribute: not initialized by value yet, just zero
64 myCoords = TDataStd_RealArray::Set(theLabel, 0, 2);