Salome HOME
Issue #529 : 4.07. Import IGES, export to BREP, STEP, IGES - Set locale before export
authorSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Tue, 19 May 2015 06:24:30 +0000 (09:24 +0300)
committerSergey POKHODENKO <sergey.pokhodenko@opencascade.com>
Tue, 19 May 2015 07:58:20 +0000 (10:58 +0300)
src/GeomAlgoAPI/CMakeLists.txt
src/GeomAlgoAPI/GeomAlgoAPI_BREPExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_IGESExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_STEPExport.cpp
src/GeomAlgoAPI/GeomAlgoAPI_Tools.cpp [new file with mode: 0644]
src/GeomAlgoAPI/GeomAlgoAPI_Tools.h [new file with mode: 0644]

index 208e613581a4e63b64467a0570d99261e5ca3a41..83a668987dc3824de0e2c3674b65aa1ae50a2814 100644 (file)
@@ -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
index 506a082645e816ee5831cc0a3c86eff803dc4501..c57b274b84d29cf71eed3bd52dcfd218ad947d10 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <GeomAlgoAPI_BREPExport.h>
 
+#include "GeomAlgoAPI_Tools.h"
+
 #include <BRepTools.hxx>
 #include <BRep_Builder.hxx>
 
@@ -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;
index 593c49670f5e04629cb840a2e213ea439f1a889d..936dfd6935ae41eae03a7667da9dc300c60f55e2 100644 (file)
@@ -2,9 +2,7 @@
 
 #include <GeomAlgoAPI_IGESExport.h>
 
-//// KERNEL includes
-//#include <utilities.h>
-//#include <Basics_Utils.hxx>
+#include "GeomAlgoAPI_Tools.h"
 
 // OOCT includes
 #include <IGESControl_Controller.hxx>
@@ -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();
index 734d91fb82b4da7a4709b537c894403cff49b8f0..ab2ac793111d1bc994ae56977f3721f2f15ab7e5 100644 (file)
@@ -2,6 +2,8 @@
 
 #include <GeomAlgoAPI_STEPExport.h>
 
+#include "GeomAlgoAPI_Tools.h"
+
 // OOCT includes
 #include <IFSelect_ReturnStatus.hxx>
 #include <STEPControl_Writer.hxx>
@@ -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 (file)
index 0000000..50a3907
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * GeomAlgoAPI_Tools.cpp
+ *
+ *  Created on: May 18, 2015
+ *      Author: spo
+ */
+
+#include "GeomAlgoAPI_Tools.h"
+
+#include <clocale>
+
+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 (file)
index 0000000..2f1e0eb
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * GeomAlgoAPI_Tools.h
+ *
+ *  Created on: May 18, 2015
+ *      Author: spo
+ */
+
+#ifndef GEOMALGOAPI_TOOLS_H_
+#define GEOMALGOAPI_TOOLS_H_
+
+#include <GeomAlgoAPI.h>
+
+#include <string>
+
+namespace GeomAlgoAPI_Tools {
+
+class GEOMALGOAPI_EXPORT Localizer
+{
+public:
+  Localizer();
+  ~Localizer();
+private:
+  std::string myCurLocale;
+};
+
+} // GeomAlgoAPI_Tools
+
+#endif /* GEOMALGOAPI_TOOLS_H_ */