1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Boolean.cpp
4 // Created: 07 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Boolean.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Integer.h>
11 #include <ModelHighAPI_Selection.h>
12 #include <ModelHighAPI_Tools.h>
14 //==================================================================================================
15 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature)
16 : ModelHighAPI_Interface(theFeature)
21 //==================================================================================================
22 FeaturesAPI_Boolean::FeaturesAPI_Boolean(const std::shared_ptr<ModelAPI_Feature>& theFeature,
23 const ModelHighAPI_Integer& theBoolType,
24 const std::list<ModelHighAPI_Selection>& theMainObjects,
25 const std::list<ModelHighAPI_Selection>& theToolObjects)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(theBoolType, myboolType);
30 fillAttribute(theMainObjects, mymainObjects);
31 fillAttribute(theToolObjects, mytoolObjects);
37 //==================================================================================================
38 FeaturesAPI_Boolean::~FeaturesAPI_Boolean()
43 //==================================================================================================
44 void FeaturesAPI_Boolean::setBoolType(const ModelHighAPI_Integer& theBoolType)
46 fillAttribute(theBoolType, myboolType);
51 //==================================================================================================
52 void FeaturesAPI_Boolean::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
54 fillAttribute(theMainObjects, mymainObjects);
59 //==================================================================================================
60 void FeaturesAPI_Boolean::setToolObjects(const std::list<ModelHighAPI_Selection>& theToolObjects)
62 fillAttribute(theToolObjects, mytoolObjects);
67 //==================================================================================================
68 void FeaturesAPI_Boolean::dump(ModelHighAPI_Dumper& theDumper) const
70 FeaturePtr aBase = feature();
72 FeaturesPlugin_Boolean::OperationType aType =
73 (FeaturesPlugin_Boolean::OperationType)aBase->integer(FeaturesPlugin_Boolean::TYPE_ID())->value();
75 theDumper << aBase << " = model.add";
78 case FeaturesPlugin_Boolean::BOOL_CUT: theDumper << "Cut"; break;
79 case FeaturesPlugin_Boolean::BOOL_FUSE: theDumper << "Fuse"; break;
80 case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break;
81 case FeaturesPlugin_Boolean::BOOL_FILL: theDumper << "Fill"; break;
82 case FeaturesPlugin_Boolean::BOOL_SMASH: theDumper << "Smash"; break;
85 const std::string& aDocName = theDumper.name(aBase->document());
86 AttributeSelectionListPtr anObjects = aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
87 AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
89 theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
92 //==================================================================================================
93 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
94 const std::list<ModelHighAPI_Selection>& theMainObjects,
95 const std::list<ModelHighAPI_Selection>& theToolObjects)
97 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
98 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
99 FeaturesPlugin_Boolean::BOOL_CUT,
104 //==================================================================================================
105 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
106 const std::list<ModelHighAPI_Selection>& theObjects)
108 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
109 std::list<ModelHighAPI_Selection> aToolObjects;
110 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
111 FeaturesPlugin_Boolean::BOOL_FUSE,
116 //==================================================================================================
117 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
118 const std::list<ModelHighAPI_Selection>& theMainObjects,
119 const std::list<ModelHighAPI_Selection>& theToolObjects)
121 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
122 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
123 FeaturesPlugin_Boolean::BOOL_FUSE,
128 //==================================================================================================
129 BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
130 const std::list<ModelHighAPI_Selection>& theMainObjects,
131 const std::list<ModelHighAPI_Selection>& theToolObjects)
133 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
134 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
135 FeaturesPlugin_Boolean::BOOL_COMMON,
140 //==================================================================================================
141 BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
142 const std::list<ModelHighAPI_Selection>& theMainObjects,
143 const std::list<ModelHighAPI_Selection>& theToolObjects)
145 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
146 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
147 FeaturesPlugin_Boolean::BOOL_SMASH,
152 //==================================================================================================
153 BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
154 const std::list<ModelHighAPI_Selection>& theMainObjects,
155 const std::list<ModelHighAPI_Selection>& theToolObjects)
157 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
158 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
159 FeaturesPlugin_Boolean::BOOL_FILL,