1 // Copyright (C) 2014-2022 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 "FeaturesAPI_Intersection.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Tools.h>
26 static const double DEFAULT_FUZZY = 1.e-5;
29 //==================================================================================================
30 FeaturesAPI_Intersection::FeaturesAPI_Intersection(
31 const std::shared_ptr<ModelAPI_Feature>& theFeature)
32 : ModelHighAPI_Interface(theFeature)
37 //==================================================================================================
38 FeaturesAPI_Intersection::FeaturesAPI_Intersection(
39 const std::shared_ptr<ModelAPI_Feature>& theFeature,
40 const std::list<ModelHighAPI_Selection>& theObjects,
41 const ModelHighAPI_Double& theFuzzy)
42 : ModelHighAPI_Interface(theFeature)
45 bool aUseFuzzy = (theFuzzy.value() > 0);
46 ModelHighAPI_Double aFuzzy = (aUseFuzzy ? theFuzzy : ModelHighAPI_Double(DEFAULT_FUZZY));
47 fillAttribute(theObjects, myobjects);
48 fillAttribute(aUseFuzzy, myuseFuzzy);
49 fillAttribute(aFuzzy, myfuzzyParam);
55 //==================================================================================================
56 FeaturesAPI_Intersection::~FeaturesAPI_Intersection()
61 //==================================================================================================
62 void FeaturesAPI_Intersection::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
64 fillAttribute(theObjects, myobjects);
69 //==================================================================================================
70 void FeaturesAPI_Intersection::setUseFuzzy(bool theUseFuzzy)
72 fillAttribute(theUseFuzzy, myuseFuzzy);
77 //==================================================================================================
78 void FeaturesAPI_Intersection::setFuzzyValue(const ModelHighAPI_Double& theFuzzy)
80 fillAttribute(theFuzzy, myfuzzyParam);
85 //==================================================================================================
86 void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
88 FeaturePtr aBase = feature();
89 const std::string& aDocName = theDumper.name(aBase->document());
91 AttributeSelectionListPtr anAttrObjects =
92 aBase->selectionList(FeaturesPlugin_Intersection::OBJECT_LIST_ID());
93 bool aUseFuzzy = aBase->boolean(FeaturesPlugin_Intersection::USE_FUZZY_ID())->value();
94 AttributeDoublePtr aFuzzy = aBase->real(FeaturesPlugin_Intersection::FUZZY_PARAM_ID());
96 theDumper << aBase << " = model.addIntersection(" << aDocName << ", " << anAttrObjects;
99 theDumper << ", fuzzyParam = " << aFuzzy;
101 if (!aBase->data()->version().empty())
102 theDumper << ", keepSubResults = True";
104 theDumper << ")" << std::endl;
107 //==================================================================================================
108 IntersectionPtr addIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
109 const std::list<ModelHighAPI_Selection>& theObjects,
110 const ModelHighAPI_Double& fuzzyParam,
111 const bool keepSubResults)
113 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Intersection::ID());
115 aFeature->data()->setVersion("");
116 return IntersectionPtr(new FeaturesAPI_Intersection(aFeature, theObjects, fuzzyParam));