Commit cb91e095 authored by Wayne Stambaugh's avatar Wayne Stambaugh
Browse files

Coding policy fixes and comment out debugging output.

parent 5f70ec63
Loading
Loading
Loading
Loading
+63 −56
Original line number Diff line number Diff line
@@ -56,8 +56,7 @@ char SkipGetChar ( FILE* File )

                    return EOF;
                }
            }
            while((c == ' ') || (c == '\t') || (c == '{') || (c == '['));
            } while( (c == ' ') || (c == '\t') || (c == '{') || (c == '[') );
        }

        if( (c == '#') || (c == '\n') ||  (c == '\r') || (c == 0) || (c == ',') )
@@ -72,8 +71,7 @@ char SkipGetChar ( FILE* File )
                        // DBG( printf( "EOF\n" ) );
                        return EOF;
                    }
                }
                while((c != '\n') &&  (c != '\r') && (c != 0) && (c != ','));
                } while( (c != '\n') &&  (c != '\r') && (c != 0) && (c != ',') );
            }
            else
            {
@@ -94,27 +92,30 @@ char SkipGetChar ( FILE* File )

char* GetNextTag( FILE* File, char* tag )
{

    char c = SkipGetChar( File );

    if( c == EOF )
    {
        return NULL;
    }

    tag[0]  = c;
    tag[1]  = 0;

    // DBG( printf( "tag[0] %c\n", tag[0] ) );
    if( (c != '}') && (c != ']') )
    {
        char* dst = &tag[1];

        while( fscanf( File, "%c", dst ) )
        {
            if( (*dst == ' ') || (*dst == '[') || (*dst == '{') ||
                (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') )
            if( (*dst == ' ') || (*dst == '[') || (*dst == '{')
                || (*dst == '\t') || (*dst == '\n')|| (*dst == '\r') )
            {
                *dst = 0;
                break;
            }

            dst++;
        }

@@ -136,6 +137,7 @@ char* GetNextTag( FILE* File, char* tag )
int read_NotImplemented( FILE* File, char closeChar )
{
    char c;

    // DBG( printf( "look for %c\n", closeChar) );
    while( ( c = fgetc( File ) ) != EOF )
    {
@@ -143,18 +145,20 @@ int read_NotImplemented( FILE* File, char closeChar)
        {
            // DBG( printf( "{\n") );
            read_NotImplemented( File, '}' );
        } else if( c == '[' )
        }
        else if( c == '[' )
        {
            // DBG( printf( "[\n") );
            read_NotImplemented( File, ']' );
        } else if( c == closeChar )
        }
        else if( c == closeChar )
        {
            // DBG( printf( "%c\n", closeChar) );
            return 0;
        }
    }

    DBG( printf( "  NotImplemented failed\n" ) );
    // DBG( printf( "  NotImplemented failed\n" ) );
    return -1;
}

@@ -166,6 +170,7 @@ int parseVertexList( FILE* File, std::vector< glm::vec3 > &dst_vector)
    dst_vector.clear();

    glm::vec3 vertex;

    while( parseVertex( File, vertex ) == 3 )
    {
        dst_vector.push_back( vertex );
@@ -191,6 +196,7 @@ int parseVertex( FILE* File, glm::vec3 &dst_vertex )
        // Puts again the read char in the buffer
        ungetc( s, File );
    }

    // DBG( printf( "ret%d(%.9f,%.9f,%.9f)", ret, a,b,c) );

    return ret;
@@ -201,6 +207,7 @@ int parseFloat( FILE* File, float *dst_float )
{
    float   value;
    int     ret = fscanf( File, "%e", &value );

    *dst_float = value;

    return ret;
+84 −78
Original line number Diff line number Diff line
@@ -71,9 +71,12 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
    float vrmlunits_to_3Dunits = g_Parm_3D_Visu.m_BiuTo3Dunits * UNITS3D_TO_UNITSPCB;
    glScalef( vrmlunits_to_3Dunits, vrmlunits_to_3Dunits, vrmlunits_to_3Dunits );

    glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y, GetMaster()->m_MatScale.z );
    glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y, GetMaster()->m_MatRotation.z );
    glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y, GetMaster()->m_MatPosition.z );
    glm::vec3 matScale( GetMaster()->m_MatScale.x, GetMaster()->m_MatScale.y,
            GetMaster()->m_MatScale.z );
    glm::vec3 matRot( GetMaster()->m_MatRotation.x, GetMaster()->m_MatRotation.y,
            GetMaster()->m_MatRotation.z );
    glm::vec3 matPos( GetMaster()->m_MatPosition.x, GetMaster()->m_MatPosition.y,
            GetMaster()->m_MatPosition.z );


#define SCALE_3D_CONV ( (IU_PER_MILS * 1000.0f) / UNITS3D_TO_UNITSPCB )
@@ -94,7 +97,6 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )

    while( GetNextTag( m_file, text ) )
    {

        if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) )
        {
            continue;
@@ -123,6 +125,7 @@ void VRML1_MODEL_PARSER::Load( const wxString aFilename )
    }
}


int VRML1_MODEL_PARSER::read_separator()
{
    char text[128];
@@ -131,7 +134,6 @@ int VRML1_MODEL_PARSER::read_separator()

    while( GetNextTag( m_file, text ) )
    {

        if( strcmp( text, "Material" ) == 0 )
        {
            readMaterial();
@@ -290,6 +292,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet( )
    return -1;
}


int VRML1_MODEL_PARSER::readMaterial_ambientColor()
{
    // DBG( printf( "    readMaterial_ambientColor\n" ) );
@@ -408,6 +411,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex()
    glm::ivec3 coord;

    int dummy;    // should be -1

    while( fscanf( m_file, "%d,%d,%d,%d,", &coord[0], &coord[1], &coord[2], &dummy ) )
    {
        std::vector<int> coord_list;
@@ -417,9 +421,9 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex()
        coord_list[1] = coord[1];
        coord_list[2] = coord[2];

        if( (coord[0] == coord[1]) ||
            (coord[0] == coord[2]) ||
            (coord[2] == coord[1]) )
        if( (coord[0] == coord[1])
            || (coord[0] == coord[2])
            || (coord[2] == coord[1]) )
        {
            // DBG( printf( "    invalid coordIndex at index %lu (%d, %d, %d, %d)\n", m_model->m_CoordIndex.size()+1,coord[0], coord[1], coord[2], dummy ) );
        }
@@ -428,6 +432,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_coordIndex()
        {
            // DBG( printf( "    Error at index %lu, -1 Expected, got %d\n", m_model->m_CoordIndex.size()+1, dummy  ) );
        }

        m_model->m_CoordIndex.push_back( coord_list );
    }

@@ -444,6 +449,7 @@ int VRML1_MODEL_PARSER::readIndexedFaceSet_materialIndex()
    m_model->m_MaterialIndex.clear();

    int index;

    while( fscanf( m_file, "%d,", &index ) )
    {
        m_model->m_MaterialIndex.push_back( index );
+145 −140
Original line number Diff line number Diff line
@@ -98,7 +98,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )

    while( GetNextTag( m_file, text ) )
    {

        if( ( text == NULL ) || ( *text == '}' ) || ( *text == ']' ) )
        {
            continue;
@@ -110,7 +109,6 @@ void VRML2_MODEL_PARSER::Load( const wxString aFilename )
            childs.push_back( m_model );

            read_Transform();

        }
        else if( strcmp( text, "DEF" ) == 0 )
        {
@@ -149,11 +147,13 @@ int VRML2_MODEL_PARSER::read_Transform()
        {
            continue;
        }

        if( ( *text == '}' ) )
        {
            // DBG( printf( "  } Exit Transform\n" ) );
            break;
        }

        if( strcmp( text, "translation" ) == 0 )
        {
            parseVertex( m_file, m_model->m_translation );
@@ -210,6 +210,7 @@ int VRML2_MODEL_PARSER::read_Transform()
        else if( strcmp( text, "whichChoice" ) == 0 )
        {
            int dummy;

            if( fscanf( m_file, "%d", &dummy ) != 1 )
            {
                // !TODO: log errors
@@ -236,7 +237,6 @@ int VRML2_MODEL_PARSER::read_Transform()
            read_Shape();

            m_model = parent;

        }
        else if( strcmp( text, "DEF" ) == 0 )
        {
@@ -244,10 +244,11 @@ int VRML2_MODEL_PARSER::read_Transform()
        }
        else
        {
            DBG( printf( "    %s NotImplemented\n", text ) );
            // DBG( printf( "    %s NotImplemented\n", text ) );
            read_NotImplemented( m_file, '}' );
        }
    }

    return 0;
}

@@ -276,7 +277,8 @@ int VRML2_MODEL_PARSER::read_DEF()
        if( strcmp( text, "Transform" ) == 0 )
        {
            return read_Transform();
        } else if( strcmp( text, "children" ) == 0 )
        }
        else if( strcmp( text, "children" ) == 0 )
        {
            // skip
        }
@@ -304,7 +306,7 @@ int VRML2_MODEL_PARSER::read_DEF()
        }
    }

    DBG( printf( "  DEF failed\n" ) );
    // DBG( printf( "  DEF failed\n" ) );
    return -1;
}

@@ -346,12 +348,12 @@ int VRML2_MODEL_PARSER::read_Shape()
        }
        else
        {
            DBG( printf( "    %s NotImplemented\n", text ) );
            // DBG( printf( "    %s NotImplemented\n", text ) );
            read_NotImplemented( m_file, '}' );
        }
    }

    DBG( printf( "  Shape failed\n") );
    // DBG( printf( "  Shape failed\n" ) );
    return -1;
}

