Merge pull request #316 from tgnottingham/master
Allow numbers starting with decimal in fast_atof. Allow several spaces between numbers in OBJ files.pull/321/head
commit
b7d46b29ad
|
@ -233,12 +233,13 @@ void ObjFileParser::copyNextLine(char *pBuffer, size_t length)
|
|||
// -------------------------------------------------------------------
|
||||
void ObjFileParser::getVector( std::vector<aiVector3D> &point3d_array ) {
|
||||
size_t numComponents( 0 );
|
||||
DataArrayIt tmp( m_DataIt );
|
||||
const char* tmp( &m_DataIt[0] );
|
||||
while( !IsLineEnd( *tmp ) ) {
|
||||
if( *tmp == ' ' ) {
|
||||
++numComponents;
|
||||
if ( !SkipSpaces( &tmp ) ) {
|
||||
break;
|
||||
}
|
||||
tmp++;
|
||||
SkipToken( tmp );
|
||||
++numComponents;
|
||||
}
|
||||
float x, y, z;
|
||||
if( 2 == numComponents ) {
|
||||
|
|
|
@ -229,14 +229,26 @@ inline uint64_t strtoul10_64( const char* in, const char** out=0, unsigned int*
|
|||
template <typename Real>
|
||||
inline const char* fast_atoreal_move( const char* c, Real& out, bool check_comma = true)
|
||||
{
|
||||
Real f;
|
||||
Real f = 0;
|
||||
|
||||
bool inv = (*c == '-');
|
||||
if (inv || *c == '+') {
|
||||
++c;
|
||||
}
|
||||
|
||||
if (!(c[0] >= '0' && c[0] <= '9') &&
|
||||
!(c[0] == '.' && c[1] >= '0' && c[1] <= '9'))
|
||||
{
|
||||
throw std::invalid_argument("Cannot parse string "
|
||||
"as real number: does not start with digit "
|
||||
"or decimal point followed by digit.");
|
||||
}
|
||||
|
||||
if (*c != '.')
|
||||
{
|
||||
f = static_cast<Real>( strtoul10_64 ( c, &c) );
|
||||
}
|
||||
|
||||
if ((*c == '.' || (check_comma && c[0] == ',')) && c[1] >= '0' && c[1] <= '9')
|
||||
{
|
||||
++c;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
v 1.0 2.0 3.0
|
||||
v 2.0 3.0 1.0
|
||||
v 3.0 1.0 2.0
|
||||
v 1.0 2.0 3.0
|
||||
|
||||
vt 1.0 2.0 3.0
|
||||
vt 2.0 3.0 1.0
|
||||
vt 3.0 1.0 2.0
|
||||
vt 1.0 2.0 3.0
|
||||
|
||||
f 1 2 3
|
|
@ -0,0 +1,23 @@
|
|||
v 0 0 0
|
||||
|
||||
v 1 2. 3.0
|
||||
v +1 +2. +3.0
|
||||
v -1 -2. -3.0
|
||||
|
||||
v 1e2 2.e1 3.1e2
|
||||
v +1e2 +2.e1 +3.1e2
|
||||
v -1e2 -2.e1 -3.1e2
|
||||
|
||||
v 1e+2 2.e+1 3.1+e2
|
||||
v +1e+2 +2.e+1 +3.1+e2
|
||||
v -1e+2 -2.e+1 -3.1+e2
|
||||
|
||||
v 1e-2 2.e-1 3.1-e2
|
||||
v +1e-2 +2.e-1 +3.1-e2
|
||||
v -1e-2 -2.e-1 -3.1-e2
|
||||
|
||||
v 1e10 2.e01 3.1e10
|
||||
|
||||
v 1E2 2.E1 3.1E2
|
||||
|
||||
f 1 2 4
|
Loading…
Reference in New Issue