1 // Name : ConstructionAPI_Point.cpp
5 // 29/03/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ConstructionAPI_Point.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelAPI_AttributeDouble.h>
11 #include <ModelAPI_Document.h>
12 #include <ModelAPI_Feature.h>
14 #include <ModelHighAPI_Double.h>
15 //--------------------------------------------------------------------------------------
16 ConstructionAPI_Point::ConstructionAPI_Point(
17 const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : ModelHighAPI_Interface(theFeature)
23 ConstructionAPI_Point::ConstructionAPI_Point(
24 const std::shared_ptr<ModelAPI_Feature> & theFeature,
25 const ModelHighAPI_Double & theX,
26 const ModelHighAPI_Double & theY,
27 const ModelHighAPI_Double & theZ)
28 : ModelHighAPI_Interface(theFeature)
31 setPoint(theX, theY, theZ);
36 ConstructionAPI_Point::~ConstructionAPI_Point()
41 //--------------------------------------------------------------------------------------
42 bool ConstructionAPI_Point::initialize()
45 throwException("ConstructionAPI_Point exception: The feature is NULL.");
49 if (feature()->getKind() != "Point") {
50 throwException("ConstructionAPI_Point exception: Wrong feature kind.");
54 // data() throws exceptions if the attribute is invalid
55 myX = feature()->real("x");
56 myY = feature()->real("y");
57 myZ = feature()->real("z");
59 if (!myX || !myY || !myZ)
65 //--------------------------------------------------------------------------------------
66 void ConstructionAPI_Point::setPoint(const ModelHighAPI_Double & theX,
67 const ModelHighAPI_Double & theY,
68 const ModelHighAPI_Double & theZ)
70 theX.fillAttribute(myX);
71 theY.fillAttribute(myY);
72 theZ.fillAttribute(myZ);
75 //--------------------------------------------------------------------------------------
76 std::shared_ptr<ModelAPI_AttributeDouble> ConstructionAPI_Point::x() const
80 std::shared_ptr<ModelAPI_AttributeDouble> ConstructionAPI_Point::y() const
84 std::shared_ptr<ModelAPI_AttributeDouble> ConstructionAPI_Point::z() const
89 //--------------------------------------------------------------------------------------
90 // TODO(spo): make add* as static functions of the class
92 std::shared_ptr<ModelAPI_Document> thePart,
93 const ModelHighAPI_Double& theX,
94 const ModelHighAPI_Double& theY,
95 const ModelHighAPI_Double& theZ)
97 // TODO(spo): check that thePart is not empty
98 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature("Point");
99 return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));