Salome HOME
Issue #1648: Dump Python in the High Level Parameterized Geometry API
[modules/shaper.git] / src / FeaturesAPI / FeaturesAPI_Intersection.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        FeaturesAPI_Intersection.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "FeaturesAPI_Intersection.h"
8
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
11
12 //==================================================================================================
13 FeaturesAPI_Intersection::FeaturesAPI_Intersection(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
15 {
16   initialize();
17 }
18
19 //==================================================================================================
20 FeaturesAPI_Intersection::FeaturesAPI_Intersection(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21                                                    const std::list<ModelHighAPI_Selection>& theObjects,
22                                                    const std::list<ModelHighAPI_Selection>& theTools)
23 : ModelHighAPI_Interface(theFeature)
24 {
25   if(initialize()) {
26     fillAttribute(theObjects, myobjects);
27     fillAttribute(theTools, mytools);
28
29     execute();
30   }
31 }
32
33 //==================================================================================================
34 FeaturesAPI_Intersection::~FeaturesAPI_Intersection()
35 {
36
37 }
38
39 //==================================================================================================
40 void FeaturesAPI_Intersection::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
41 {
42   fillAttribute(theObjects, myobjects);
43
44   execute();
45 }
46
47 //==================================================================================================
48 void FeaturesAPI_Intersection::setTools(const std::list<ModelHighAPI_Selection>& theTools)
49 {
50   fillAttribute(theTools, mytools);
51
52   execute();
53 }
54
55 //==================================================================================================
56 void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
57 {
58   FeaturePtr aBase = feature();
59   const std::string& aDocName = theDumper.name(aBase->document());
60
61   AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Intersection::OBJECT_LIST_ID());
62   AttributeSelectionListPtr anAttrTools = aBase->selectionList(FeaturesPlugin_Intersection::TOOL_LIST_ID());
63
64   theDumper << aBase << " = model.addIntersection(" << aDocName << ", "
65             << anAttrObjects << ", " << anAttrTools << ")" << std::endl;
66 }
67
68 //==================================================================================================
69 IntersectionPtr addIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
70                                 const std::list<ModelHighAPI_Selection>& theObjects,
71                                 const std::list<ModelHighAPI_Selection>& theTools)
72 {
73   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Intersection::ID());
74   return IntersectionPtr(new FeaturesAPI_Intersection(aFeature, theObjects, theTools));
75 }