]> SALOME platform Git repositories - modules/shaper.git/blob - src/GeomData/GeomData_Point2D.cpp
Salome HOME
Merge branch 'Dev_0.6.1' of newgeom:newgeom into Dev_0.6.1
[modules/shaper.git] / src / GeomData / GeomData_Point2D.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2
3 // File:        GeomData_Point2D.cxx
4 // Created:     24 Apr 2014
5 // Author:      Mikhail PONIKAROV
6
7 #include "GeomData_Point2D.h"
8 #include <GeomAPI_Pnt2d.h>
9 #include <ModelAPI_Feature.h>
10 #include <ModelAPI_Data.h>
11
12 using namespace std;
13
14 void GeomData_Point2D::setValue(const double theX, const double theY)
15 {
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);
20   }
21 }
22
23 void GeomData_Point2D::setValue(const std::shared_ptr<GeomAPI_Pnt2d>& thePoint)
24 {
25   setValue(thePoint->x(), thePoint->y());
26 }
27
28 double GeomData_Point2D::x() const
29 {
30   return myCoords->Value(0);
31 }
32
33 double GeomData_Point2D::y() const
34 {
35   return myCoords->Value(1);
36 }
37
38 std::shared_ptr<GeomAPI_Pnt2d> GeomData_Point2D::pnt()
39 {
40   std::shared_ptr<GeomAPI_Pnt2d> aResult(
41       new GeomAPI_Pnt2d(myCoords->Value(0), myCoords->Value(1)));
42   return aResult;
43 }
44
45 GeomData_Point2D::GeomData_Point2D(TDF_Label& theLabel)
46 {
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);
51   }
52 }