]> SALOME platform Git repositories - modules/shaper.git/blob - src/ConstructionAPI/ConstructionAPI_Axis.cpp
Salome HOME
Add ConstructionAPI_Axis
[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 // TODO(spo): make add* as static functions of the class
93
94 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
95                 const ModelHighAPI_Selection & thePoint1,
96                 const ModelHighAPI_Selection & thePoint2)
97 {
98   // TODO(spo): check that thePart is not empty
99   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
100   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint1, thePoint2));
101 }
102
103 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
104                 const ModelHighAPI_Selection & theCylindricalFace)
105 {
106   // TODO(spo): check that thePart is not empty
107   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
108   return AxisPtr(new ConstructionAPI_Axis(aFeature, theCylindricalFace));
109 }
110
111 AxisPtr addAxis(const std::shared_ptr<ModelAPI_Document> & thePart,
112                 const ModelHighAPI_Selection & thePoint,
113                 const ModelHighAPI_Double & theX,
114                 const ModelHighAPI_Double & theY,
115                 const ModelHighAPI_Double & theZ)
116 {
117   // TODO(spo): check that thePart is not empty
118   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ConstructionAPI_Axis::ID());
119   return AxisPtr(new ConstructionAPI_Axis(aFeature, thePoint, theX, theY, theZ));
120 }