Salome HOME
Issue #1834: Fix length of lines
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Union.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Union.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Union.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //================================================================================================
13 FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //================================================================================================
20 FeaturesAPI_Union::FeaturesAPI_Union(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                      const std::list<ModelHighAPI_Selection>& theBaseObjects)
22 : ModelHighAPI_Interface(theFeature)
23 {
24   if(initialize()) {
25     setBase(theBaseObjects);
26   }
27 }
28
29 //================================================================================================
30 FeaturesAPI_Union::~FeaturesAPI_Union()
31 {
32
33 }
34
35 //==================================================================================================
36 void FeaturesAPI_Union::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
37 {
38   fillAttribute(theBaseObjects, mybaseObjects);
39
40   execute();
41 }
42
43 //==================================================================================================
44 void FeaturesAPI_Union::dump(ModelHighAPI_Dumper& theDumper) const
45 {
46   FeaturePtr aBase = feature();
47   const std::string& aDocName = theDumper.name(aBase->document());
48
49   AttributeSelectionListPtr anAttrObjects =
50     aBase->selectionList(FeaturesPlugin_Union::BASE_OBJECTS_ID());
51
52   theDumper << aBase << " = model.addUnion(" << aDocName << 
53     ", " << anAttrObjects << ")" << std::endl;
54 }
55
56 //==================================================================================================
57 UnionPtr addUnion(const std::shared_ptr<ModelAPI_Document>& thePart,
58                   const std::list<ModelHighAPI_Selection>& theBaseObjects)
59 {
60   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Union::ID());
61   return UnionPtr(new FeaturesAPI_Union(aFeature, theBaseObjects));
62 }