Skip to content
Snippets Groups Projects
Commit ee3740b1 authored by Martin Schultz's avatar Martin Schultz
Browse files

refs #2421

* fileOBJ uses utils again


git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@20893 383ad7c9-94d9-4d36-a494-682f7c89f535
parent f8698a51
No related branches found
No related tags found
No related merge requests found
......@@ -63,7 +63,7 @@
#include <iostream>
#include <algorithm>
#include <OpenFlipper/Utils/FileIO/NumberParsing.hh>
// Defines for the type handling drop down box
#define TYPEAUTODETECT 0
......@@ -71,134 +71,10 @@
#define TYPEPOLY 2
#define TYPETRIANGLE 3
using namespace Utils;
//-----------------------------------------------------------------------------
// help functions
namespace{
float getFloat( QTextStream& _source)
{
QString rawNumber;
_source >> rawNumber;
//decimal part > 0
float highPart = 0.0f;
//decimal part < 0
float lowPart = 0.0f;
//sign of the decimal
float sign = 1.0;
//counter to concatenate high and lowaprt
int n = 0;
QString::Iterator it = rawNumber.begin();
QString::Iterator end = rawNumber.end();
if(*it == QLatin1Char('-'))
{
//we have a negative float
sign = sign * -1.0;
it++;
}
for (;it != end;it++)
{
//we have read a digit
if(it->isDigit())
{
highPart *=10;
highPart += it->digitValue();
}
else
{
//stop counting the highPart if its not a digit
it++;
break;
}
}
for (;it != end;it++)
{
//we assume to have read a digit
if(it->isDigit())
{
lowPart *=10;
lowPart += it->digitValue();
n++;
}
else
{
//stop counting the highPart dont increment here!
// otherwise we cant detect if we successful converted
break;
}
}
// if something went wrong during decoding use the standard decoding
if(it != end)
{
return rawNumber.toFloat();
}
return sign * (highPart + lowPart / std::pow(10.0,n));
}
double getDouble( QTextStream& _source)
{
QString rawNumber;
_source >> rawNumber;
//decimal part > 0
double highPart = 0.0f;
//decimal part < 0
double lowPart = 0.0f;
//sign of the decimal
double sign = 1.0;
//counter to concatenate high and lowaprt
int n = 0;
QString::Iterator it = rawNumber.begin();
QString::Iterator end = rawNumber.end();
if(*it == QLatin1Char('-'))
{
//we have a negative float
sign = sign * -1.0;
it++;
}
for (;it != end;it++)
{
//we have read a digit
if(it->isDigit())
{
highPart *=10;
highPart += it->digitValue();
}
else
{
//stop counting the highPart if its not a digit
it++;
break;
}
}
for (;it != end;it++)
{
//we assume to have read a digit
if(it->isDigit())
{
lowPart *=10;
lowPart += it->digitValue();
n++;
}
else
{
//stop counting the highPart dont increment here!
// otherwise we cant detect if we successful converted
break;
}
}
// if something went wrong during decoding use the standard decoding
if(it != end)
{
return rawNumber.toDouble();
}
return sign * (highPart + lowPart / std::pow(10.0,n));
}
}
void remove_duplicated_vertices(VHandles& _indices)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment