X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FExchangePlugin%2FExchangePlugin_ExportFeature.cpp;h=f4ff3d3ad9fa976278264117b9b8005ad04e6db5;hb=676ee79de539b14b242a561857c1505cce13d951;hp=1cf82bb0b9e974efa70b184d76aff35858c5c128;hpb=015aa771f0bb34d556efcf94ae51e6cdef5c8047;p=modules%2Fshaper.git diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 1cf82bb0b..f4ff3d3ad 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -26,8 +26,6 @@ #include #include -#include - #include #include #include @@ -58,8 +56,8 @@ const std::string& ExchangePlugin_ExportFeature::getKind() */ void ExchangePlugin_ExportFeature::initAttributes() { - data()->addAttribute(ExchangePlugin_ExportFeature::FILE_FORMAT_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(ExchangePlugin_ExportFeature::FILE_PATH_ID(), ModelAPI_AttributeString::typeId()); + data()->addAttribute(ExchangePlugin_ExportFeature::FILE_FORMAT_ID(), ModelAPI_AttributeString::typeId()); data()->addAttribute(ExchangePlugin_ExportFeature::SELECTION_LIST_ID(), ModelAPI_AttributeSelectionList::typeId()); } @@ -85,10 +83,21 @@ void ExchangePlugin_ExportFeature::execute() this->selectionList(ExchangePlugin_ExportFeature::SELECTION_LIST_ID()); std::list > aShapes; for (int i = 0, aSize = aSelectionListAttr->size(); i < aSize; ++i) { - aShapes.push_back(aSelectionListAttr->value(i)->value()); + AttributeSelectionPtr anAttrSelection = aSelectionListAttr->value(i); + std::shared_ptr aCurShape = anAttrSelection->value(); + if (aCurShape.get() == NULL) + aCurShape = anAttrSelection->context()->shape(); + if (aCurShape.get() != NULL) + aShapes.push_back(aCurShape); + } + + // Store compound if we have more than one shape. + std::shared_ptr aShape; + if(aShapes.size() == 1) { + aShape = aShapes.front(); + } else { + aShape = GeomAlgoAPI_CompoundBuilder::compound(aShapes); } - std::shared_ptr aShape = - GeomAlgoAPI_CompoundBuilder::compound(aShapes); exportFile(aFilePath, aFormat, aShape); } @@ -116,15 +125,13 @@ bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, // Perform the export std::string anError; - - TopoDS_Shape aShape(theShape->impl()); bool aResult = false; if (aFormatName == "BREP") { - aResult = BREPExport::Export(theFileName, aFormatName, aShape, anError); + aResult = BREPExport(theFileName, aFormatName, theShape, anError); } else if (aFormatName == "STEP") { - aResult = STEPExport::Export(theFileName, aFormatName, aShape, anError); + aResult = STEPExport(theFileName, aFormatName, theShape, anError); } else if (aFormatName.substr(0, 4) == "IGES") { - aResult = IGESExport::Export(theFileName, aFormatName, aShape, anError); + aResult = IGESExport(theFileName, aFormatName, theShape, anError); } else { anError = "Unsupported format " + aFormatName; }