1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: PrimitivesAPI_Cylinder.h
4 // Created: 12 Jan 2017
5 // Author: Clarisse Genrault (CEA)
7 #include "PrimitivesAPI_Cylinder.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const ModelHighAPI_Selection& theBasePoint,
23 const ModelHighAPI_Selection& theAxis,
24 const ModelHighAPI_Double& theRadius,
25 const ModelHighAPI_Double& theHeight)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER(), creationMethod());
30 setObjects(theBasePoint, theAxis);
31 setSizes(theRadius, theHeight);
35 //==================================================================================================
36 PrimitivesAPI_Cylinder::PrimitivesAPI_Cylinder(const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const ModelHighAPI_Selection& theBasePoint,
38 const ModelHighAPI_Selection& theAxis,
39 const ModelHighAPI_Double& theRadius,
40 const ModelHighAPI_Double& theHeight,
41 const ModelHighAPI_Double& theAngle)
42 : ModelHighAPI_Interface(theFeature)
45 fillAttribute(PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION(), creationMethod());
46 setObjects(theBasePoint, theAxis);
47 setSizes(theRadius, theHeight);
52 //==================================================================================================
53 void PrimitivesAPI_Cylinder::setObjects(const ModelHighAPI_Selection& theBasePoint,
54 const ModelHighAPI_Selection& theAxis)
56 fillAttribute(theBasePoint, basePoint());
57 fillAttribute(theAxis, axis());
62 //==================================================================================================
63 void PrimitivesAPI_Cylinder::setSizes(const ModelHighAPI_Double& theRadius,
64 const ModelHighAPI_Double& theHeight)
66 fillAttribute(theRadius, radius());
67 fillAttribute(theHeight, height());
72 //==================================================================================================
73 void PrimitivesAPI_Cylinder::setAngle(const ModelHighAPI_Double& theAngle)
75 fillAttribute(theAngle, angle());
80 //==================================================================================================
81 void PrimitivesAPI_Cylinder::dump(ModelHighAPI_Dumper& theDumper) const
83 FeaturePtr aBase = feature();
84 const std::string& aDocName = theDumper.name(aBase->document());
86 theDumper << aBase << " = model.addCylinder(" << aDocName;
88 std::string aCreationMethod = aBase->string(PrimitivesPlugin_Cylinder::CREATION_METHOD())->value();
90 AttributeSelectionPtr anAttrBasePoint =
91 aBase->selection(PrimitivesPlugin_Cylinder::BASE_POINT_ID());
92 AttributeSelectionPtr anAttrAxis = aBase->selection(PrimitivesPlugin_Cylinder::AXIS_ID());
93 AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Cylinder::RADIUS_ID());
94 AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cylinder::HEIGHT_ID());
96 theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
97 theDumper << ", " << anAttrRadius << ", " << anAttrHeight;
99 if (aCreationMethod == PrimitivesPlugin_Cylinder::CREATION_METHOD_CYLINDER_PORTION()) {
100 AttributeDoublePtr anAttrAngle = aBase->real(PrimitivesPlugin_Cylinder::ANGLE_ID());
101 theDumper << ", " << anAttrAngle;
104 theDumper << ")" << std::endl;
107 //==================================================================================================
108 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
109 const ModelHighAPI_Selection& theBasePoint,
110 const ModelHighAPI_Selection& theAxis,
111 const ModelHighAPI_Double& theRadius,
112 const ModelHighAPI_Double& theHeight,
113 const ModelHighAPI_Double& theAngle)
115 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
116 return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
117 theRadius, theHeight, theAngle));
120 //==================================================================================================
121 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
122 const ModelHighAPI_Selection& theBasePoint,
123 const ModelHighAPI_Selection& theAxis,
124 const ModelHighAPI_Double& theRadius,
125 const ModelHighAPI_Double& theHeight)
127 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
128 return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, theBasePoint, theAxis,
129 theRadius, theHeight));
132 //==================================================================================================
133 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
134 const ModelHighAPI_Double& theRadius,
135 const ModelHighAPI_Double& theHeight,
136 const ModelHighAPI_Double& theAngle)
138 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
139 ModelHighAPI_Selection aBasePoint("VERT", "Origin");
140 ModelHighAPI_Selection anAxis("EDGE", "OZ");
141 return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
142 theRadius, theHeight, theAngle));
145 //==================================================================================================
146 CylinderPtr addCylinder(const std::shared_ptr<ModelAPI_Document>& thePart,
147 const ModelHighAPI_Double& theRadius,
148 const ModelHighAPI_Double& theHeight)
150 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cylinder::ID());
151 ModelHighAPI_Selection aBasePoint("VERT", "Origin");
152 ModelHighAPI_Selection anAxis("EDGE", "OZ");
153 return CylinderPtr(new PrimitivesAPI_Cylinder(aFeature, aBasePoint, anAxis,
154 theRadius, theHeight));