Salome HOME
Use ID() static functions of ConstructionAPI_Plane & ConstructionAPI_Point in add...
[modules/shaper.git] / src / ConstructionAPI / ConstructionAPI_Point.cpp
1 // Name   : ConstructionAPI_Point.cpp
2 // Purpose: 
3 //
4 // History:
5 // 29/03/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ConstructionAPI_Point.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelAPI_AttributeDouble.h>
11 #include <ModelAPI_Document.h>
12 #include <ModelAPI_Feature.h>
13
14 #include <ModelHighAPI_Double.h>
15 //--------------------------------------------------------------------------------------
16 ConstructionAPI_Point::ConstructionAPI_Point(
17     const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : ModelHighAPI_Interface(theFeature)
19 {
20   initialize();
21 }
22
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)
29 {
30   if (initialize())
31     setPoint(theX, theY, theZ);
32 }
33
34 ConstructionAPI_Point::~ConstructionAPI_Point()
35 {
36
37 }
38
39 //--------------------------------------------------------------------------------------
40 void ConstructionAPI_Point::setPoint(const ModelHighAPI_Double & theX,
41                                      const ModelHighAPI_Double & theY,
42                                      const ModelHighAPI_Double & theZ)
43 {
44   theX.fillAttribute(myx);
45   theY.fillAttribute(myy);
46   theZ.fillAttribute(myz);
47
48   execute();
49 }
50
51 //--------------------------------------------------------------------------------------
52 // TODO(spo): make add* as static functions of the class
53 PointPtr addPoint(
54     const std::shared_ptr<ModelAPI_Document> & thePart,
55     const ModelHighAPI_Double& theX,
56     const ModelHighAPI_Double& theY,
57     const ModelHighAPI_Double& theZ)
58 {
59   // TODO(spo): check that thePart is not empty
60   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Point::ID());
61   return PointPtr(new ConstructionAPI_Point(aFeature, theX, theY, theZ));
62 }