1 // Copyright (C) 2017-20xx 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "BuildAPI_Filling.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
26 BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr<ModelAPI_Feature>& theFeature)
27 : ModelHighAPI_Interface(theFeature)
32 BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr<ModelAPI_Feature>& theFeature,
33 const std::list<ModelHighAPI_Selection>& theBaseObjects)
34 : ModelHighAPI_Interface(theFeature)
37 setBase(theBaseObjects);
40 BuildAPI_Filling::BuildAPI_Filling(const std::shared_ptr<ModelAPI_Feature>& theFeature,
41 const std::list<ModelHighAPI_Selection>& theBaseObjects,
42 const std::string& theOrientCorrection,
43 const int theMinDegree,
44 const int theMaxDegree,
46 const double theTolerance2D,
47 const double theTolerance3D,
48 const bool theApproximate)
49 : ModelHighAPI_Interface(theFeature)
52 setOrientationMethod(theOrientCorrection);
53 setMinDegree(theMinDegree);
54 setMaxDegree(theMaxDegree);
55 setNbIterations(theNbIter);
56 setTolerance2d(theTolerance2D);
57 setTolerance3d(theTolerance3D);
58 setApproximation(theApproximate);
60 setBase(theBaseObjects);
64 BuildAPI_Filling::~BuildAPI_Filling()
68 void BuildAPI_Filling::execIfBaseNotEmpty()
70 if (baseObjects()->size() > 0)
74 void BuildAPI_Filling::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
76 fillAttribute(theBaseObjects, mybaseObjects);
80 void BuildAPI_Filling::setOrientationMethod(const std::string& theMethod)
82 fillAttribute(theMethod, myorientationMethod);
83 if (theMethod != BuildPlugin_Filling::METHOD_DEFAULT())
88 void BuildAPI_Filling::setMinDegree(const int theMinDegree)
90 fillAttribute(theMinDegree, myminDegree);
91 if (theMinDegree != BuildPlugin_Filling::MINIMAL_DEGREE_DEFAULT())
96 void BuildAPI_Filling::setMaxDegree(const int theMaxDegree)
98 fillAttribute(theMaxDegree, mymaxDegree);
99 if (theMaxDegree != BuildPlugin_Filling::MAXIMAL_DEGREE_DEFAULT())
100 setAdvancedOptions();
101 execIfBaseNotEmpty();
104 void BuildAPI_Filling::setNbIterations(const int theNbIter)
106 fillAttribute(theNbIter, mynbIterations);
107 if (theNbIter != BuildPlugin_Filling::NUMBER_OF_ITERATIONS_DEFAULT())
108 setAdvancedOptions();
109 execIfBaseNotEmpty();
112 void BuildAPI_Filling::setTolerance2d(const double theTol2d)
114 fillAttribute(theTol2d, mytolerance2d);
115 if (theTol2d != BuildPlugin_Filling::TOLERANCE_2D_DEFAULT())
116 setAdvancedOptions();
117 execIfBaseNotEmpty();
120 void BuildAPI_Filling::setTolerance3d(const double theTol3d)
122 fillAttribute(theTol3d, mytolerance3d);
123 if (theTol3d != BuildPlugin_Filling::TOLERANCE_3D_DEFAULT())
124 setAdvancedOptions();
125 execIfBaseNotEmpty();
128 void BuildAPI_Filling::setApproximation(const bool theApproximate)
130 fillAttribute(theApproximate, myapproximate);
131 if (theApproximate != BuildPlugin_Filling::APPROXIMATION_DEFAULT())
132 setAdvancedOptions();
133 execIfBaseNotEmpty();
136 void BuildAPI_Filling::setAdvancedOptions()
138 feature()->string(BuildPlugin_Filling::ADVANCED_OPTIONS_ID())->setValue("true");
141 void BuildAPI_Filling::dump(ModelHighAPI_Dumper& theDumper) const
143 FeaturePtr aBase = feature();
144 std::string aPartName = theDumper.name(aBase->document());
146 theDumper << aBase << " = model.addFilling(" << aPartName << ", " << baseObjects();
148 if (!aBase->string(BuildPlugin_Filling::ADVANCED_OPTIONS_ID())->value().empty()) {
150 theDumper << ", " << orientationMethod()
151 << ", " << minDegree() << ", " << maxDegree() << ", " << nbIterations()
152 << ", " << tolerance2d() << ", " << tolerance3d()
153 << ", " << approximate();
155 theDumper << ")" << std::endl;
158 //==================================================================================================
160 FillingPtr addFilling(const std::shared_ptr<ModelAPI_Document>& thePart,
161 const std::list<ModelHighAPI_Selection>& theBaseObjects)
163 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Filling::ID());
164 return FillingPtr(new BuildAPI_Filling(aFeature, theBaseObjects));
167 FillingPtr addFilling(const std::shared_ptr<ModelAPI_Document>& thePart,
168 const std::list<ModelHighAPI_Selection>& theBaseObjects,
169 const std::string& theOrientCorrection,
170 const int theMinDegree,
171 const int theMaxDegree,
173 const double theTolerance2D,
174 const double theTolerance3D,
175 const bool theApproximate)
177 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_Filling::ID());
178 return FillingPtr(new BuildAPI_Filling(aFeature, theBaseObjects, theOrientCorrection,
179 theMinDegree, theMaxDegree, theNbIter, theTolerance2D, theTolerance3D, theApproximate));