]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #529: 4.07. Import IGES, export to BREP, STEP, IGES - If file for export is...
authorspo <sergey.pokhodenko@opencascade.com>
Thu, 28 May 2015 12:24:24 +0000 (15:24 +0300)
committerspo <sergey.pokhodenko@opencascade.com>
Thu, 28 May 2015 12:27:11 +0000 (15:27 +0300)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp

index a67b57bccb115ce7d649bfd812bbf93b194ef1a3..6d3fc8a847a50c2fc54abd63f20eab758b615d2d 100644 (file)
@@ -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<TopoDS_Shape>());