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 "FeaturesAPI_BooleanFuse.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Selection.h>
24 #include <ModelHighAPI_Tools.h>
26 //==================================================================================================
27 FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
28 const std::shared_ptr<ModelAPI_Feature>& theFeature)
29 : ModelHighAPI_Interface(theFeature)
34 //==================================================================================================
35 FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
36 const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const std::list<ModelHighAPI_Selection>& theMainObjects,
38 const bool theRemoveEdges,
40 : ModelHighAPI_Interface(theFeature)
43 fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod);
44 fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID()));
45 fillAttribute(theMainObjects, mymainObjects);
46 fillAttribute(theRemoveEdges, myremoveEdges);
52 //==================================================================================================
53 FeaturesAPI_BooleanFuse::FeaturesAPI_BooleanFuse(
54 const std::shared_ptr<ModelAPI_Feature>& theFeature,
55 const std::list<ModelHighAPI_Selection>& theMainObjects,
56 const std::list<ModelHighAPI_Selection>& theToolObjects,
57 const bool theRemoveEdges,
59 : ModelHighAPI_Interface(theFeature)
62 fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod);
63 fillAttribute(theVersion, theFeature->integer(FeaturesPlugin_Boolean::VERSION_ID()));
64 fillAttribute(theMainObjects, mymainObjects);
65 fillAttribute(theToolObjects, mytoolObjects);
66 fillAttribute(theRemoveEdges, myremoveEdges);
72 //==================================================================================================
73 FeaturesAPI_BooleanFuse::~FeaturesAPI_BooleanFuse()
78 //==================================================================================================
79 void FeaturesAPI_BooleanFuse::setMainObjects(
80 const std::list<ModelHighAPI_Selection>& theMainObjects)
82 fillAttribute(theMainObjects, mymainObjects);
87 //==================================================================================================
88 void FeaturesAPI_BooleanFuse::setToolObjects(
89 const std::list<ModelHighAPI_Selection>& theToolObjects)
91 fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod);
92 fillAttribute(theToolObjects, mytoolObjects);
97 //==================================================================================================
98 void FeaturesAPI_BooleanFuse::setRemoveEdges(const bool theRemoveEdges)
100 fillAttribute(theRemoveEdges, myremoveEdges);
105 //==================================================================================================
106 void FeaturesAPI_BooleanFuse::setAdvancedMode(const bool theMode)
109 fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED(), mycreationMethod);
111 fillAttribute(FeaturesPlugin_BooleanFuse::CREATION_METHOD_SIMPLE(), mycreationMethod);
117 //==================================================================================================
118 void FeaturesAPI_BooleanFuse::dump(ModelHighAPI_Dumper& theDumper) const
120 FeaturePtr aBase = feature();
122 theDumper << aBase << " = model.addFuse";
124 const std::string& aDocName = theDumper.name(aBase->document());
125 AttributeStringPtr aMode = aBase->string(FeaturesPlugin_BooleanFuse::CREATION_METHOD());
126 AttributeSelectionListPtr anObjects =
127 aBase->selectionList(FeaturesPlugin_BooleanFuse::OBJECT_LIST_ID());
128 AttributeSelectionListPtr aTools =
129 aBase->selectionList(FeaturesPlugin_BooleanFuse::TOOL_LIST_ID());
130 AttributeBooleanPtr aRemoveEdges =
131 aBase->boolean(FeaturesPlugin_BooleanFuse::REMOVE_INTERSECTION_EDGES_ID());
132 AttributeIntegerPtr aVersion =
133 aBase->integer(FeaturesPlugin_BooleanFuse::VERSION_ID());
135 theDumper << "(" << aDocName << ", " << anObjects;
137 if (aMode->value() == FeaturesPlugin_BooleanFuse::CREATION_METHOD_ADVANCED()) {
138 theDumper << ", " << aTools;
141 bool hasVersion = aVersion && aVersion->isInitialized();
142 if (aRemoveEdges->value() || hasVersion) {
143 theDumper << ", " << aRemoveEdges->value();
147 theDumper << ", " << aVersion->value();
150 theDumper << ")" << std::endl;
153 //==================================================================================================
154 BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
155 const std::list<ModelHighAPI_Selection>& theObjects,
156 const bool theRemoveEdges,
157 const int theVersion)
159 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID());
160 return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature,
166 //==================================================================================================
167 BooleanFusePtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
168 const std::list<ModelHighAPI_Selection>& theMainObjects,
169 const std::list<ModelHighAPI_Selection>& theToolObjects,
170 const bool theRemoveEdges,
171 const int theVersion)
173 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_BooleanFuse::ID());
174 return BooleanFusePtr(new FeaturesAPI_BooleanFuse(aFeature,