Salome HOME
Merge branch 'CPPHighAPI'
[modules/shaper.git] / src / PartSetAPI / PartSetAPI_Part.cpp
1 // Name   : PartSetAPI_Part.cpp
2 // Purpose: 
3 //
4 // History:
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "PartSetAPI_Part.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelAPI_ResultPart.h>
11 //--------------------------------------------------------------------------------------
12 #include <PartSetPlugin_Duplicate.h>
13 #include <PartSetPlugin_Remove.h>
14 //--------------------------------------------------------------------------------------
15 PartSetAPI_Part::PartSetAPI_Part(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : ModelHighAPI_Interface(theFeature)
18 {
19   initialize();
20 }
21
22 PartSetAPI_Part::~PartSetAPI_Part()
23 {
24 }
25
26 //--------------------------------------------------------------------------------------
27 std::shared_ptr<ModelAPI_Document> PartSetAPI_Part::document() const
28 {
29   return std::dynamic_pointer_cast<ModelAPI_ResultPart>(defaultResult())->partDoc();
30 }
31
32 //--------------------------------------------------------------------------------------
33 PartPtr addPart(const std::shared_ptr<ModelAPI_Document> & thePart)
34 {
35   // TODO(spo): check that thePart is not empty
36   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetAPI_Part::ID());
37   aFeature->execute();
38   return PartPtr(new PartSetAPI_Part(aFeature));
39 }
40
41 PartPtr duplicatePart(const std::shared_ptr<ModelAPI_Document> & thePart)
42 {
43   // TODO(spo): check that thePart is not empty
44   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Duplicate::ID());
45   aFeature->execute();
46   return PartPtr(new PartSetAPI_Part(aFeature));
47 }
48
49 void removePart(const std::shared_ptr<ModelAPI_Document> & thePart)
50 {
51   // TODO(spo): check that thePart is not empty
52   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Remove::ID());
53   aFeature->execute();
54 }