From: Sergey POKHODENKO Date: Tue, 19 May 2015 06:24:30 +0000 (+0300) Subject: Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Set locale before export X-Git-Tag: V_1.2.0~145^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6a737aadaa4b1f19c7791245a0ef74a398b719a4;p=modules%2Fshaper.git Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Set locale before export --- diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 208e61358..83a668987 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -7,6 +7,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS GeomAlgoAPI.h + GeomAlgoAPI_Tools.h GeomAlgoAPI_CompoundBuilder.h GeomAlgoAPI_FaceBuilder.h GeomAlgoAPI_EdgeBuilder.h @@ -28,6 +29,7 @@ SET(PROJECT_HEADERS ) SET(PROJECT_SOURCES + GeomAlgoAPI_Tools.cpp GeomAlgoAPI_CompoundBuilder.cpp GeomAlgoAPI_FaceBuilder.cpp GeomAlgoAPI_EdgeBuilder.cpp diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp index 506a08264..c57b274b8 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp @@ -2,6 +2,8 @@ #include +#include "GeomAlgoAPI_Tools.h" + #include #include @@ -20,6 +22,10 @@ bool Export(const TCollection_AsciiString& theFileName, #ifdef _DEBUG std::cout << "Export BREP into file " << theFileName << std::endl; #endif + + // Set "C" numeric locale to save numbers correctly + GeomAlgoAPI_Tools::Localizer loc; + if ( !BRepTools::Write( theShape, theFileName.ToCString() ) ) { theError = "BREP Export failed"; return false; diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp index 593c49670..936dfd693 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp @@ -2,9 +2,7 @@ #include -//// KERNEL includes -//#include -//#include +#include "GeomAlgoAPI_Tools.h" // OOCT includes #include @@ -115,8 +113,8 @@ bool Export(const TCollection_AsciiString& theFileName, aBrepMode = aKind; } -// // Set "C" numeric locale to save numbers correctly -// Kernel_Utils::Localizer loc; + // Set "C" numeric locale to save numbers correctly + GeomAlgoAPI_Tools::Localizer loc; // initialize writer IGESControl_Controller::Init(); diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp index 734d91fb8..ab2ac7931 100644 --- a/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp +++ b/src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp @@ -2,6 +2,8 @@ #include +#include "GeomAlgoAPI_Tools.h" + // OOCT includes #include #include @@ -20,8 +22,8 @@ bool Export(const TCollection_AsciiString& theFileName, try { -// // Set "C" numeric locale to save numbers correctly -// Kernel_Utils::Localizer loc; + // Set "C" numeric locale to save numbers correctly + GeomAlgoAPI_Tools::Localizer loc; IFSelect_ReturnStatus status ; //VRV: OCC 4.0 migration diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp new file mode 100644 index 000000000..50a3907eb --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp @@ -0,0 +1,23 @@ +/* + * GeomAlgoAPI_Tools.cpp + * + * Created on: May 18, 2015 + * Author: spo + */ + +#include "GeomAlgoAPI_Tools.h" + +#include + +using namespace GeomAlgoAPI_Tools; + +Localizer::Localizer() +{ + myCurLocale = std::setlocale(LC_NUMERIC, 0); + std::setlocale(LC_NUMERIC, "C"); +} + +Localizer::~Localizer() +{ + std::setlocale(LC_NUMERIC, myCurLocale.c_str()); +} diff --git a/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h new file mode 100644 index 000000000..2f1e0eb92 --- /dev/null +++ b/src/GeomAlgoAPI/GeomAlgoAPI_Tools.h @@ -0,0 +1,28 @@ +/* + * GeomAlgoAPI_Tools.h + * + * Created on: May 18, 2015 + * Author: spo + */ + +#ifndef GEOMALGOAPI_TOOLS_H_ +#define GEOMALGOAPI_TOOLS_H_ + +#include + +#include + +namespace GeomAlgoAPI_Tools { + +class GEOMALGOAPI_EXPORT Localizer +{ +public: + Localizer(); + ~Localizer(); +private: + std::string myCurLocale; +}; + +} // GeomAlgoAPI_Tools + +#endif /* GEOMALGOAPI_TOOLS_H_ */