From 0db6518cbadf1b02df67477465a11bcffd007ed9 Mon Sep 17 00:00:00 2001 From: spo Date: Thu, 28 May 2015 15:24:24 +0300 Subject: [PATCH] Issue #529: 4.07. Import IGES, export to BREP, STEP, IGES - If file for export is inputed by hand then file format is from extension and for IGES files it is IGES-5.1 format. --- .../ExchangePlugin_ExportFeature.cpp | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index a67b57bcc..6d3fc8a84 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -77,8 +77,9 @@ void ExchangePlugin_ExportFeature::execute() AttributeStringPtr aFormatAttr = this->string(ExchangePlugin_ExportFeature::FILE_FORMAT_ID()); std::string aFormat = aFormatAttr->value(); - if (aFormat.empty()) - return; + // Format may be empty. In this case look at extension. +// if (aFormat.empty()) +// return; AttributeStringPtr aFilePathAttr = this->string(ExchangePlugin_ExportFeature::FILE_PATH_ID()); @@ -106,6 +107,23 @@ bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName, TCollection_AsciiString aFileName(theFileName.c_str()); TCollection_AsciiString aFormatName(theFormat.c_str()); + if (theFormat.empty()) { // look at extension + OSD_Path aPath(aFileName); + TCollection_AsciiString anExtension = aPath.Extension(); + // ".brep" -> "BREP", TCollection_AsciiString are numbered from 1 + anExtension = anExtension.SubString(2, anExtension.Length()); + anExtension.UpperCase(); + if (anExtension == "BREP" || anExtension == "BRP") { + aFormatName = "BREP"; + } else if (anExtension == "STEP" || anExtension == "STP") { + aFormatName = "STEP"; + } else if (anExtension == "IGES" || anExtension == "IGS") { + aFormatName = "IGES-5.1"; + } else { + aFormatName = anExtension; + } + } + // Perform the export TCollection_AsciiString anError; TopoDS_Shape aShape(theShape->impl()); -- 2.39.2