From: Sergey POKHODENKO Date: Thu, 14 May 2015 12:29:22 +0000 (+0300) Subject: Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Export STEP X-Git-Tag: V_1.2.0~145^2~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b4be68ffcb00b8b9276a94b05ea613d9c411fde6;p=modules%2Fshaper.git Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Export STEP --- diff --git a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp index 3ad9783e2..5120fde5e 100644 --- a/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp +++ b/src/ExchangePlugin/ExchangePlugin_ExportFeature.cpp @@ -9,7 +9,7 @@ #include #include -//#include +#include #include #include @@ -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); } diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 2dfd6048f..208e61358 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -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 index 000000000..9454f4a06 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp @@ -0,0 +1,49 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +#include + +// OOCT includes +#include +#include +#include + +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 index 000000000..f0bcec172 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.h @@ -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 + +#include +#include +#include +#include + +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_ */ diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h index 232f28dce..dc3299669 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPImport.h @@ -7,6 +7,9 @@ * Author: sbh */ +#ifndef GEOMALGOAPI_STEPIMPORT_H_ +#define GEOMALGOAPI_STEPIMPORT_H_ + #include #include @@ -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_ */