Salome HOME
Issue #1860: fix end lines with spaces
[modules/shaper.git] / src / PartSetAPI / PartSetAPI_Part.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name   : PartSetAPI_Part.cpp
3 // Purpose:
4 //
5 // History:
6 // 16/06/16 - Sergey POKHODENKO - Creation of the file
7
8 //--------------------------------------------------------------------------------------
9 #include "PartSetAPI_Part.h"
10 //--------------------------------------------------------------------------------------
11 #include <ModelAPI_ResultPart.h>
12 #include <ModelHighAPI_Dumper.h>
13 //--------------------------------------------------------------------------------------
14 #include <PartSetPlugin_Duplicate.h>
15 #include <PartSetPlugin_Remove.h>
16 //--------------------------------------------------------------------------------------
17 PartSetAPI_Part::PartSetAPI_Part(
18     const std::shared_ptr<ModelAPI_Feature> & theFeature)
19 : ModelHighAPI_Interface(theFeature)
20 {
21   initialize();
22 }
23
24 PartSetAPI_Part::~PartSetAPI_Part()
25 {
26 }
27
28 //--------------------------------------------------------------------------------------
29 std::shared_ptr<ModelAPI_Document> PartSetAPI_Part::document() const
30 {
31   return std::dynamic_pointer_cast<ModelAPI_ResultPart>(defaultResult())->partDoc();
32 }
33
34 void PartSetAPI_Part::dump(ModelHighAPI_Dumper& theDumper) const
35 {
36   FeaturePtr aBase = feature();
37   const std::string& aDocName = theDumper.name(aBase->document());
38
39   theDumper << aBase << " = model.addPart(" << aDocName << ")" << std::endl;
40 }
41
42 //--------------------------------------------------------------------------------------
43 PartPtr addPart(const std::shared_ptr<ModelAPI_Document> & thePart)
44 {
45   // TODO(spo): check that thePart is not empty
46   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetAPI_Part::ID());
47   aFeature->execute();
48   return PartPtr(new PartSetAPI_Part(aFeature));
49 }
50
51 PartPtr duplicatePart(const std::shared_ptr<ModelAPI_Document> & thePart)
52 {
53   // TODO(spo): check that thePart is not empty
54   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Duplicate::ID());
55   aFeature->execute();
56   return PartPtr(new PartSetAPI_Part(aFeature));
57 }
58
59 void removePart(const std::shared_ptr<ModelAPI_Document> & thePart)
60 {
61   // TODO(spo): check that thePart is not empty
62   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(PartSetPlugin_Remove::ID());
63   aFeature->execute();
64 }