@@ -380,7 +382,7 @@ int VRML2_MODEL_PARSER::read_Appearance()
        }
    }

    DBG( printf( "  Appearance failed\n") );
    // DBG( printf( "  Appearance failed\n" ) );
    return -1;
}

@@ -449,12 +451,13 @@ int VRML2_MODEL_PARSER::read_material()
                        return 0;
                    }
                }

                DBG( printf( "   read_material error: material not found\n" ) );
            }
        }
    }

    DBG( printf( "  failed material\n") );
    // DBG( printf( "  failed material\n" ) );
    return -1;
}

@@ -484,10 +487,12 @@ int VRML2_MODEL_PARSER::read_Material()
            parseVertex( m_file, vertex );
            // DBG( printf( "\n") );
            m_model->m_Materials->m_DiffuseColor.push_back( vertex );
        } else if( strcmp( text, "emissiveColor" ) == 0 )
        }
        else if( strcmp( text, "emissiveColor" ) == 0 )
        {
            // DBG( printf( "  emissiveColor") );
            parseVertex( m_file, vertex );

            // DBG( printf( "\n") );
            if( GetMaster()->m_use_modelfile_emissiveColor == true )
            {
@@ -513,7 +518,8 @@ int VRML2_MODEL_PARSER::read_Material()

            if( GetMaster()->m_use_modelfile_ambientIntensity == true )
            {
                m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity, ambientIntensity, ambientIntensity ) );
                m_model->m_Materials->m_AmbientColor.push_back( glm::vec3( ambientIntensity,
                                ambientIntensity, ambientIntensity ) );
            }
        }
        else if( strcmp( text, "transparency" ) == 0 )
@@ -542,7 +548,7 @@ int VRML2_MODEL_PARSER::read_Material()
        }
    }

    DBG( printf( "  Material failed\n") );
    // DBG( printf( "  Material failed\n" ) );
    return -1;
}

