1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Rotation.cpp
4 // Created: 07 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Rotation.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theMainObjects,
22 const ModelHighAPI_Selection& theAxisObject,
23 const ModelHighAPI_Double& theAngle)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theMainObjects, mymainObjects);
28 fillAttribute(theAxisObject, myaxisObject);
33 //==================================================================================================
34 FeaturesAPI_Rotation::FeaturesAPI_Rotation(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const std::list<ModelHighAPI_Selection>& theMainObjects,
36 const ModelHighAPI_Selection& theCenterPoint,
37 const ModelHighAPI_Selection& theStartPoint,
38 const ModelHighAPI_Selection& theEndPoint)
39 : ModelHighAPI_Interface(theFeature)
42 fillAttribute(theMainObjects, mymainObjects);
43 setPoints(theCenterPoint, theStartPoint, theEndPoint);
47 //==================================================================================================
48 FeaturesAPI_Rotation::~FeaturesAPI_Rotation()
53 //==================================================================================================
54 void FeaturesAPI_Rotation::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
56 fillAttribute(theMainObjects, mymainObjects);
61 //==================================================================================================
62 void FeaturesAPI_Rotation::setAxisObject(const ModelHighAPI_Selection& theAxisObject)
64 fillAttribute(FeaturesPlugin_Rotation::CREATION_METHOD_BY_ANGLE(), mycreationMethod);
65 fillAttribute(theAxisObject, myaxisObject);
70 //==================================================================================================
71 void FeaturesAPI_Rotation::setAngle(const ModelHighAPI_Double& theAngle)
73 fillAttribute(FeaturesPlugin_Rotation::CREATION_METHOD_BY_ANGLE(), mycreationMethod);
74 fillAttribute(theAngle, myangle);
79 //==================================================================================================
80 void FeaturesAPI_Rotation::setPoints(const ModelHighAPI_Selection& theCenterPoint,
81 const ModelHighAPI_Selection& theStartPoint,
82 const ModelHighAPI_Selection& theEndPoint)
84 fillAttribute(FeaturesPlugin_Rotation::CREATION_METHOD_BY_THREE_POINTS(), mycreationMethod);
85 fillAttribute(theCenterPoint, centerPoint());
86 fillAttribute(theStartPoint, startPoint());
87 fillAttribute(theEndPoint, endPoint());
92 //==================================================================================================
93 void FeaturesAPI_Rotation::dump(ModelHighAPI_Dumper& theDumper) const
95 FeaturePtr aBase = feature();
96 const std::string& aDocName = theDumper.name(aBase->document());
98 AttributeSelectionListPtr anAttrObjects =
99 aBase->selectionList(FeaturesPlugin_Rotation::OBJECTS_LIST_ID());
101 theDumper << aBase << " = model.addRotation(" << aDocName << ", " << anAttrObjects;
103 std::string aCreationMethod =
104 aBase->string(FeaturesPlugin_Rotation::CREATION_METHOD())->value();
106 if (aCreationMethod == FeaturesPlugin_Rotation::CREATION_METHOD_BY_ANGLE()) {
107 AttributeSelectionPtr anAttrAxis = aBase->selection(FeaturesPlugin_Rotation::AXIS_OBJECT_ID());
108 AttributeDoublePtr anAttrAngle = aBase->real(FeaturesPlugin_Rotation::ANGLE_ID());
109 theDumper << ", " << anAttrAxis << ", " << anAttrAngle;
110 } else if (aCreationMethod == FeaturesPlugin_Rotation::CREATION_METHOD_BY_THREE_POINTS()) {
111 AttributeSelectionPtr anAttrCenterPoint =
112 aBase->selection(FeaturesPlugin_Rotation::CENTER_POINT_ID());
113 AttributeSelectionPtr anAttrStartPoint =
114 aBase->selection(FeaturesPlugin_Rotation::START_POINT_ID());
115 AttributeSelectionPtr anAttrEndPoint =
116 aBase->selection(FeaturesPlugin_Rotation::END_POINT_ID());
117 theDumper << ", " << anAttrCenterPoint << ", " << anAttrStartPoint << ", " << anAttrEndPoint;
120 theDumper << ")" << std::endl;
123 //==================================================================================================
124 RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
125 const std::list<ModelHighAPI_Selection>& theMainObjects,
126 const ModelHighAPI_Selection& theAxisObject,
127 const ModelHighAPI_Double& theAngle)
129 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
130 return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theAxisObject, theAngle));
133 //==================================================================================================
134 RotationPtr addRotation(const std::shared_ptr<ModelAPI_Document>& thePart,
135 const std::list<ModelHighAPI_Selection>& theMainObjects,
136 const ModelHighAPI_Selection& theCenterPoint,
137 const ModelHighAPI_Selection& theStartPoint,
138 const ModelHighAPI_Selection& theEndPoint)
140 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Rotation::ID());
141 return RotationPtr(new FeaturesAPI_Rotation(aFeature, theMainObjects, theCenterPoint,
142 theStartPoint, theEndPoint));