1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ExchangePlugin_ExportFeature.cpp
4 // Created: May 14, 2015
5 // Author: Sergey POKHODENKO
7 #include <ExchangePlugin_Dump.h>
9 #include <ModelAPI_AttributeString.h>
10 #include <ModelAPI_Document.h>
11 #include <ModelAPI_Session.h>
12 #include <ModelAPI_ResultPart.h>
14 #include <ModelHighAPI_Dumper.h>
16 #include <Config_ModuleReader.h>
19 ExchangePlugin_Dump::ExchangePlugin_Dump()
23 ExchangePlugin_Dump::~ExchangePlugin_Dump()
27 void ExchangePlugin_Dump::initAttributes()
29 data()->addAttribute(ExchangePlugin_Dump::FILE_PATH_ID(), ModelAPI_AttributeString::typeId());
30 data()->addAttribute(ExchangePlugin_Dump::FILE_FORMAT_ID(), ModelAPI_AttributeString::typeId());
33 void ExchangePlugin_Dump::execute()
35 AttributeStringPtr aFilePathAttr =
36 this->string(ExchangePlugin_Dump::FILE_PATH_ID());
37 std::string aFilePath = aFilePathAttr->value();
38 if (aFilePath.empty())
44 void ExchangePlugin_Dump::dump(const std::string& theFileName)
46 // load DumpAssistant from Python side
47 Config_ModuleReader::loadScript("salome.shaper.model.dump");
49 ModelHighAPI_Dumper* aDumper = ModelHighAPI_Dumper::getInstance();
51 DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
53 std::list<FeaturePtr> aFeatures = aDoc->allFeatures();
54 for(std::list<FeaturePtr>::const_iterator aFeatIt = aFeatures.begin();
55 aFeatIt != aFeatures.end();
57 ResultPartPtr aResultPart =
58 std::dynamic_pointer_cast<ModelAPI_ResultPart>((*aFeatIt)->firstResult());
59 if(aResultPart.get()) {
60 if(!aResultPart->isActivated()) {
61 setError("Error: Not all parts are loaded. Can not dump.");
67 if (!aDumper || !aDumper->process(aDoc, theFileName))
68 setError("An error occured while dumping to " + theFileName);