summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/assimp/code/ObjTools.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/3rdparty/assimp/code/ObjTools.h')
-rw-r--r--src/3rdparty/assimp/code/ObjTools.h86
1 files changed, 71 insertions, 15 deletions
diff --git a/src/3rdparty/assimp/code/ObjTools.h b/src/3rdparty/assimp/code/ObjTools.h
index 311965ce3..7236cedc0 100644
--- a/src/3rdparty/assimp/code/ObjTools.h
+++ b/src/3rdparty/assimp/code/ObjTools.h
@@ -2,7 +2,8 @@
Open Asset Import Library (assimp)
----------------------------------------------------------------------
-Copyright (c) 2006-2016, assimp team
+Copyright (c) 2006-2017, assimp team
+
All rights reserved.
Redistribution and use of this software in source and binary forms,
@@ -48,8 +49,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include "ParsingUtils.h"
#include <vector>
-namespace Assimp
-{
+namespace Assimp {
/** @brief Returns true, if the last entry of the buffer is reached.
* @param it Iterator of current position.
@@ -57,15 +57,14 @@ namespace Assimp
* @return true, if the end of the buffer is reached.
*/
template<class char_t>
-inline bool isEndOfBuffer( char_t it, char_t end )
-{
+inline bool isEndOfBuffer( char_t it, char_t end ) {
if ( it == end )
{
return true;
}
else
{
- end--;
+ --end;
}
return ( it == end );
}
@@ -80,8 +79,10 @@ inline Char_T getNextWord( Char_T pBuffer, Char_T pEnd )
{
while ( !isEndOfBuffer( pBuffer, pEnd ) )
{
- if( !IsSpaceOrNewLine( *pBuffer ) || IsLineEnd( *pBuffer ) )
- break;
+ if ( !IsSpaceOrNewLine( *pBuffer ) || IsLineEnd( *pBuffer ) ) {
+ //if ( *pBuffer != '\\' )
+ break;
+ }
pBuffer++;
}
return pBuffer;
@@ -115,14 +116,16 @@ inline char_t skipLine( char_t it, char_t end, unsigned int &uiLine ) {
while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it ) ) {
++it;
}
- if ( it != end )
- {
+
+ if ( it != end ) {
++it;
++uiLine;
}
// fix .. from time to time there are spaces at the beginning of a material line
- while ( it != end && (*it == '\t' || *it == ' ') )
+ while ( it != end && ( *it == '\t' || *it == ' ' ) ) {
++it;
+ }
+
return it;
}
@@ -142,11 +145,50 @@ inline char_t getName( char_t it, char_t end, std::string &name )
}
char *pStart = &( *it );
- while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it ) ) {
+ while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it )) {
++it;
}
- while( isEndOfBuffer( it, end ) || IsLineEnd( *it ) || IsSpaceOrNewLine( *it ) ) {
+ while(IsSpace( *it ) ) {
+ --it;
+ }
+ // Get name
+ // if there is no name, and the previous char is a separator, come back to start
+ while (&(*it) < pStart) {
+ ++it;
+ }
+ std::string strName( pStart, &(*it) );
+ if ( strName.empty() )
+ return it;
+ else
+ name = strName;
+
+ return it;
+}
+
+/** @brief Get a name from the current line. Do not preserve space
+ * in the middle, but trim it at the end.
+ * @param it set to current position
+ * @param end set to end of scratch buffer for readout
+ * @param name Separated name
+ * @return Current-iterator with new position
+ */
+template<class char_t>
+inline char_t getNameNoSpace( char_t it, char_t end, std::string &name )
+{
+ name = "";
+ if( isEndOfBuffer( it, end ) ) {
+ return end;
+ }
+
+ char *pStart = &( *it );
+ while( !isEndOfBuffer( it, end ) && !IsLineEnd( *it )
+ && !IsSpaceOrNewLine( *it ) ) {
+ ++it;
+ }
+
+ while( isEndOfBuffer( it, end ) || IsLineEnd( *it )
+ || IsSpaceOrNewLine( *it ) ) {
--it;
}
++it;
@@ -196,12 +238,12 @@ inline char_t CopyNextWord( char_t it, char_t end, char *pBuffer, size_t length
* @return Current-iterator with new position
*/
template<class char_t>
-inline char_t getFloat( char_t it, char_t end, float &value )
+inline char_t getFloat( char_t it, char_t end, ai_real &value )
{
static const size_t BUFFERSIZE = 1024;
char buffer[ BUFFERSIZE ];
it = CopyNextWord<char_t>( it, end, buffer, BUFFERSIZE );
- value = (float) fast_atof( buffer );
+ value = (ai_real) fast_atof( buffer );
return it;
}
@@ -246,6 +288,20 @@ string_type trim_whitespaces(string_type str)
return str;
}
+template<class T>
+bool hasLineEnd( T it, T end ) {
+ bool hasLineEnd( false );
+ while ( !isEndOfBuffer( it, end ) ) {
+ it++;
+ if ( IsLineEnd( it ) ) {
+ hasLineEnd = true;
+ break;
+ }
+ }
+
+ return hasLineEnd;
+}
+
} // Namespace Assimp
#endif // OBJ_TOOLS_H_INC