Salome HOME
Add ExchangeAPI, fillAttribute in ModelHighAPI_Tools, ModelHighAPI_Selection and...
[modules/shaper.git] / src / ExchangeAPI / ExchangeAPI_Import.cpp
1 // Name   : ExchangeAPI_Import.cpp
2 // Purpose: 
3 //
4 // History:
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
6
7 //--------------------------------------------------------------------------------------
8 #include "ExchangeAPI_Import.h"
9
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_Feature.h>
12
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 ExchangeAPI_Import::ExchangeAPI_Import(
16     const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : ModelHighAPI_Interface(theFeature)
18 {
19   initialize();
20 }
21
22 ExchangeAPI_Import::ExchangeAPI_Import(
23     const std::shared_ptr<ModelAPI_Feature> & theFeature,
24     const std::string & theFilePath)
25 : ModelHighAPI_Interface(theFeature)
26 {
27   if (initialize())
28     setFilePath(theFilePath);
29 }
30
31 ExchangeAPI_Import::~ExchangeAPI_Import()
32 {
33
34 }
35
36 //--------------------------------------------------------------------------------------
37 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
38 {
39   fillAttribute(theFilePath, myfilePath);
40
41   execute();
42 }
43
44 //--------------------------------------------------------------------------------------
45 // TODO(spo): make add* as static functions of the class
46 ImportPtr addImport(
47     const std::shared_ptr<ModelAPI_Document> & thePart,
48     const std::string & theFilePath)
49 {
50   // TODO(spo): check that thePart is not empty
51   std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Import::ID());
52   return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath));
53 }