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(
74 FeaturesPlugin_Boolean::TYPE_ID())->value();
76 theDumper << aBase << " = model.add";
79 case FeaturesPlugin_Boolean::BOOL_CUT: theDumper << "Cut"; break;
80 case FeaturesPlugin_Boolean::BOOL_FUSE: theDumper << "Fuse"; break;
81 case FeaturesPlugin_Boolean::BOOL_COMMON: theDumper << "Common"; break;
82 case FeaturesPlugin_Boolean::BOOL_FILL: theDumper << "Fill"; break;
83 case FeaturesPlugin_Boolean::BOOL_SMASH: theDumper << "Smash"; break;
86 const std::string& aDocName = theDumper.name(aBase->document());
87 AttributeSelectionListPtr anObjects =
88 aBase->selectionList(FeaturesPlugin_Boolean::OBJECT_LIST_ID());
89 AttributeSelectionListPtr aTools = aBase->selectionList(FeaturesPlugin_Boolean::TOOL_LIST_ID());
91 theDumper << "(" << aDocName << ", " << anObjects << ", " << aTools << ")" << std::endl;
94 //==================================================================================================
95 BooleanPtr addCut(const std::shared_ptr<ModelAPI_Document>& thePart,
96 const std::list<ModelHighAPI_Selection>& theMainObjects,
97 const std::list<ModelHighAPI_Selection>& theToolObjects)
99 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
100 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
101 FeaturesPlugin_Boolean::BOOL_CUT,
106 //==================================================================================================
107 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
108 const std::list<ModelHighAPI_Selection>& theObjects)
110 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
111 std::list<ModelHighAPI_Selection> aToolObjects;
112 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
113 FeaturesPlugin_Boolean::BOOL_FUSE,
118 //==================================================================================================
119 BooleanPtr addFuse(const std::shared_ptr<ModelAPI_Document>& thePart,
120 const std::list<ModelHighAPI_Selection>& theMainObjects,
121 const std::list<ModelHighAPI_Selection>& theToolObjects)
123 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
124 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
125 FeaturesPlugin_Boolean::BOOL_FUSE,
130 //==================================================================================================
131 BooleanPtr addCommon(const std::shared_ptr<ModelAPI_Document>& thePart,
132 const std::list<ModelHighAPI_Selection>& theMainObjects,
133 const std::list<ModelHighAPI_Selection>& theToolObjects)
135 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
136 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
137 FeaturesPlugin_Boolean::BOOL_COMMON,
142 //==================================================================================================
143 BooleanPtr addSmash(const std::shared_ptr<ModelAPI_Document>& thePart,
144 const std::list<ModelHighAPI_Selection>& theMainObjects,
145 const std::list<ModelHighAPI_Selection>& theToolObjects)
147 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
148 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
149 FeaturesPlugin_Boolean::BOOL_SMASH,
154 //==================================================================================================
155 BooleanPtr addFill(const std::shared_ptr<ModelAPI_Document>& thePart,
156 const std::list<ModelHighAPI_Selection>& theMainObjects,
157 const std::list<ModelHighAPI_Selection>& theToolObjects)
159 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Boolean::ID());
160 return BooleanPtr(new FeaturesAPI_Boolean(aFeature,
161 FeaturesPlugin_Boolean::BOOL_FILL,