Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix for the atof problem

  • Loading branch information...
commit 08706edb09735297cd670dcdcc61ac4bbbe5352b 1 parent e0400d2
@rwaury rwaury authored
View
5 src/simulation/joint.cpp
@@ -8,6 +8,7 @@
#include <simulation/joint.hpp>
#include <iostream>
#include <util/tostring.hpp>
+#include <locale>
namespace sim {
@@ -141,6 +142,10 @@ Hinge __Hinge::load(const std::list<Object>& list, rapidxml::xml_node<>* node)
{
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
Vec3f pivot, pinDir;
int parentID = -1, childID = -1;
bool limited = false;
View
9 src/simulation/material.cpp
@@ -17,6 +17,7 @@
#include <string.h>
#include <util/tostring.hpp>
#include <util/erroradapters.hpp>
+#include <locale>
namespace sim {
@@ -46,6 +47,10 @@ void Material::load(rapidxml::xml_node<>* const node)
{
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
xml_attribute<>* attr = node->first_attribute("name");
if(attr) {
name = attr->value();
@@ -170,6 +175,10 @@ void MaterialPair::load(rapidxml::xml_node<>* node)
{
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
MaterialMgr& m = MaterialMgr::instance();
xml_attribute<> *attr = node->first_attribute("mat0");
View
9 src/simulation/object.cpp
@@ -17,6 +17,7 @@
#include <stdio.h>
#include <util/tostring.hpp>
#include <boost/foreach.hpp>
+#include <locale>
namespace sim {
@@ -453,6 +454,10 @@ RigidBody __RigidBody::load(rapidxml::xml_node<>* node)
{
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
int freezeState = 0; Vec4f damping(0.1f, 0.1f, 0.1f, 0.1f); // all except dominos use it
float w, h, d; // box
float x, y, z; // sphere
@@ -901,6 +906,10 @@ Convex __Convex::load(rapidxml::xml_node<>* node)
{
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
Mat4f matrix = Mat4f();
int freezeState;
Vec4f damping = Vec4f();
View
67 src/simulation/simulation.cpp
@@ -22,6 +22,7 @@
#include <util/threadcounter.hpp>
#include <util/tostring.hpp>
#include <stdlib.h>
+#include <locale>
namespace sim {
@@ -168,68 +169,6 @@ Simulation::~Simulation()
m_mouseAdapter.removeListener(this);
}
-// TODO I didn't find the todo just paste this code where it belongs
-/* template load/save */
-/*
-void Simulation::saveTemplate(const std::string& fileName, __Object& object)
-{
- using namespace rapidxml;
- // create document
- xml_document<> doc;
-
- // create XML declaration
- xml_node<>* declaration = doc.allocate_node(node_declaration);
- doc.append_node(declaration);
- declaration->append_attribute(doc.allocate_attribute("version", "1.0"));
- declaration->append_attribute(doc.allocate_attribute("encoding", "utf-8"));
-
-
- // create root element "template"
- xml_node<>* t = doc.allocate_node(node_element, "template");
- doc.append_node(t);
-
- __Object::save(object, t, &doc);
-
- std::string s;
- print(std::back_inserter(s), doc, 0);
-
- // save document
- std::ofstream myfile;
- myfile.open (fileName.c_str());
- myfile << s;
- myfile.close();
-
- // frees all memory allocated to the nodes
- doc.clear();
-
-}
-
-void Simulation::loadTemplate(const std::string& fileName)
-{
- using namespace rapidxml;
-
- file<char> f(fileName.c_str());
-
- char* m = f.data();
-
- // TODO add exception handling
- xml_document<> doc;
- doc.parse<0>(m);
-
- // this is important so we don't parse the template tag but the object or compound tag
- xml_node<>* nodes = doc.first_node();
-
- // only the first tag is loaded the rest will be ignored
- xml_node<>* node = nodes->first_node();
- std::string type(node->name());
-
- if (type == "object" || type == "compound") {
- Object object = __Object::load(node);
- add(object);
- }
-}*/ /* template load/save END */
-
-
void Simulation::save(const std::string& fileName)
{
using namespace rapidxml;
@@ -305,6 +244,10 @@ void Simulation::load(const std::string& fileName)
using namespace rapidxml;
+ // this prevents that the atof functions fails on German systems
+ // since they use "," as a separator for floats
+ setlocale(LC_ALL,"C");
+
char* m;
file<char>* f = 0;
Please sign in to comment.
Something went wrong with that request. Please try again.