1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Extrusion.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Extrusion.h"
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const std::list<ModelHighAPI_Selection>& theBaseObjects,
23 const ModelHighAPI_Double& theSize)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theBaseObjects, mybaseObjects);
28 setSizes(theSize, ModelHighAPI_Double());
32 //==================================================================================================
33 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
34 const std::list<ModelHighAPI_Selection>& theBaseObjects,
35 const ModelHighAPI_Selection& theDirection,
36 const ModelHighAPI_Double& theSize)
37 : ModelHighAPI_Interface(theFeature)
40 fillAttribute(theBaseObjects, mybaseObjects);
41 fillAttribute(theDirection, mydirection);
42 setSizes(theSize, ModelHighAPI_Double());
46 //==================================================================================================
47 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
48 const std::list<ModelHighAPI_Selection>& theBaseObjects,
49 const ModelHighAPI_Double& theToSize,
50 const ModelHighAPI_Double& theFromSize)
51 : ModelHighAPI_Interface(theFeature)
54 fillAttribute(theBaseObjects, mybaseObjects);
55 setSizes(theToSize, theFromSize);
59 //==================================================================================================
60 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
61 const std::list<ModelHighAPI_Selection>& theBaseObjects,
62 const ModelHighAPI_Selection& theDirection,
63 const ModelHighAPI_Double& theToSize,
64 const ModelHighAPI_Double& theFromSize)
65 : ModelHighAPI_Interface(theFeature)
68 fillAttribute(theBaseObjects, mybaseObjects);
69 fillAttribute(theDirection, mydirection);
70 setSizes(theToSize, theFromSize);
74 //==================================================================================================
75 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
76 const std::list<ModelHighAPI_Selection>& theBaseObjects,
77 const ModelHighAPI_Selection& theToObject,
78 const ModelHighAPI_Double& theToOffset,
79 const ModelHighAPI_Selection& theFromObject,
80 const ModelHighAPI_Double& theFromOffset)
81 : ModelHighAPI_Interface(theFeature)
84 fillAttribute(theBaseObjects, mybaseObjects);
85 setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
89 //==================================================================================================
90 FeaturesAPI_Extrusion::FeaturesAPI_Extrusion(const std::shared_ptr<ModelAPI_Feature>& theFeature,
91 const std::list<ModelHighAPI_Selection>& theBaseObjects,
92 const ModelHighAPI_Selection& theDirection,
93 const ModelHighAPI_Selection& theToObject,
94 const ModelHighAPI_Double& theToOffset,
95 const ModelHighAPI_Selection& theFromObject,
96 const ModelHighAPI_Double& theFromOffset)
97 : ModelHighAPI_Interface(theFeature)
100 fillAttribute(theBaseObjects, mybaseObjects);
101 fillAttribute(theDirection, mydirection);
102 setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
106 //==================================================================================================
107 FeaturesAPI_Extrusion::~FeaturesAPI_Extrusion()
112 //==================================================================================================
113 void FeaturesAPI_Extrusion::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
115 fillAttribute(theBaseObjects, mybaseObjects);
120 //==================================================================================================
121 void FeaturesAPI_Extrusion::setDirection(const ModelHighAPI_Selection& theDirection)
123 fillAttribute(theDirection, mydirection);
128 //==================================================================================================
129 void FeaturesAPI_Extrusion::setSizes(const ModelHighAPI_Double& theToSize,
130 const ModelHighAPI_Double& theFromSize)
132 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
133 fillAttribute(theToSize, mytoSize);
134 fillAttribute(theFromSize, myfromSize);
139 //==================================================================================================
140 void FeaturesAPI_Extrusion::setSize(const ModelHighAPI_Double& theSize)
142 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES(), mycreationMethod);
143 fillAttribute(theSize, mytoSize);
144 fillAttribute(ModelHighAPI_Double(), myfromSize);
149 //==================================================================================================
150 void FeaturesAPI_Extrusion::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
151 const ModelHighAPI_Double& theToOffset,
152 const ModelHighAPI_Selection& theFromObject,
153 const ModelHighAPI_Double& theFromOffset)
155 fillAttribute(FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES(), mycreationMethod);
156 fillAttribute(theToObject, mytoObject);
157 fillAttribute(theToOffset, mytoOffset);
158 fillAttribute(theFromObject, myfromObject);
159 fillAttribute(theFromOffset, myfromOffset);
164 //==================================================================================================
165 void FeaturesAPI_Extrusion::dump(ModelHighAPI_Dumper& theDumper) const
167 FeaturePtr aBase = feature();
168 const std::string& aDocName = theDumper.name(aBase->document());
170 AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Extrusion::BASE_OBJECTS_ID());
171 AttributeSelectionPtr aDirection = aBase->selection(FeaturesPlugin_Extrusion::DIRECTION_OBJECT_ID());
173 theDumper << aBase << " = model.addExtrusion(" << aDocName << ", " << anObjects << ", " << aDirection;
175 std::string aCreationMethod = aBase->string(FeaturesPlugin_Extrusion::CREATION_METHOD())->value();
177 if(aCreationMethod == FeaturesPlugin_Extrusion::CREATION_METHOD_BY_SIZES()) {
178 AttributeDoublePtr anAttrToSize = aBase->real(FeaturesPlugin_Extrusion::TO_SIZE_ID());
179 AttributeDoublePtr anAttrFromSize = aBase->real(FeaturesPlugin_Extrusion::FROM_SIZE_ID());
181 theDumper << ", " << anAttrToSize << ", " << anAttrFromSize;
182 } else if(aCreationMethod == FeaturesPlugin_Extrusion::CREATION_METHOD_BY_PLANES()) {
183 AttributeSelectionPtr anAttrToObject = aBase->selection(FeaturesPlugin_Extrusion::TO_OBJECT_ID());
184 AttributeDoublePtr anAttrToOffset = aBase->real(FeaturesPlugin_Extrusion::TO_OFFSET_ID());
185 AttributeSelectionPtr anAttrFromObject = aBase->selection(FeaturesPlugin_Extrusion::FROM_OBJECT_ID());
186 AttributeDoublePtr anAttrFromOffset = aBase->real(FeaturesPlugin_Extrusion::FROM_OFFSET_ID());
188 theDumper << ", " << anAttrToObject << ", " << anAttrToOffset << ", " << anAttrFromObject << ", " << anAttrFromOffset;
191 theDumper << ")" << std::endl;
194 //==================================================================================================
195 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
196 const std::list<ModelHighAPI_Selection>& theBaseObjects,
197 const ModelHighAPI_Double& theSize)
199 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
200 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theSize));
203 //==================================================================================================
204 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
205 const std::list<ModelHighAPI_Selection>& theBaseObjects,
206 const ModelHighAPI_Selection& theDirection,
207 const ModelHighAPI_Double& theSize)
209 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
210 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theDirection, theSize));
213 //==================================================================================================
214 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
215 const std::list<ModelHighAPI_Selection>& theBaseObjects,
216 const ModelHighAPI_Double& theToSize,
217 const ModelHighAPI_Double& theFromSize)
219 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
220 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature, theBaseObjects, theToSize, theFromSize));
223 //==================================================================================================
224 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
225 const std::list<ModelHighAPI_Selection>& theBaseObjects,
226 const ModelHighAPI_Selection& theDirection,
227 const ModelHighAPI_Double& theToSize,
228 const ModelHighAPI_Double& theFromSize)
230 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
231 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
238 //==================================================================================================
239 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
240 const std::list<ModelHighAPI_Selection>& theBaseObjects,
241 const ModelHighAPI_Selection& theToObject,
242 const ModelHighAPI_Double& theToOffset,
243 const ModelHighAPI_Selection& theFromObject,
244 const ModelHighAPI_Double& theFromOffset)
246 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
247 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,
255 //==================================================================================================
256 ExtrusionPtr addExtrusion(const std::shared_ptr<ModelAPI_Document>& thePart,
257 const std::list<ModelHighAPI_Selection>& theBaseObjects,
258 const ModelHighAPI_Selection& theDirection,
259 const ModelHighAPI_Selection& theToObject,
260 const ModelHighAPI_Double& theToOffset,
261 const ModelHighAPI_Selection& theFromObject,
262 const ModelHighAPI_Double& theFromOffset)
264 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Extrusion::ID());
265 return ExtrusionPtr(new FeaturesAPI_Extrusion(aFeature,