1 // Name : ExchangeAPI_Import.cpp
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "ExchangeAPI_Import.h"
9 //--------------------------------------------------------------------------------------
10 #include <ModelHighAPI_Dumper.h>
11 #include <ModelHighAPI_Tools.h>
12 //--------------------------------------------------------------------------------------
13 ExchangeAPI_Import::ExchangeAPI_Import(
14 const std::shared_ptr<ModelAPI_Feature> & theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 ExchangeAPI_Import::ExchangeAPI_Import(
21 const std::shared_ptr<ModelAPI_Feature> & theFeature,
22 const std::string & theFilePath)
23 : ModelHighAPI_Interface(theFeature)
26 setFilePath(theFilePath);
29 ExchangeAPI_Import::~ExchangeAPI_Import()
34 //--------------------------------------------------------------------------------------
35 void ExchangeAPI_Import::setFilePath(const std::string & theFilePath)
37 fillAttribute(theFilePath, myfilePath);
42 //--------------------------------------------------------------------------------------
43 void ExchangeAPI_Import::dump(ModelHighAPI_Dumper& theDumper) const
45 FeaturePtr aBase = feature();
46 std::string aPartName = theDumper.name(aBase->document());
48 theDumper << aBase << " = model.addImport(" << aPartName << ", "
49 << aBase->string(ExchangePlugin_ImportFeature::FILE_PATH_ID()) << ")" << std::endl;
50 // to make import have results
51 theDumper << "model.do()" << std::endl;
53 CompositeFeaturePtr aCompositeFeature = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(aBase);
54 if(aCompositeFeature.get()) {
55 int aNbOfSubs = aCompositeFeature->numberOfSubs();
56 for(int anIndex = 0; anIndex < aNbOfSubs; ++anIndex) {
57 std::string aSubFeatureGet = theDumper.name(aBase) + ".subFeature(" + std::to_string((long long)anIndex) + ")";
58 theDumper.dumpSubFeatureNameAndColor(aSubFeatureGet, aCompositeFeature->subFeature(anIndex));
63 //--------------------------------------------------------------------------------------
65 const std::shared_ptr<ModelAPI_Document> & thePart,
66 const std::string & theFilePath)
68 // TODO(spo): check that thePart is not empty
69 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(ExchangeAPI_Import::ID());
70 return ImportPtr(new ExchangeAPI_Import(aFeature, theFilePath));