1 // Copyright (C) 2014-2017 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 "FeaturesAPI_Boolean.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Integer.h>
25 #include <ModelHighAPI_Selection.h>
26 #include <ModelHighAPI_Tools.h>
28 //==================================================================================================
29 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature)
30 : ModelHighAPI_Interface(theFeature)
35 //==================================================================================================
36 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const ModelHighAPI_Integer& theBoolType,
38 const std::list<ModelHighAPI_Selection>& theMainObjects,
39 const std::list<ModelHighAPI_Selection>& theToolObjects)
40 : ModelHighAPI_Interface(theFeature)
43 fillAttribute(theBoolType, myboolType);
44 fillAttribute(theMainObjects, mymainObjects);
45 fillAttribute(theToolObjects, mytoolObjects);
51 //==================================================================================================
52 FeaturesAPI_Boolean::~FeaturesAPI_Boolean()
57 //==================================================================================================
58 void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType)
60 fillAttribute(theBoolType, myboolType);
65 //==================================================================================================
66 void FeaturesAPI_Boolean::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
68 fillAttribute(theMainObjects, mymainObjects);
73 //==================================================================================================
74 void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects)
76 fillAttribute(theToolObjects, mytoolObjects);
81 //==================================================================================================
82 void FeaturesAPI_Boolean::dump(ModelHighAPI_Dumper& theDumper) const
84 FeaturePtr aBase = feature();
86 FeaturesPlugin_Boolean::OperationType aType =
87 (FeaturesPlugin_Boolean::OperationType)aBase->integer(
88 FeaturesPlugin_Boolean::TYPE_ID())->value();
90 theDumper << aBase << " = model.add";
93 case FeaturesPlugin_Boolean::BOOL_CUT: theDumper << "Cut"; break;
94 case FeaturesPlugin_Boolean::BOOL_FUSE: theDumper << "Fuse"; break;
95 case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break;
96 case FeaturesPlugin_Boolean::BOOL_FILL: theDumper << "Fill"; break;
97 case FeaturesPlugin_Boolean::BOOL_SMASH: theDumper << "Smash"; break;
100 const std::string& aDocName = theDumper.name(aBase->document());
101 AttributeSelectionListPtr anObjects =
102 aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
103 AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
105 theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
108 //==================================================================================================
109 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
110 const std::list<ModelHighAPI_Selection>& theMainObjects,
111 const std::list<ModelHighAPI_Selection>& theToolObjects)
113 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
114 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
115 FeaturesPlugin_Boolean::BOOL_CUT,
120 //==================================================================================================
121 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
122 const std::list<ModelHighAPI_Selection>& theObjects)
124 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
125 std::list<ModelHighAPI_Selection> aToolObjects;
126 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
127 FeaturesPlugin_Boolean::BOOL_FUSE,
132 //==================================================================================================
133 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
134 const std::list<ModelHighAPI_Selection>& theMainObjects,
135 const std::list<ModelHighAPI_Selection>& theToolObjects)
137 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
138 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
139 FeaturesPlugin_Boolean::BOOL_FUSE,
144 //==================================================================================================
145 BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
146 const std::list<ModelHighAPI_Selection>& theMainObjects,
147 const std::list<ModelHighAPI_Selection>& theToolObjects)
149 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
150 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
151 FeaturesPlugin_Boolean::BOOL_COMMON,
156 //==================================================================================================
157 BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
158 const std::list<ModelHighAPI_Selection>& theMainObjects,
159 const std::list<ModelHighAPI_Selection>& theToolObjects)
161 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
162 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
163 FeaturesPlugin_Boolean::BOOL_SMASH,
168 //==================================================================================================
169 BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
170 const std::list<ModelHighAPI_Selection>& theMainObjects,
171 const std::list<ModelHighAPI_Selection>& theToolObjects)
173 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
174 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
175 FeaturesPlugin_Boolean::BOOL_FILL,