Salome HOME
Added CPP High API for FeaturesPlugin_Revolution
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Revolution.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Revolution.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Revolution.h"
8
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                                const std::list<ModelHighAPI_Selection>& theBaseObjects,
22                                                const ModelHighAPI_Selection& theAxis,
23                                                const ModelHighAPI_Double& theAngle)
24 : ModelHighAPI_Interface(theFeature)
25 {
26   if(initialize()) {
27     fillAttribute(theBaseObjects, mybaseObjects);
28     fillAttribute(theAxis, myaxis);
29     setAngles(theAngle, ModelHighAPI_Double());
30   }
31 }
32
33 //==================================================================================================
34 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35                                                const std::list<ModelHighAPI_Selection>& theBaseObjects,
36                                                const ModelHighAPI_Selection& theAxis,
37                                                const ModelHighAPI_Double& theToAngle,
38                                                const ModelHighAPI_Double& theFromAngle)
39 : ModelHighAPI_Interface(theFeature)
40 {
41   if(initialize()) {
42     fillAttribute(theBaseObjects, mybaseObjects);
43     fillAttribute(theAxis, myaxis);
44     setAngles(theToAngle, theFromAngle);
45   }
46 }
47
48 //==================================================================================================
49 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
50                                                const std::list<ModelHighAPI_Selection>& theBaseObjects,
51                                                const ModelHighAPI_Selection& theAxis,
52                                                const ModelHighAPI_Selection& theToObject,
53                                                const ModelHighAPI_Double& theToOffset,
54                                                const ModelHighAPI_Selection& theFromObject,
55                                                const ModelHighAPI_Double& theFromOffset)
56 : ModelHighAPI_Interface(theFeature)
57 {
58   if(initialize()) {
59     fillAttribute(theBaseObjects, mybaseObjects);
60     fillAttribute(theAxis, myaxis);
61     setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
62   }
63 }
64
65 //==================================================================================================
66 FeaturesAPI_Revolution::~FeaturesAPI_Revolution()
67 {
68
69 }
70
71 //==================================================================================================
72 void FeaturesAPI_Revolution::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
73 {
74   fillAttribute(theBaseObjects, mybaseObjects);
75
76   execute();
77 }
78
79 //==================================================================================================
80 void FeaturesAPI_Revolution::setAxis(const ModelHighAPI_Selection& theAxis)
81 {
82   fillAttribute(theAxis, myaxis);
83
84   execute();
85 }
86
87 //==================================================================================================
88 void FeaturesAPI_Revolution::setAngles(const ModelHighAPI_Double& theToAngle,
89                                        const ModelHighAPI_Double& theFromAngle)
90 {
91   fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
92   fillAttribute(theToAngle, mytoAngle);
93   fillAttribute(theFromAngle, myfromAngle);
94
95   execute();
96 }
97
98 //==================================================================================================
99 void FeaturesAPI_Revolution::setAngle(const ModelHighAPI_Double& theAngle)
100 {
101   fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
102   fillAttribute(theAngle, mytoAngle);
103   fillAttribute(ModelHighAPI_Double(), myfromAngle);
104
105   execute();
106 }
107
108 //==================================================================================================
109 void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
110                                                 const ModelHighAPI_Double& theToOffset,
111                                                 const ModelHighAPI_Selection& theFromObject,
112                                                 const ModelHighAPI_Double& theFromOffset)
113 {
114   fillAttribute("ByPlanesAndOffsets", mycreationMethod);
115   fillAttribute(theToObject, mytoObject);
116   fillAttribute(theToOffset, mytoOffset);
117   fillAttribute(theFromObject, myfromObject);
118   fillAttribute(theFromOffset, myfromOffset);
119
120   execute();
121 }
122
123 // TODO(spo): make add* as static functions of the class
124 //==================================================================================================
125 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
126                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
127                             const ModelHighAPI_Selection& theAxis,
128                             const ModelHighAPI_Double& theAngle)
129 {
130   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
131   return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theAngle));
132 }
133
134 //==================================================================================================
135 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
136                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
137                             const ModelHighAPI_Selection& theAxis,
138                             const ModelHighAPI_Double& theToAngle,
139                             const ModelHighAPI_Double& theFromAngle)
140 {
141   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
142   return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
143                                                 theBaseObjects,
144                                                 theAxis,
145                                                 theToAngle,
146                                                 theFromAngle));
147 }
148
149 //==================================================================================================
150 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
151                             const std::list<ModelHighAPI_Selection>& theBaseObjects,
152                             const ModelHighAPI_Selection& theAxis,
153                             const ModelHighAPI_Selection& theToObject,
154                             const ModelHighAPI_Double& theToOffset,
155                             const ModelHighAPI_Selection& theFromObject,
156                             const ModelHighAPI_Double& theFromOffset)
157 {
158   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
159   return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
160                                                 theBaseObjects,
161                                                 theAxis,
162                                                 theToObject,
163                                                 theToOffset,
164                                                 theFromObject,
165                                                 theFromOffset));
166 }