Salome HOME
Add copyright header according to request of CEA from 06.06.2017
[modules/shaper.git] / src / GDMLAPI / GDMLAPI_ConeSegment.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
19 //
20
21 #include "GDMLAPI_ConeSegment.h"
22
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
25
26 //==================================================================================================
27 GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
29 {
30   initialize();
31 }
32
33 //==================================================================================================
34 GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35                                          const ModelHighAPI_Double& theRMin1,
36                                          const ModelHighAPI_Double& theRMax1,
37                                          const ModelHighAPI_Double& theRMin2,
38                                          const ModelHighAPI_Double& theRMax2,
39                                          const ModelHighAPI_Double& theZ,
40                                          const ModelHighAPI_Double& theStartPhi,
41                                          const ModelHighAPI_Double& theDeltaPhi)
42 : ModelHighAPI_Interface(theFeature)
43 {
44   if (initialize())
45     setAttributes(theRMin1, theRMax1, theRMin2, theRMax2, theZ, theStartPhi, theDeltaPhi);
46 }
47
48 //==================================================================================================
49 GDMLAPI_ConeSegment::~GDMLAPI_ConeSegment()
50 {
51 }
52
53 //==================================================================================================
54 void GDMLAPI_ConeSegment::setAttributes(const ModelHighAPI_Double& theRMin1,
55                                         const ModelHighAPI_Double& theRMax1,
56                                         const ModelHighAPI_Double& theRMin2,
57                                         const ModelHighAPI_Double& theRMax2,
58                                         const ModelHighAPI_Double& theZ,
59                                         const ModelHighAPI_Double& theStartPhi,
60                                         const ModelHighAPI_Double& theDeltaPhi)
61 {
62   fillAttribute(theRMin1, rmin1());
63   fillAttribute(theRMax1, rmax1());
64   fillAttribute(theRMin2, rmin2());
65   fillAttribute(theRMax2, rmax2());
66   fillAttribute(theZ, z());
67   fillAttribute(theStartPhi, startphi());
68   fillAttribute(theDeltaPhi, deltaphi());
69
70   execute();
71 }
72
73 //==================================================================================================
74 void GDMLAPI_ConeSegment::dump(ModelHighAPI_Dumper& theDumper) const
75 {
76   FeaturePtr aBase = feature();
77   const std::string& aDocName = theDumper.name(aBase->document());
78
79   theDumper << aBase << " = model.addConeSegment(" << aDocName;
80
81   AttributeDoublePtr anAttrRMin1 = aBase->real(GDMLPlugin_ConeSegment::RMIN1_ID());
82   AttributeDoublePtr anAttrRMax1 = aBase->real(GDMLPlugin_ConeSegment::RMAX1_ID());
83   AttributeDoublePtr anAttrRMin2 = aBase->real(GDMLPlugin_ConeSegment::RMIN2_ID());
84   AttributeDoublePtr anAttrRMax2 = aBase->real(GDMLPlugin_ConeSegment::RMAX2_ID());
85   AttributeDoublePtr anAttrZ = aBase->real(GDMLPlugin_ConeSegment::Z_ID());
86   AttributeDoublePtr anAttrStartPhi = aBase->real(GDMLPlugin_ConeSegment::STARTPHI_ID());
87   AttributeDoublePtr anAttrDeltaPhi = aBase->real(GDMLPlugin_ConeSegment::DELTAPHI_ID());
88   theDumper << ", " << anAttrRMin1 << ", " << anAttrRMax1;
89   theDumper << ", " << anAttrRMin2 << ", " << anAttrRMax2;
90   theDumper << ", " << anAttrZ << ", " << anAttrStartPhi << " , " << anAttrDeltaPhi;
91
92   theDumper << ")" << std::endl;
93 }
94
95 //==================================================================================================
96 ConeSegmentPtr addConeSegment(const std::shared_ptr<ModelAPI_Document>& thePart,
97                               const ModelHighAPI_Double& theRMin1,
98                               const ModelHighAPI_Double& theRMax1,
99                               const ModelHighAPI_Double& theRMin2,
100                               const ModelHighAPI_Double& theRMax2,
101                               const ModelHighAPI_Double& theZ,
102                               const ModelHighAPI_Double& theStartPhi,
103                               const ModelHighAPI_Double& theDeltaPhi)
104 {
105   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_ConeSegment::ID());
106   return ConeSegmentPtr(new GDMLAPI_ConeSegment(aFeature, theRMin1, theRMax1, theRMin2, theRMax2,
107                                                 theZ, theStartPhi, theDeltaPhi));
108 }