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