Salome HOME
Added CPP High API for FeaturesPlugin_Revolution
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Extrusion.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Extrusion.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Extrusion.h"
8
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
22                                              const ModelHighAPI_Double& theSize)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if(initialize()) {
26     fillAttribute(theBaseObjects, mybaseObjects);
27     setSizes(theSize, ModelHighAPI_Double());
28   }
29 }
30
31 //==================================================================================================
32 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
33                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
34                                              const ModelHighAPI_Selection& theDirection,
35                                              const ModelHighAPI_Double& theSize)
36 : ModelHighAPI_Interface(theFeature)
37 {
38   if(initialize()) {
39     fillAttribute(theBaseObjects, mybaseObjects);
40     fillAttribute(theDirection, mydirection);
41     setSizes(theSize, ModelHighAPI_Double());
42   }
43 }
44
45 //==================================================================================================
46 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
47                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
48                                              const ModelHighAPI_Double& theToSize,
49                                              const ModelHighAPI_Double& theFromSize)
50 : ModelHighAPI_Interface(theFeature)
51 {
52   if(initialize()) {
53     fillAttribute(theBaseObjects, mybaseObjects);
54     setSizes(theToSize, theFromSize);
55   }
56 }
57
58 //==================================================================================================
59 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
60                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
61                                              const ModelHighAPI_Selection& theDirection,
62                                              const ModelHighAPI_Double& theToSize,
63                                              const ModelHighAPI_Double& theFromSize)
64 : ModelHighAPI_Interface(theFeature)
65 {
66   if(initialize()) {
67     fillAttribute(theBaseObjects, mybaseObjects);
68     fillAttribute(theDirection, mydirection);
69     setSizes(theToSize, theFromSize);
70   }
71 }
72
73 //==================================================================================================
74 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
75                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
76                                              const ModelHighAPI_Selection& theToObject,
77                                              const ModelHighAPI_Double& theToOffset,
78                                              const ModelHighAPI_Selection& theFromObject,
79                                              const ModelHighAPI_Double& theFromOffset)
80 : ModelHighAPI_Interface(theFeature)
81 {
82   if(initialize()) {
83     fillAttribute(theBaseObjects, mybaseObjects);
84     setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
85   }
86 }
87
88 //==================================================================================================
89 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
90                                              const std::list<ModelHighAPI_Selection>& theBaseObjects,
91                                              const ModelHighAPI_Selection& theDirection,
92                                              const ModelHighAPI_Selection& theToObject,
93                                              const ModelHighAPI_Double& theToOffset,
94                                              const ModelHighAPI_Selection& theFromObject,
95                                              const ModelHighAPI_Double& theFromOffset)
96 : ModelHighAPI_Interface(theFeature)
97 {
98   if(initialize()) {
99     fillAttribute(theBaseObjects, mybaseObjects);
100     fillAttribute(theDirection, mydirection);
101     setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
102   }
103 }
104
105 //==================================================================================================
106 FeaturesAPI_Extrusion::~FeaturesAPI_Extrusion()
107 {
108
109 }
110
111 //==================================================================================================
112 void FeaturesAPI_Extrusion::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
113 {
114   fillAttribute(theBaseObjects, mybaseObjects);
115
116   execute();
117 }
118
119 //==================================================================================================
120 void FeaturesAPI_Extrusion::setDirection(const ModelHighAPI_Selection& theDirection)
121 {
122   fillAttribute(theDirection, mydirection);
123
124   execute();
125 }
126
127 //==================================================================================================
128 void FeaturesAPI_Extrusion::setSizes(const ModelHighAPI_Double& theToSize,
129                                      const ModelHighAPI_Double& theFromSize)
130 {
131   fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
132   fillAttribute(theToSize, mytoSize);
133   fillAttribute(theFromSize, myfromSize);
134
135   execute();
136 }
137
138 //==================================================================================================
139 void FeaturesAPI_Extrusion::setSize(const ModelHighAPI_Double& theSize)
140 {
141   fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
142   fillAttribute(theSize, mytoSize);
143   fillAttribute(ModelHighAPI_Double(), myfromSize);
144
145   execute();
146 }
147
148 //==================================================================================================
149 void FeaturesAPI_Extrusion::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
150                                                 const ModelHighAPI_Double& theToOffset,
151                                                 const ModelHighAPI_Selection& theFromObject,
152                                                 const ModelHighAPI_Double& theFromOffset)
153 {
154   fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
155   fillAttribute(theToObject, mytoObject);
156   fillAttribute(theToOffset, mytoOffset);
157   fillAttribute(theFromObject, myfromObject);
158   fillAttribute(theFromOffset, myfromOffset);
159
160   execute();
161 }
162
163 // TODO(spo): make add* as static functions of the class
164 //==================================================================================================
165 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
166                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
167                           const ModelHighAPI_Double& theSize)
168 {
169   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
170   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theSize));
171 }
172
173 //==================================================================================================
174 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
175                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
176                           const ModelHighAPI_Selection& theDirection,
177                           const ModelHighAPI_Double& theSize)
178 {
179   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
180   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theDirection, theSize));
181 }
182
183 //==================================================================================================
184 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
185                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
186                           const ModelHighAPI_Double& theToSize,
187                           const ModelHighAPI_Double& theFromSize)
188 {
189   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
190   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theToSize, theFromSize));
191 }
192
193 //==================================================================================================
194 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
195                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
196                           const ModelHighAPI_Selection& theDirection,
197                           const ModelHighAPI_Double& theToSize,
198                           const ModelHighAPI_Double& theFromSize)
199 {
200   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
201   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
202                                                 theBaseObjects,
203                                                 theDirection,
204                                                 theToSize,
205                                                 theFromSize));
206 }
207
208 //==================================================================================================
209 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
210                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
211                           const ModelHighAPI_Selection& theToObject,
212                           const ModelHighAPI_Double& theToOffset,
213                           const ModelHighAPI_Selection& theFromObject,
214                           const ModelHighAPI_Double& theFromOffset)
215 {
216   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
217   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
218                                                 theBaseObjects,
219                                                 theToObject,
220                                                 theToOffset,
221                                                 theFromObject,
222                                                 theFromOffset));
223 }
224
225 //==================================================================================================
226 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
227                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
228                           const ModelHighAPI_Selection& theDirection,
229                           const ModelHighAPI_Selection& theToObject,
230                           const ModelHighAPI_Double& theToOffset,
231                           const ModelHighAPI_Selection& theFromObject,
232                           const ModelHighAPI_Double& theFromOffset)
233 {
234   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
235   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
236                                                 theBaseObjects,
237                                                 theDirection,
238                                                 theToObject,
239                                                 theToOffset,
240                                                 theFromObject,
241                                                 theFromOffset));
242 }