1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomData_Point.cxx
4 // Created: 24 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #include "GeomData_Point.h"
8 #include <GeomAPI_Pnt.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
14 void GeomData_Point::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_Point::setValue(const std::shared_ptr<GeomAPI_Pnt>& thePoint)
27 setValue(thePoint->x(), thePoint->y(), thePoint->z());
30 double GeomData_Point::x() const
32 return myCoords->Value(0);
35 double GeomData_Point::y() const
37 return myCoords->Value(1);
40 double GeomData_Point::z() const
42 return myCoords->Value(2);
45 std::shared_ptr<GeomAPI_Pnt> GeomData_Point::pnt()
47 std::shared_ptr<GeomAPI_Pnt> aResult(
48 new GeomAPI_Pnt(myCoords->Value(0), myCoords->Value(1), myCoords->Value(2)));
52 GeomData_Point::GeomData_Point(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);