1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Revolution.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Revolution.h"
9 #include <ModelHighAPI_Double.h>
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const std::list<ModelHighAPI_Selection>& theBaseObjects,
23 const ModelHighAPI_Selection& theAxis,
24 const ModelHighAPI_Double& theAngle)
25 : ModelHighAPI_Interface(theFeature)
28 fillAttribute(theBaseObjects, mybaseObjects);
29 fillAttribute(theAxis, myaxis);
30 setAngles(theAngle, ModelHighAPI_Double());
34 //==================================================================================================
35 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
36 const std::list<ModelHighAPI_Selection>& theBaseObjects,
37 const ModelHighAPI_Selection& theAxis,
38 const ModelHighAPI_Double& theToAngle,
39 const ModelHighAPI_Double& theFromAngle)
40 : ModelHighAPI_Interface(theFeature)
43 fillAttribute(theBaseObjects, mybaseObjects);
44 fillAttribute(theAxis, myaxis);
45 setAngles(theToAngle, theFromAngle);
49 //==================================================================================================
50 FeaturesAPI_Revolution::FeaturesAPI_Revolution(const std::shared_ptr<ModelAPI_Feature>& theFeature,
51 const std::list<ModelHighAPI_Selection>& theBaseObjects,
52 const ModelHighAPI_Selection& theAxis,
53 const ModelHighAPI_Selection& theToObject,
54 const ModelHighAPI_Double& theToOffset,
55 const ModelHighAPI_Selection& theFromObject,
56 const ModelHighAPI_Double& theFromOffset)
57 : ModelHighAPI_Interface(theFeature)
60 fillAttribute(theBaseObjects, mybaseObjects);
61 fillAttribute(theAxis, myaxis);
62 setPlanesAndOffsets(theToObject, theToOffset, theFromObject, theFromOffset);
66 //==================================================================================================
67 FeaturesAPI_Revolution::~FeaturesAPI_Revolution()
72 //==================================================================================================
73 void FeaturesAPI_Revolution::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
75 fillAttribute(theBaseObjects, mybaseObjects);
80 //==================================================================================================
81 void FeaturesAPI_Revolution::setAxis(const ModelHighAPI_Selection& theAxis)
83 fillAttribute(theAxis, myaxis);
88 //==================================================================================================
89 void FeaturesAPI_Revolution::setAngles(const ModelHighAPI_Double& theToAngle,
90 const ModelHighAPI_Double& theFromAngle)
92 fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
93 fillAttribute(theToAngle, mytoAngle);
94 fillAttribute(theFromAngle, myfromAngle);
99 //==================================================================================================
100 void FeaturesAPI_Revolution::setAngle(const ModelHighAPI_Double& theAngle)
102 fillAttribute(FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES(), mycreationMethod);
103 fillAttribute(theAngle, mytoAngle);
104 fillAttribute(ModelHighAPI_Double(), myfromAngle);
109 //==================================================================================================
110 void FeaturesAPI_Revolution::setPlanesAndOffsets(const ModelHighAPI_Selection& theToObject,
111 const ModelHighAPI_Double& theToOffset,
112 const ModelHighAPI_Selection& theFromObject,
113 const ModelHighAPI_Double& theFromOffset)
115 fillAttribute("ByPlanesAndOffsets", mycreationMethod);
116 fillAttribute(theToObject, mytoObject);
117 fillAttribute(theToOffset, mytoOffset);
118 fillAttribute(theFromObject, myfromObject);
119 fillAttribute(theFromOffset, myfromOffset);
124 //==================================================================================================
125 void FeaturesAPI_Revolution::dump(ModelHighAPI_Dumper& theDumper) const
127 FeaturePtr aBase = feature();
128 const std::string& aDocName = theDumper.name(aBase->document());
130 AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Revolution::BASE_OBJECTS_ID());
131 AttributeSelectionPtr anAxis = aBase->selection(FeaturesPlugin_Revolution::AXIS_OBJECT_ID());
133 theDumper << aBase << " = model.addRevolution(" << aDocName << ", " << anObjects << ", " << anAxis;
135 std::string aCreationMethod = aBase->string(FeaturesPlugin_Revolution::CREATION_METHOD())->value();
137 if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_ANGLES()) {
138 AttributeDoublePtr anAttrToAngle = aBase->real(FeaturesPlugin_Revolution::TO_ANGLE_ID());
139 AttributeDoublePtr anAttrFromAngle = aBase->real(FeaturesPlugin_Revolution::FROM_ANGLE_ID());
141 theDumper << ", " << anAttrToAngle << ", " << anAttrFromAngle;
142 } else if(aCreationMethod == FeaturesPlugin_Revolution::CREATION_METHOD_BY_PLANES()) {
143 AttributeSelectionPtr anAttrToObject = aBase->selection(FeaturesPlugin_Revolution::TO_OBJECT_ID());
144 AttributeDoublePtr anAttrToOffset = aBase->real(FeaturesPlugin_Revolution::TO_OFFSET_ID());
145 AttributeSelectionPtr anAttrFromObject = aBase->selection(FeaturesPlugin_Revolution::FROM_OBJECT_ID());
146 AttributeDoublePtr anAttrFromOffset = aBase->real(FeaturesPlugin_Revolution::FROM_OFFSET_ID());
148 theDumper << ", " << anAttrToObject << ", " << anAttrToOffset << ", " << anAttrFromObject << ", " << anAttrFromOffset;
151 theDumper << ")" << std::endl;
154 //==================================================================================================
155 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
156 const std::list<ModelHighAPI_Selection>& theBaseObjects,
157 const ModelHighAPI_Selection& theAxis,
158 const ModelHighAPI_Double& theAngle)
160 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
161 return RevolutionPtr(new FeaturesAPI_Revolution(aFeature, theBaseObjects, theAxis, theAngle));
164 //==================================================================================================
165 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
166 const std::list<ModelHighAPI_Selection>& theBaseObjects,
167 const ModelHighAPI_Selection& theAxis,
168 const ModelHighAPI_Double& theToAngle,
169 const ModelHighAPI_Double& theFromAngle)
171 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
172 return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,
179 //==================================================================================================
180 RevolutionPtr addRevolution(const std::shared_ptr<ModelAPI_Document>& thePart,
181 const std::list<ModelHighAPI_Selection>& theBaseObjects,
182 const ModelHighAPI_Selection& theAxis,
183 const ModelHighAPI_Selection& theToObject,
184 const ModelHighAPI_Double& theToOffset,
185 const ModelHighAPI_Selection& theFromObject,
186 const ModelHighAPI_Double& theFromOffset)
188 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Revolution::ID());
189 return RevolutionPtr(new FeaturesAPI_Revolution(aFeature,