1 // Copyright (C) 2014-2019 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 #include "GDMLAPI_Ellipsoid.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Tools.h>
25 GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature)
26 : ModelHighAPI_Interface(theFeature)
31 GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
32 const ModelHighAPI_Double& theAX,
33 const ModelHighAPI_Double& theBY,
34 const ModelHighAPI_Double& theCZ)
35 : ModelHighAPI_Interface(theFeature)
38 setSizes(theAX, theBY, theCZ);
39 fillAttribute("", useZCut1());
40 fillAttribute("", useZCut2());
44 GDMLAPI_Ellipsoid::GDMLAPI_Ellipsoid(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 const ModelHighAPI_Double& theAX,
46 const ModelHighAPI_Double& theBY,
47 const ModelHighAPI_Double& theCZ,
48 const ModelHighAPI_Double& theZCut1,
49 const ModelHighAPI_Double& theZCut2)
50 : ModelHighAPI_Interface(theFeature)
53 setSizes(theAX, theBY, theCZ);
59 GDMLAPI_Ellipsoid::~GDMLAPI_Ellipsoid()
63 void GDMLAPI_Ellipsoid::setSizes(const ModelHighAPI_Double& theAX,
64 const ModelHighAPI_Double& theBY,
65 const ModelHighAPI_Double& theCZ)
67 fillAttribute(theAX, ax());
68 fillAttribute(theBY, by());
69 fillAttribute(theCZ, cz());
74 void GDMLAPI_Ellipsoid::setZCut1(const ModelHighAPI_Double& theZCut1)
76 fillAttribute("true", useZCut1());
77 fillAttribute(theZCut1, zCut1());
82 void GDMLAPI_Ellipsoid::setZCut2(const ModelHighAPI_Double& theZCut2)
84 fillAttribute("true", useZCut2());
85 fillAttribute(theZCut2, zCut2());
91 //==================================================================================================
92 void GDMLAPI_Ellipsoid::dump(ModelHighAPI_Dumper& theDumper) const
94 FeaturePtr aBase = feature();
95 const std::string& aDocName = theDumper.name(aBase->document());
97 AttributeDoublePtr anAttrAX = aBase->real(GDMLPlugin_Ellipsoid::AX_ID());
98 AttributeDoublePtr anAttrBY = aBase->real(GDMLPlugin_Ellipsoid::BY_ID());
99 AttributeDoublePtr anAttrCZ = aBase->real(GDMLPlugin_Ellipsoid::CZ_ID());
101 theDumper << aBase << " = model.addEllipsoid(" << aDocName << ", "
102 << anAttrAX << ", " << anAttrBY << ", " << anAttrCZ;
104 AttributeStringPtr anAttrUseZCut1 = aBase->string(GDMLPlugin_Ellipsoid::USE_ZCUT1_ID());
105 AttributeDoublePtr anAttrZCut1 = aBase->real(GDMLPlugin_Ellipsoid::ZCUT1_ID());
106 AttributeStringPtr anAttrUseZCut2 = aBase->string(GDMLPlugin_Ellipsoid::USE_ZCUT2_ID());
107 AttributeDoublePtr anAttrZCut2 = aBase->real(GDMLPlugin_Ellipsoid::ZCUT2_ID());
109 bool isZCut1 = !anAttrUseZCut1->value().empty();
110 bool isZCut2 = !anAttrUseZCut2->value().empty();
111 if (isZCut1 && isZCut2)
112 theDumper << ", " << anAttrZCut1 << ", " << anAttrZCut2 << ")" << std::endl;
114 theDumper << ")" << std::endl;
116 if (isZCut1 && !isZCut2)
117 theDumper << theDumper.name(aBase) << ".setZCut1(" << anAttrZCut1 << ")" << std::endl;
118 else if (!isZCut1 && isZCut2)
119 theDumper << theDumper.name(aBase) << ".setZCut2(" << anAttrZCut2 << ")" << std::endl;
124 //==================================================================================================
125 EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
126 const ModelHighAPI_Double& theAX,
127 const ModelHighAPI_Double& theBY,
128 const ModelHighAPI_Double& theCZ)
130 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_Ellipsoid::ID());
131 return EllipsoidPtr(new GDMLAPI_Ellipsoid(aFeature, theAX, theBY, theCZ));
134 EllipsoidPtr addEllipsoid(const std::shared_ptr<ModelAPI_Document>& thePart,
135 const ModelHighAPI_Double& theAX,
136 const ModelHighAPI_Double& theBY,
137 const ModelHighAPI_Double& theCZ,
138 const ModelHighAPI_Double& theZCut1,
139 const ModelHighAPI_Double& theZCut2)
141 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(GDMLAPI_Ellipsoid::ID());
142 return EllipsoidPtr(new GDMLAPI_Ellipsoid(aFeature, theAX, theBY, theCZ, theZCut1, theZCut2));