1 // Copyright (C) 2014-201x CEA/DEN, EDF R&D -->
3 // File: PrimitivesAPI_Torus.cpp
4 // Created: 20 Mar 2017
5 // Author: Clarisse Genrault
7 #include "PrimitivesAPI_Torus.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Selection.h>
11 #include <ModelHighAPI_Tools.h>
13 //==================================================================================================
14 PrimitivesAPI_Torus::PrimitivesAPI_Torus(const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 PrimitivesAPI_Torus::PrimitivesAPI_Torus(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& theRingRadius)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(theBasePoint, basePoint());
30 fillAttribute(theAxis, axis());
31 setRadius(theRadius, theRingRadius);
35 //==================================================================================================
36 PrimitivesAPI_Torus::~PrimitivesAPI_Torus()
40 //==================================================================================================
41 void PrimitivesAPI_Torus::setRadius(const ModelHighAPI_Double& theRadius,
42 const ModelHighAPI_Double& theRingRadius)
44 fillAttribute(theRadius, radius());
45 fillAttribute(theRingRadius, ringRadius());
49 //==================================================================================================
50 void PrimitivesAPI_Torus::dump(ModelHighAPI_Dumper& theDumper) const
52 FeaturePtr aBase = feature();
53 const std::string& aDocName = theDumper.name(aBase->document());
55 theDumper << aBase << " = model.addTorus(" << aDocName;
57 AttributeSelectionPtr anAttrBasePoint =
58 aBase->selection(PrimitivesPlugin_Torus::BASE_POINT_ID());
59 AttributeSelectionPtr anAttrAxis =
60 aBase->selection(PrimitivesPlugin_Torus::AXIS_ID());
61 theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
63 AttributeDoublePtr anAttrRadius = aBase->real(PrimitivesPlugin_Torus::RADIUS_ID());
64 AttributeDoublePtr anAttrRingRadius = aBase->real(PrimitivesPlugin_Torus::RING_RADIUS_ID());
65 theDumper << ", " << anAttrRadius << ", " << anAttrRingRadius;
67 theDumper << ")" << std::endl;
70 //==================================================================================================
71 TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
72 const ModelHighAPI_Selection& theBasePoint,
73 const ModelHighAPI_Selection& theAxis,
74 const ModelHighAPI_Double& theRadius,
75 const ModelHighAPI_Double& theRingRadius)
77 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
78 return TorusPtr(new PrimitivesAPI_Torus(aFeature, theBasePoint, theAxis,
79 theRadius, theRingRadius));
82 //==================================================================================================
83 TorusPtr addTorus(const std::shared_ptr<ModelAPI_Document>& thePart,
84 const ModelHighAPI_Double& theRadius,
85 const ModelHighAPI_Double& theRingRadius)
87 ModelHighAPI_Selection aBasePoint("VERTEX", "PartSet/Origin");
88 ModelHighAPI_Selection anAxis("EDGE", "PartSet/OZ");
89 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Torus::ID());
90 return TorusPtr(new PrimitivesAPI_Torus(aFeature, aBasePoint, anAxis, theRadius, theRingRadius));