Salome HOME
Issue #1834: Fix length of lines
[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(
14   const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
16 {
17   initialize();
18 }
19
20 //==================================================================================================
21 FeaturesAPI_Intersection::FeaturesAPI_Intersection(
22   const std::shared_ptr<ModelAPI_Feature>& theFeature,
23   const std::list<ModelHighAPI_Selection>& theObjects,
24   const std::list<ModelHighAPI_Selection>& theTools)
25 : ModelHighAPI_Interface(theFeature)
26 {
27   if(initialize()) {
28     fillAttribute(theObjects, myobjects);
29     fillAttribute(theTools, mytools);
30
31     execute();
32   }
33 }
34
35 //==================================================================================================
36 FeaturesAPI_Intersection::~FeaturesAPI_Intersection()
37 {
38
39 }
40
41 //==================================================================================================
42 void FeaturesAPI_Intersection::setObjects(const std::list<ModelHighAPI_Selection>& theObjects)
43 {
44   fillAttribute(theObjects, myobjects);
45
46   execute();
47 }
48
49 //==================================================================================================
50 void FeaturesAPI_Intersection::setTools(const std::list<ModelHighAPI_Selection>& theTools)
51 {
52   fillAttribute(theTools, mytools);
53
54   execute();
55 }
56
57 //==================================================================================================
58 void FeaturesAPI_Intersection::dump(ModelHighAPI_Dumper& theDumper) const
59 {
60   FeaturePtr aBase = feature();
61   const std::string& aDocName = theDumper.name(aBase->document());
62
63   AttributeSelectionListPtr anAttrObjects = 
64     aBase->selectionList(FeaturesPlugin_Intersection::OBJECT_LIST_ID());
65   AttributeSelectionListPtr anAttrTools = 
66     aBase->selectionList(FeaturesPlugin_Intersection::TOOL_LIST_ID());
67
68   theDumper << aBase << " = model.addIntersection(" << aDocName << ", "
69             << anAttrObjects << ", " << anAttrTools << ")" << std::endl;
70 }
71
72 //==================================================================================================
73 IntersectionPtr addIntersection(const std::shared_ptr<ModelAPI_Document>& thePart,
74                                 const std::list<ModelHighAPI_Selection>& theObjects,
75                                 const std::list<ModelHighAPI_Selection>& theTools)
76 {
77   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Intersection::ID());
78   return IntersectionPtr(new FeaturesAPI_Intersection(aFeature, theObjects, theTools));
79 }