Salome HOME
Temporary modification
[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     const std::shared_ptr<ModelAPI_Feature> & theFeature,
52     const ModelHighAPI_Double & theDX,
53     const ModelHighAPI_Double & theDY,
54     const ModelHighAPI_Double & theDZ)
55 : ModelHighAPI_Interface(theFeature)
56 {
57   if (initialize())
58     setDimensions(theDX, theDY, theDZ);
59 }
60
61 ConstructionAPI_Axis::~ConstructionAPI_Axis()
62 {
63
64 }
65
66 //--------------------------------------------------------------------------------------
67 void ConstructionAPI_Axis::setPoints(
68     const ModelHighAPI_Selection & thePoint1,
69     const ModelHighAPI_Selection & thePoint2)
70 {
71   fillAttribute("AxisByPointsCase", creationMethod());
72   fillAttribute(thePoint1, firstPoint());
73   fillAttribute(thePoint2, secondPoint());
74
75   execute();
76 }
77
78 void ConstructionAPI_Axis::setCylindricalFace(
79     const ModelHighAPI_Selection & theCylindricalFace)
80 {
81   fillAttribute("AxisByCylindricalFaceCase", creationMethod());
82   fillAttribute(theCylindricalFace, cylindricalFace());
83
84   execute();
85 }
86
87 void ConstructionAPI_Axis::setPointAndDirection(
88     const ModelHighAPI_Selection & thePoint,
89     const ModelHighAPI_Double & theX,
90     const ModelHighAPI_Double & theY,
91     const ModelHighAPI_Double & theZ)
92 {
93   fillAttribute("AxisByPointAndDirection", creationMethod());
94   fillAttribute(thePoint, firstPoint());
95   fillAttribute(theX, xDirection());
96   fillAttribute(theY, yDirection());
97   fillAttribute(theZ, zDirection());
98
99   execute();
100 }
101
102 void ConstructionAPI_Axis::setDimensions(
103     const ModelHighAPI_Double & theDX,
104     const ModelHighAPI_Double & theDY,
105     const ModelHighAPI_Double & theDZ)
106 {
107   fillAttribute("AxisByDimensionsCase", creationMethod());
108   fillAttribute(theDX, xDimension());
109   fillAttribute(theDY, yDimension());
110   fillAttribute(theDZ, zDimension());
111
112   execute();
113 }
114
115 //--------------------------------------------------------------------------------------
116 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
117                 const ModelHighAPI_Selection & thePoint1,
118                 const ModelHighAPI_Selection & thePoint2)
119 {
120   // TODO(spo): check that thePart is not empty
121   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
122   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
123 }
124
125 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
126                 const ModelHighAPI_Selection & theCylindricalFace)
127 {
128   // TODO(spo): check that thePart is not empty
129   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
130   return AxisPtr(new ConstructionAPI_Axis(aFeature, theCylindricalFace));
131 }
132
133 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
134                 const ModelHighAPI_Selection & thePoint,
135                 const ModelHighAPI_Double & theX,
136                 const ModelHighAPI_Double & theY,
137                 const ModelHighAPI_Double & theZ)
138 {
139   // TODO(spo): check that thePart is not empty
140   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
141   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
142 }
143
144 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
145                 const ModelHighAPI_Double & theDX,
146                 const ModelHighAPI_Double & theDY,
147                 const ModelHighAPI_Double & theDZ)
148 {
149   // TODO(spo): check that thePart is not empty
150   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
151   return AxisPtr(new ConstructionAPI_Axis(aFeature, theDX, theDY, theDZ));
152 }