소스 검색

bugfix: add correct handling for metric line end for example file.

Signed-off-by: Kim Kulling <[email protected]>
Kim Kulling 11 년 전
부모
커밋
dbf9536213
3개의 변경된 파일23개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 0
      .gitignore
  2. 21 9
      code/OpenGEXParser.cpp
  3. 1 0
      code/OpenGEXParser.h

+ 1 - 0
.gitignore

@@ -47,3 +47,4 @@ test/gtest/src/gtest-stamp/gtest-build.cmake
 test/gtest/src/gtest-stamp/Debug/gtest-patch
 *.cache
 test/gtest/src/gtest-stamp/Debug/gtest-build
+*.lib

+ 21 - 9
code/OpenGEXParser.cpp

@@ -189,6 +189,17 @@ bool OpenGEXParser::skipComments() {
     return skipped;
 }
 
+//------------------------------------------------------------------------------------------------
+void OpenGEXParser::readUntilEndOfLine() {
+    while( !IsLineEnd( m_buffer[ m_index ] ) ) {
+        ++m_index;
+    }
+    ++m_index;
+    if( IsLineEnd( m_buffer[ m_index ] ) ) {
+        ++m_index;
+    }
+}
+
 //------------------------------------------------------------------------------------------------
 bool OpenGEXParser::parseNextNode() {
     std::string token( getNextToken() );
@@ -202,8 +213,11 @@ bool OpenGEXParser::parseNextNode() {
         if( !getNodeData( nodeType ) ) {
             return false;
         }
+        
+        readUntilEndOfLine();
 
         m_nodeTypeStack.pop_back();
+
     }
 
     return true;
@@ -329,21 +343,19 @@ bool OpenGEXParser::getMetricAttributeKey( std::string &attribName ) {
 
 //------------------------------------------------------------------------------------------------
 bool OpenGEXParser::onMetricNode( const std::string &attribName ) {
+    float value( 0.0f );
     bool success( true );
     if( "distance" == attribName ) {
-        float distance( 0.0f );
-        if( getFloatData( 1, &distance ) ) {
-            m_model.m_metrics.m_distance = distance;
+        if( getFloatData( 1, &value ) ) {
+            m_model.m_metrics.m_distance = value;
         }
     } else if( "angle" == attribName ) {
-        float angle( 0.0f );
-        if( getFloatData( 1, &angle ) ) {
-            m_model.m_metrics.m_angle = angle;
+        if( getFloatData( 1, &value ) ) {
+            m_model.m_metrics.m_angle = value;
         }
     } else if( "time" == attribName ) {
-        float time( 0.0f );
-        if( getFloatData( 1, &time ) ) {
-            m_model.m_metrics.m_time = time;
+        if( getFloatData( 1, &value ) ) {
+            m_model.m_metrics.m_time = value;
         }
     } else if( "up" == attribName ) {
         std::string up;

+ 1 - 0
code/OpenGEXParser.h

@@ -87,6 +87,7 @@ public:
 protected:
     std::string getNextToken();
     bool skipComments();
+    void readUntilEndOfLine();
     bool parseNextNode();
     bool getNodeHeader( std::string &name );
     bool getBracketOpen();