@@ -583,6 +589,7 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
        else if( strcmp( text, "colorPerVertex" ) == 0 )
        {
            GetNextTag( m_file, text );

            if( strcmp( text, "TRUE" ) )
            {
                // DBG( printf( "  colorPerVertex = true\n") );
@@ -592,7 +599,6 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
            {
                colorPerVertex = false;
            }

        }
        else if( strcmp( text, "Coordinate" ) == 0 )
        {
@@ -618,10 +624,9 @@ int VRML2_MODEL_PARSER::read_IndexedFaceSet()
        {
            read_colorIndex();
        }

    }

    DBG( printf( "  IndexedFaceSet failed %s\n", text) );
    // DBG( printf( "  IndexedFaceSet failed %s\n", text ) );
    return -1;
}

@@ -636,6 +641,7 @@ int VRML2_MODEL_PARSER::read_colorIndex()
    {
        int index;
        int first_index;

        while( fscanf( m_file, "%d, ", &index ) )
        {
            if( index == -1 )
@@ -677,6 +683,7 @@ int VRML2_MODEL_PARSER::read_NormalIndex()

    std::vector<int> coord_list;
    coord_list.clear();

    while( fscanf( m_file, "%d, ", &dummy ) == 1 )
    {
        if( dummy == -1 )
@@ -710,6 +717,7 @@ int VRML2_MODEL_PARSER::read_coordIndex()

    std::vector<int> coord_list;
    coord_list.clear();

    while( fscanf( m_file, "%d, ", &dummy ) == 1 )
    {
        if( dummy == -1 )
@@ -761,8 +769,6 @@ int VRML2_MODEL_PARSER::read_Color()
}




int VRML2_MODEL_PARSER::read_Normal()
{
    char text[128];
@@ -828,4 +834,3 @@ int VRML2_MODEL_PARSER::read_Coordinate()

    return -1;
}
+8 −7
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )

        return;
    }

    fclose( file );


@@ -97,5 +98,5 @@ void VRML_MODEL_PARSER::Load( const wxString aFilename )
        return;
    }

    DBG( printf( "Unknown VRML file format: %s\n", line ) );
    // DBG( printf( "Unknown VRML file format: %s\n", line ) );
}
+94 −88
Original line number Diff line number Diff line
@@ -43,11 +43,13 @@

X3D_MODEL_PARSER::X3D_MODEL_PARSER( S3D_MASTER* aMaster ) :
    S3D_MODEL_PARSER( aMaster )
{}
{
}


X3D_MODEL_PARSER::~X3D_MODEL_PARSER()
{}
{
}


void X3D_MODEL_PARSER::Load( const wxString aFilename )
@@ -197,11 +199,13 @@ void X3D_MODEL_PARSER::GetNodeProperties( wxXmlNode* aNode, PROPERTY_MAP& aProps
    }
}


/* Private ----- */

void X3D_MODEL_PARSER::readTransform( wxXmlNode* aTransformNode )
{
    NODE_LIST childnodes;

    GetChildsByName( aTransformNode, wxT( "Material" ), childnodes );

    for( NODE_LIST::iterator node = childnodes.begin();
@@ -234,6 +238,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
    glm::vec3 color;

    PROPERTY_MAP properties;

    GetNodeProperties( aMatNode, properties );

    // DEFine new Material named as value of DEF
@@ -246,10 +251,9 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )

        m_model->m_Materials = material;

        if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ],
                                 color ) )
        if( !parseDoubleTriplet( properties[ wxT( "diffuseColor" ) ], color ) )
        {
            DBG( printf("diffuseColor parsing error") );
            // DBG( printf( "diffuseColor parsing error" ) );
        }
        else
        {
@@ -258,7 +262,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )

        if( !parseDoubleTriplet( properties[ wxT( "specularColor" ) ], color ) )
        {
            DBG( printf("specularColor parsing error") );
            // DBG( printf( "specularColor parsing error" ) );
        }
        else
        {
@@ -267,7 +271,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )

        if( !parseDoubleTriplet( properties[ wxT( "emissiveColor" ) ], color ) )
        {
            DBG( printf("emissiveColor parsing error") );
            // DBG( printf( "emissiveColor parsing error" ) );
        }
        else
        {
@@ -283,7 +287,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
        }
        else
        {
            DBG( printf( "ambienterror" ) );
            // DBG( printf( "ambienterror" ) );
        }

        values.SetString( properties[ wxT( "shininess" ) ]  );
