Salome HOME
b6e2a729bb657082176b3514fa13f11879a34a45
[modules/shaper.git] / src / BuildAPI / BuildAPI_SubShapes.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        BuildAPI_SubShapes.cpp
4 // Created:     09 June 2016
5 // Author:      Dmitry Bobylev
6
7 #include "BuildAPI_SubShapes.h"
8
9 #include <ModelHighAPI_Tools.h>
10
11 //==================================================================================================
12 BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr<ModelAPI_Feature>& theFeature)
13 : ModelHighAPI_Interface(theFeature)
14 {
15   initialize();
16 }
17
18 //==================================================================================================
19 BuildAPI_SubShapes::BuildAPI_SubShapes(const std::shared_ptr<ModelAPI_Feature>& theFeature,
20                                        const ModelHighAPI_Selection& theBaseShape,
21                                        const std::list<ModelHighAPI_Selection>& theSubShapes)
22 : ModelHighAPI_Interface(theFeature)
23 {
24   if(initialize()) {
25     fillAttribute(theBaseShape, mybaseShape);
26     setSubShapes(theSubShapes);
27   }
28 }
29
30 //==================================================================================================
31 BuildAPI_SubShapes::~BuildAPI_SubShapes()
32 {
33
34 }
35
36 //==================================================================================================
37 void BuildAPI_SubShapes::setBaseShape(const ModelHighAPI_Selection& theBaseShape)
38 {
39   fillAttribute(theBaseShape, mybaseShape);
40
41   execute();
42 }
43
44 //==================================================================================================
45 void BuildAPI_SubShapes::setSubShapes(const std::list<ModelHighAPI_Selection>& theSubShapes)
46 {
47   fillAttribute(theSubShapes, mysubShapes);
48
49   execute();
50 }
51
52 // TODO(spo): make add* as static functions of the class
53 //==================================================================================================
54 SubShapesPtr addSubShapes(const std::shared_ptr<ModelAPI_Document>& thePart,
55                           const ModelHighAPI_Selection& theBaseShape,
56                           const std::list<ModelHighAPI_Selection>& theSubShapes)
57 {
58   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(BuildAPI_SubShapes::ID());
59   return SubShapesPtr(new BuildAPI_SubShapes(aFeature, theBaseShape, theSubShapes));
60 }