1 // Copyright (C) 2017-2020 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 // File: PrimitivesAPI_Cone.cpp
21 // Created: 20 Mar 2017
22 // Author: Clarisse Genrault
24 #include "PrimitivesAPI_Cone.h"
26 #include <ModelHighAPI_Dumper.h>
27 #include <ModelHighAPI_Selection.h>
28 #include <ModelHighAPI_Tools.h>
30 //==================================================================================================
31 PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature)
32 : ModelHighAPI_Interface(theFeature)
37 //==================================================================================================
38 PrimitivesAPI_Cone::PrimitivesAPI_Cone(const std::shared_ptr<ModelAPI_Feature>& theFeature,
39 const ModelHighAPI_Selection& theBasePoint,
40 const ModelHighAPI_Selection& theAxis,
41 const ModelHighAPI_Double& theBaseRadius,
42 const ModelHighAPI_Double& theTopRadius,
43 const ModelHighAPI_Double& theHeight)
44 : ModelHighAPI_Interface(theFeature)
47 fillAttribute(theBasePoint, basePoint());
48 fillAttribute(theAxis, axis());
49 fillAttribute(theBaseRadius, baseRadius());
50 fillAttribute(theTopRadius, topRadius());
55 //==================================================================================================
56 PrimitivesAPI_Cone::~PrimitivesAPI_Cone()
60 //==================================================================================================
61 void PrimitivesAPI_Cone::setRadius(const ModelHighAPI_Double& theBaseRadius,
62 const ModelHighAPI_Double& theTopRadius)
64 fillAttribute(theBaseRadius, baseRadius());
65 fillAttribute(theTopRadius, topRadius());
69 //==================================================================================================
70 void PrimitivesAPI_Cone::setHeight(const ModelHighAPI_Double& theHeight)
72 fillAttribute(theHeight, height());
76 //==================================================================================================
77 void PrimitivesAPI_Cone::dump(ModelHighAPI_Dumper& theDumper) const
79 FeaturePtr aBase = feature();
80 const std::string& aDocName = theDumper.name(aBase->document());
82 theDumper << aBase << " = model.addCone(" << aDocName;
84 AttributeSelectionPtr anAttrBasePoint =
85 aBase->selection(PrimitivesPlugin_Cone::BASE_POINT_ID());
86 AttributeSelectionPtr anAttrAxis =
87 aBase->selection(PrimitivesPlugin_Cone::AXIS_ID());
88 theDumper << ", " << anAttrBasePoint << ", " << anAttrAxis;
90 AttributeDoublePtr anAttrBaseRadius = aBase->real(PrimitivesPlugin_Cone::BASE_RADIUS_ID());
91 AttributeDoublePtr anAttrTopRadius = aBase->real(PrimitivesPlugin_Cone::TOP_RADIUS_ID());
92 AttributeDoublePtr anAttrHeight = aBase->real(PrimitivesPlugin_Cone::HEIGHT_ID());
93 theDumper << ", " << anAttrBaseRadius << ", " << anAttrTopRadius << ", " << anAttrHeight;
95 theDumper << ")" << std::endl;
98 //==================================================================================================
99 ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
100 const ModelHighAPI_Selection& theBasePoint,
101 const ModelHighAPI_Selection& theAxis,
102 const ModelHighAPI_Double& theBaseRadius,
103 const ModelHighAPI_Double& theTopRadius,
104 const ModelHighAPI_Double& theHeight)
106 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
107 return ConePtr(new PrimitivesAPI_Cone(aFeature, theBasePoint, theAxis, theBaseRadius,
108 theTopRadius, theHeight));
111 //==================================================================================================
112 ConePtr addCone(const std::shared_ptr<ModelAPI_Document>& thePart,
113 const ModelHighAPI_Double& theBaseRadius,
114 const ModelHighAPI_Double& theTopRadius,
115 const ModelHighAPI_Double& theHeight)
117 ModelHighAPI_Selection aBasePoint("VERTEX", L"PartSet/Origin");
118 ModelHighAPI_Selection anAxis("EDGE", L"PartSet/OZ");
119 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PrimitivesAPI_Cone::ID());
120 return ConePtr(new PrimitivesAPI_Cone(aFeature, aBasePoint, anAxis, theBaseRadius,
121 theTopRadius, theHeight));