@@ -296,7 +300,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
        }
        else
        {
            DBG( printf( "shininess error" ) );
            // DBG( printf( "shininess error" ) );
        }

        values.SetString( properties[ wxT( "transparency" ) ] );
@@ -307,7 +311,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
        }
        else
        {
            DBG( printf( "trans error") );
            // DBG( printf( "trans error" ) );
        }

        // VRML
@@ -321,7 +325,6 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )

        vrml_materials.push_back( vrml_material );
    }

    // USE existing material named by value of USE
    else if( properties.find( wxT( "USE" ) ) != properties.end() )
    {
@@ -366,7 +369,7 @@ void X3D_MODEL_PARSER::readMaterial( wxXmlNode* aMatNode )
            }
        }

        DBG( printf( "ReadMaterial error: material not found\n" ) );
        // DBG( printf( "ReadMaterial error: material not found\n" ) );
    }
}

@@ -378,9 +381,9 @@ bool X3D_MODEL_PARSER::parseDoubleTriplet( const wxString& aData,

    double x, y, z;

    bool ret =  tokens.GetNextToken().ToDouble( &x ) &&
                tokens.GetNextToken().ToDouble( &y ) &&
                tokens.GetNextToken().ToDouble( &z );
    bool ret = tokens.GetNextToken().ToDouble( &x )
               && tokens.GetNextToken().ToDouble( &y )
               && tokens.GetNextToken().ToDouble( &z );

    aResult.x   = x;
    aResult.y   = y;
@@ -430,6 +433,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
     * --------------------------- */

    S3D_VERTEX translation;

    parseDoubleTriplet( aTransformProps[ wxT( "translation" ) ], translation );

    S3D_VERTEX scale;
@@ -440,12 +444,13 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,
    wxStringTokenizer tokens( aTransformProps[ wxT( "rotation" ) ] );

    double x, y, z;
    if( !(tokens.GetNextToken().ToDouble( &x ) &&
          tokens.GetNextToken().ToDouble( &y ) &&
          tokens.GetNextToken().ToDouble( &z ) &&
          tokens.GetNextToken().ToDouble( &angle ) ) )

    if( !( tokens.GetNextToken().ToDouble( &x )
           && tokens.GetNextToken().ToDouble( &y )
           && tokens.GetNextToken().ToDouble( &z )
           && tokens.GetNextToken().ToDouble( &angle ) ) )
    {
        DBG( printf("rotation read error") );
        // DBG( printf( "rotation read error" ) );
    }
    else
    {
@@ -482,7 +487,7 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,

    if( points.size() % 3 != 0 )
    {
        DBG( printf( "Number of points is incorrect" ) );
        // DBG( printf( "Number of points is incorrect" ) );
        return;
    }

@@ -549,13 +554,14 @@ void X3D_MODEL_PARSER::readIndexedFaceSet( wxXmlNode* aFaceNode,

        if( color_points.size() % 3 != 0 )
        {
            DBG( printf( "Number of points is incorrect" ) );
            // DBG( printf( "Number of points is incorrect" ) );
            return;
        }

        /* Create 3D face color from 3 color points
         */
        m_model->m_Materials->m_DiffuseColor.clear();

        for( unsigned id = 0; id < color_points.size() / 3; id++ )
        {
            m_model->m_MaterialIndex.push_back( id );