Salome HOME
Merge remote-tracking branch 'origin/cgt/devCEA'
[modules/shaper.git] / src / GDMLAPI / GDMLAPI_ConeSegment.cpp
1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D -->
2
3 // File:        GDMLAPI_ConeSegment.cpp
4 // Created:     29 Nov. 2016
5 // Author:      Clarisse Genrault
6
7 #include "GDMLAPI_ConeSegment.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 GDMLAPI_ConeSegment::GDMLAPI_ConeSegment(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                          const ModelHighAPI_Double& theRMin1,
22                                          const ModelHighAPI_Double& theRMax1,
23                                          const ModelHighAPI_Double& theRMin2,
24                                          const ModelHighAPI_Double& theRMax2,
25                                          const ModelHighAPI_Double& theZ,
26                                          const ModelHighAPI_Double& theStartPhi,
27                                          const ModelHighAPI_Double& theDeltaPhi)
28 : ModelHighAPI_Interface(theFeature)
29 {
30   if (initialize())
31     setAttributes(theRMin1, theRMax1, theRMin2, theRMax2, theZ, theStartPhi, theDeltaPhi);
32 }
33
34 //==================================================================================================
35 GDMLAPI_ConeSegment::~GDMLAPI_ConeSegment()
36 {
37 }
38
39 //==================================================================================================
40 void GDMLAPI_ConeSegment::setAttributes(const ModelHighAPI_Double& theRMin1,
41                                         const ModelHighAPI_Double& theRMax1,
42                                         const ModelHighAPI_Double& theRMin2,
43                                         const ModelHighAPI_Double& theRMax2,
44                                         const ModelHighAPI_Double& theZ,
45                                         const ModelHighAPI_Double& theStartPhi,
46                                         const ModelHighAPI_Double& theDeltaPhi)
47 {
48   fillAttribute(theRMin1, rmin1());
49   fillAttribute(theRMax1, rmax1());
50   fillAttribute(theRMin2, rmin2());
51   fillAttribute(theRMax2, rmax2());
52   fillAttribute(theZ, z());
53   fillAttribute(theStartPhi, startphi());
54   fillAttribute(theDeltaPhi, deltaphi());
55
56   execute();
57 }
58
59 //==================================================================================================
60 void GDMLAPI_ConeSegment::dump(ModelHighAPI_Dumper& theDumper) const
61 {
62   FeaturePtr aBase = feature();
63   const std::string& aDocName = theDumper.name(aBase->document());
64
65   theDumper << aBase << " = model.addConeSegment(" << aDocName;
66
67   AttributeDoublePtr anAttrRMin1 = aBase->real(GDMLPlugin_ConeSegment::RMIN1_ID());
68   AttributeDoublePtr anAttrRMax1 = aBase->real(GDMLPlugin_ConeSegment::RMAX1_ID());
69   AttributeDoublePtr anAttrRMin2 = aBase->real(GDMLPlugin_ConeSegment::RMIN2_ID());
70   AttributeDoublePtr anAttrRMax2 = aBase->real(GDMLPlugin_ConeSegment::RMAX2_ID());
71   AttributeDoublePtr anAttrZ = aBase->real(GDMLPlugin_ConeSegment::Z_ID());
72   AttributeDoublePtr anAttrStartPhi = aBase->real(GDMLPlugin_ConeSegment::STARTPHI_ID());
73   AttributeDoublePtr anAttrDeltaPhi = aBase->real(GDMLPlugin_ConeSegment::DELTAPHI_ID());
74   theDumper << ", " << anAttrRMin1 << ", " << anAttrRMax1;
75   theDumper << ", " << anAttrRMin2 << ", " << anAttrRMax2;
76   theDumper << ", " << anAttrZ << ", " << anAttrStartPhi << " , " << anAttrDeltaPhi;
77
78   theDumper << ")" << std::endl;
79 }
80
81 //==================================================================================================
82 ConeSegmentPtr addConeSegment(const std::shared_ptr<ModelAPI_Document>& thePart,
83                               const ModelHighAPI_Double& theRMin1,
84                               const ModelHighAPI_Double& theRMax1,
85                               const ModelHighAPI_Double& theRMin2,
86                               const ModelHighAPI_Double& theRMax2,
87                               const ModelHighAPI_Double& theZ,
88                               const ModelHighAPI_Double& theStartPhi,
89                               const ModelHighAPI_Double& theDeltaPhi)
90 {
91   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_ConeSegment::ID());
92   return ConeSegmentPtr(new GDMLAPI_ConeSegment(aFeature, theRMin1, theRMax1, theRMin2, theRMax2,
93                                                 theZ, theStartPhi, theDeltaPhi));
94 }