1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
3 // File: PrimitivesAPI_Cone.cpp
4 // Created: 20 Mar 2017
5 // Author: Clarisse Genrault
7 #include "PrimitivesAPI_Cone.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const ModelHighAPI_Selection& theBasePoint,
23 const ModelHighAPI_Selection& theAxis,
24 const ModelHighAPI_Double& theBaseRadius,
25 const ModelHighAPI_Double& theTopRadius,
26 const ModelHighAPI_Double& theHeight)
27 : ModelHighAPI_Interface(theFeature)
30 fillAttribute(theBasePoint, basePoint());
31 fillAttribute(theAxis, axis());
32 fillAttribute(theBaseRadius, baseRadius());
33 fillAttribute(theTopRadius, topRadius());
38 //==================================================================================================
39 PrimitivesAPI_Cone::~PrimitivesAPI_Cone()
43 //==================================================================================================
44 void PrimitivesAPI_Cone::setRadius(const ModelHighAPI_Double& theBaseRadius,
45 const ModelHighAPI_Double& theTopRadius)
47 fillAttribute(theBaseRadius, baseRadius());
48 fillAttribute(theTopRadius, topRadius());
52 //==================================================================================================
53 void PrimitivesAPI_Cone::setHeight(const ModelHighAPI_Double& theHeight)
55 fillAttribute(theHeight, height());
59 //==================================================================================================
60 void PrimitivesAPI_Cone::dump(ModelHighAPI_Dumper& theDumper) const
62 FeaturePtr aBase = feature();
63 const std::string& aDocName = theDumper.name(aBase->document());
65 theDumper << aBase << " = model.addCone(" << aDocName;
67 AttributeSelectionPtr anAttrBasePoint =
68 aBase->selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
69 AttributeSelectionPtr anAttrAxis =
70 aBase->selection(PrimitivesPlugin_Cone::AXIS_ID());
71 theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
73 AttributeDoublePtr anAttrBaseRadius = aBase->real(PrimitivesPlugin_Cone::BASE_RADIUS_ID());
74 AttributeDoublePtr anAttrTopRadius = aBase->real(PrimitivesPlugin_Cone::TOP_RADIUS_ID());
75 AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cone::HEIGHT_ID());
76 theDumper << ", " << anAttrBaseRadius << ", " << anAttrTopRadius << ", " << anAttrHeight;
78 theDumper << ")" << std::endl;
81 //==================================================================================================
82 ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
83 const ModelHighAPI_Selection& theBasePoint,
84 const ModelHighAPI_Selection& theAxis,
85 const ModelHighAPI_Double& theBaseRadius,
86 const ModelHighAPI_Double& theTopRadius,
87 const ModelHighAPI_Double& theHeight)
89 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
90 return ConePtr(new PrimitivesAPI_Cone(aFeature, theBasePoint, theAxis, theBaseRadius,
91 theTopRadius, theHeight));
94 //==================================================================================================
95 ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
96 const ModelHighAPI_Double& theBaseRadius,
97 const ModelHighAPI_Double& theTopRadius,
98 const ModelHighAPI_Double& theHeight)
100 ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
101 ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
102 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
103 return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius,
104 theTopRadius, theHeight));