]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Export STEP
authorSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Thu, 14 May 2015 12:29:22 +0000 (15:29 +0300)
committerSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Tue, 19 May 2015 07:58:19 +0000 (10:58 +0300)
src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.h [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h

index 3ad9783e26d4e5b667268b89b31b0ee3358333ac..5120fde5ef687b66dc61de71c514304db82022e2 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <ExchangePlugin_ExportFeature.h>
 #include <GeomAlgoAPI_BREPExport.h>
-//#include <GeomAlgoAPI_STEPExport.h>
+#include <GeomAlgoAPI_STEPExport.h>
 #include <GeomAlgoAPI_IGESExport.h>
 
 #include <Config_Common.h>
@@ -109,7 +109,7 @@ bool ExchangePlugin_ExportFeature::exportFile(const std::string& theFileName,
   if (aFormatName == "BREP") {
     aResult = BREPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
   } else if (aFormatName == "STEP" || aFormatName == "STP") {
-//    aShape = STEPExport::Export(aFileName, aFormatName, anError, anUnknownLabel);
+    aResult = STEPExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
   } else if (aFormatName == "IGES") {
     aResult = IGESExport::Export(aFileName, aFormatName, aShape, anError, anUnknownLabel);
   }
index 2dfd6048f3a65622d397ce8487e4c025d3a2d230..208e613581a4e63b64467a0570d99261e5ca3a41 100644 (file)
@@ -23,6 +23,7 @@ SET(PROJECT_HEADERS
     GeomAlgoAPI_STEPImport.h
     GeomAlgoAPI_IGESImport.h
     GeomAlgoAPI_BREPExport.h
+    GeomAlgoAPI_STEPExport.h
     GeomAlgoAPI_IGESExport.h
 )
 
@@ -43,6 +44,7 @@ SET(PROJECT_SOURCES
     GeomAlgoAPI_STEPImport.cpp
     GeomAlgoAPI_IGESImport.cpp
     GeomAlgoAPI_BREPExport.cpp
+    GeomAlgoAPI_STEPExport.cpp
     GeomAlgoAPI_IGESExport.cpp
 )
 
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp
new file mode 100644 (file)
index 0000000..9454f4a
--- /dev/null
@@ -0,0 +1,49 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+#include <GeomAlgoAPI_STEPExport.h>
+
+// OOCT includes
+#include <IFSelect_ReturnStatus.hxx>
+#include <STEPControl_Writer.hxx>
+#include <Interface_Static.hxx>
+
+namespace STEPExport {
+
+bool Export (const TCollection_AsciiString& theFileName,
+             const TCollection_AsciiString& theFormatName,
+             const TopoDS_Shape& theShape,
+             TCollection_AsciiString&       theError,
+             const TDF_Label&               theShapeLabel)
+{
+  #ifdef _DEBUG
+  std::cout << "Export STEP into file " << theFileName.ToCString() << std::endl;
+  #endif
+
+  try
+  {
+//    // Set "C" numeric locale to save numbers correctly
+//    Kernel_Utils::Localizer loc;
+
+    IFSelect_ReturnStatus status ;
+    //VRV: OCC 4.0 migration
+    STEPControl_Writer aWriter;
+    Interface_Static::SetCVal("xstep.cascade.unit","M");
+    Interface_Static::SetCVal("write.step.unit", "M");
+    Interface_Static::SetIVal("write.step.nonmanifold", 1);
+    status = aWriter.Transfer( theShape, STEPControl_AsIs );
+    //VRV: OCC 4.0 migration
+    if( status == IFSelect_RetDone )
+      status = aWriter.Write( theFileName.ToCString() );
+
+    // Return previous locale
+    if( status == IFSelect_RetDone )
+      return true;
+  }
+  catch (Standard_Failure)
+  {
+    theError = "Exception catched in STEPExport";
+  }
+  return false;
+}
+
+} // namespace STEPExport
diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.h
new file mode 100644 (file)
index 0000000..f0bcec1
--- /dev/null
@@ -0,0 +1,37 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+/*
+ * GEOMALGOAPI_STEPExport.h
+ *
+ *  Created on: May 14, 2015
+ *      Author: spo
+ */
+
+#ifndef GEOMALGOAPI_STEPEXPORT_H_
+#define GEOMALGOAPI_STEPEXPORT_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TDF_Label.hxx>
+
+namespace STEPExport {
+
+/// Implementation of the export parameter from the STEP file
+GEOMALGOAPI_EXPORT
+Handle(TCollection_HAsciiString) GetValue(const TCollection_AsciiString& theFileName,
+                                          const TCollection_AsciiString& theParameterName,
+                                          TCollection_AsciiString& theError);
+
+/// Implementation of the export STEP files algorithms
+GEOMALGOAPI_EXPORT
+bool Export(const TCollection_AsciiString& theFileName,
+            const TCollection_AsciiString& theFormatName,
+            const TopoDS_Shape& theShape,
+            TCollection_AsciiString& theError,
+            const TDF_Label& theShapeLabel);
+}
+
+#endif /* GEOMALGOAPI_STEPEXPORT_H_ */
index 232f28dced00e767cc03b4f1edb4ea9de4805985..dc3299669ccc6d877b7b88bd5f4955aff45dce15 100644 (file)
@@ -7,6 +7,9 @@
  *      Author: sbh
  */
 
+#ifndef GEOMALGOAPI_STEPIMPORT_H_
+#define GEOMALGOAPI_STEPIMPORT_H_
+
 #include <GeomAlgoAPI.h>
 
 #include <TCollection_AsciiString.hxx>
@@ -28,3 +31,5 @@ TopoDS_Shape Import(const TCollection_AsciiString& theFileName,
                     const TCollection_AsciiString& theFormatName, TCollection_AsciiString& theError,
                     const TDF_Label& theShapeLabel);
 }
+
+#endif /* GEOMALGOAPI_STEPIMPORT_H_ */