1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: GeomData_Point2D.cxx
4 // Created: 24 Apr 2014
5 // Author: Mikhail PONIKAROV
7 #include "GeomData_Point2D.h"
8 #include <GeomAPI_Pnt2d.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
14 void GeomData_Point2D::setValue(const double theX, const double theY)
16 if (myCoords->Value(0) != theX || myCoords->Value(1) != theY) {
17 myCoords->SetValue(0, theX);
18 myCoords->SetValue(1, theY);
19 owner()->data()->sendAttributeUpdated(this);
23 void GeomData_Point2D::setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
25 setValue(thePoint->x(), thePoint->y());
28 double GeomData_Point2D::x() const
30 return myCoords->Value(0);
33 double GeomData_Point2D::y() const
35 return myCoords->Value(1);
38 std::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
40 std::shared_ptr<GeomAPI_Pnt2d> aResult(
41 new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
45 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
47 myIsInitialized = theLabel.FindAttribute(TDataStd_RealArray::GetID(), myCoords) == Standard_True;
48 if (!myIsInitialized) {
49 // create attribute: not initialized by value yet, just zero
50 myCoords = TDataStd_RealArray::Set(theLabel, 0, 1);