Salome HOME
Remove some TODOs
[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 //==================================================================================================
164 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
165                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
166                           const ModelHighAPI_Double& theSize)
167 {
168   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
169   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theSize));
170 }
171
172 //==================================================================================================
173 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
174                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
175                           const ModelHighAPI_Selection& theDirection,
176                           const ModelHighAPI_Double& theSize)
177 {
178   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
179   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theDirection, theSize));
180 }
181
182 //==================================================================================================
183 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
184                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
185                           const ModelHighAPI_Double& theToSize,
186                           const ModelHighAPI_Double& theFromSize)
187 {
188   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
189   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theToSize, theFromSize));
190 }
191
192 //==================================================================================================
193 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
194                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
195                           const ModelHighAPI_Selection& theDirection,
196                           const ModelHighAPI_Double& theToSize,
197                           const ModelHighAPI_Double& theFromSize)
198 {
199   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
200   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
201                                                 theBaseObjects,
202                                                 theDirection,
203                                                 theToSize,
204                                                 theFromSize));
205 }
206
207 //==================================================================================================
208 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
209                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
210                           const ModelHighAPI_Selection& theToObject,
211                           const ModelHighAPI_Double& theToOffset,
212                           const ModelHighAPI_Selection& theFromObject,
213                           const ModelHighAPI_Double& theFromOffset)
214 {
215   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
216   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
217                                                 theBaseObjects,
218                                                 theToObject,
219                                                 theToOffset,
220                                                 theFromObject,
221                                                 theFromOffset));
222 }
223
224 //==================================================================================================
225 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
226                           const std::list<ModelHighAPI_Selection>& theBaseObjects,
227                           const ModelHighAPI_Selection& theDirection,
228                           const ModelHighAPI_Selection& theToObject,
229                           const ModelHighAPI_Double& theToOffset,
230                           const ModelHighAPI_Selection& theFromObject,
231                           const ModelHighAPI_Double& theFromOffset)
232 {
233   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
234   return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
235                                                 theBaseObjects,
236                                                 theDirection,
237                                                 theToObject,
238                                                 theToOffset,
239                                                 theFromObject,
240                                                 theFromOffset));
241 }