Salome HOME
352320e1d9a8b551a90e899fcef929eeab73c12b
[modules/shaper.git] / src / ConstructionAPI / ConstructionAPI_Axis.cpp
1 // Name   : ConstructionAPI_Axis.cpp
2 // Purpose: 
3 //
4 // History:
5 // 15/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ConstructionAPI_Axis.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Tools.h>
11 //--------------------------------------------------------------------------------------
12 ConstructionAPI_Axis::ConstructionAPI_Axis(
13     const std::shared_ptr<ModelAPI_Feature> & theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 ConstructionAPI_Axis::ConstructionAPI_Axis(
20     const std::shared_ptr<ModelAPI_Feature> & theFeature,
21     const ModelHighAPI_Selection & thePoint1,
22     const ModelHighAPI_Selection & thePoint2)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if (initialize())
26     setPoints(thePoint1, thePoint2);
27 }
28
29 ConstructionAPI_Axis::ConstructionAPI_Axis(
30     const std::shared_ptr<ModelAPI_Feature> & theFeature,
31     const ModelHighAPI_Selection & theCylindricalFace)
32 : ModelHighAPI_Interface(theFeature)
33 {
34   if (initialize())
35     setCylindricalFace(theCylindricalFace);
36 }
37
38 ConstructionAPI_Axis::ConstructionAPI_Axis(
39     const std::shared_ptr<ModelAPI_Feature> & theFeature,
40     const ModelHighAPI_Selection & thePoint,
41     const ModelHighAPI_Double & theX,
42     const ModelHighAPI_Double & theY,
43     const ModelHighAPI_Double & theZ)
44 : ModelHighAPI_Interface(theFeature)
45 {
46   if (initialize())
47     setPointAndDirection(thePoint, theX, theY, theZ);
48 }
49
50 ConstructionAPI_Axis::~ConstructionAPI_Axis()
51 {
52
53 }
54
55 //--------------------------------------------------------------------------------------
56 void ConstructionAPI_Axis::setPoints(
57     const ModelHighAPI_Selection & thePoint1,
58     const ModelHighAPI_Selection & thePoint2)
59 {
60   fillAttribute("AxisByPointsCase", creationMethod());
61   fillAttribute(thePoint1, firstPoint());
62   fillAttribute(thePoint2, secondPoint());
63
64   execute();
65 }
66
67 void ConstructionAPI_Axis::setCylindricalFace(
68     const ModelHighAPI_Selection & theCylindricalFace)
69 {
70   fillAttribute("AxisByCylindricalFaceCase", creationMethod());
71   fillAttribute(theCylindricalFace, cylindricalFace());
72
73   execute();
74 }
75
76 void ConstructionAPI_Axis::setPointAndDirection(
77     const ModelHighAPI_Selection & thePoint,
78     const ModelHighAPI_Double & theX,
79     const ModelHighAPI_Double & theY,
80     const ModelHighAPI_Double & theZ)
81 {
82   fillAttribute("AxisByPointAndDirection", creationMethod());
83   fillAttribute(thePoint, firstPoint());
84   fillAttribute(theX, xDirection());
85   fillAttribute(theY, yDirection());
86   fillAttribute(theZ, zDirection());
87
88   execute();
89 }
90
91 //--------------------------------------------------------------------------------------
92 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
93                 const ModelHighAPI_Selection & thePoint1,
94                 const ModelHighAPI_Selection & thePoint2)
95 {
96   // TODO(spo): check that thePart is not empty
97   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
98   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
99 }
100
101 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
102                 const ModelHighAPI_Selection & theCylindricalFace)
103 {
104   // TODO(spo): check that thePart is not empty
105   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
106   return AxisPtr(new ConstructionAPI_Axis(aFeature, theCylindricalFace));
107 }
108
109 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
110                 const ModelHighAPI_Selection & thePoint,
111                 const ModelHighAPI_Double & theX,
112                 const ModelHighAPI_Double & theY,
113                 const ModelHighAPI_Double & theZ)
114 {
115   // TODO(spo): check that thePart is not empty
116   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
117   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
118 }