[Plib-cvs] plib/src/ssg ssgSaveIV.cxx,1.1,1.2
Brought to you by:
sjbaker
From: Steve B. <sj...@us...> - 2005-01-15 17:59:42
|
Update of /cvsroot/plib/plib/src/ssg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8037/plib/src/ssg Modified Files: ssgSaveIV.cxx Log Message: Removed dynamic_cast operators. The code looks cleaner with isAKindOf anyway. Index: ssgSaveIV.cxx =================================================================== RCS file: /cvsroot/plib/plib/src/ssg/ssgSaveIV.cxx,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ssgSaveIV.cxx 26 Sep 2004 09:38:52 -0000 1.1 +++ ssgSaveIV.cxx 15 Jan 2005 17:59:31 -0000 1.2 @@ -96,11 +96,13 @@ indent( f ); fprintf( f, "# %d triangles, %d verts, %d normals, %d colours, %d texturecoords\n", cnt, nv,nn,nc,nt ) ; - if ( st ) - state = dynamic_cast<ssgSimpleState*>( st ) ; - - if ( state ) + if ( st && st -> isAKindOf ( ssgTypeSimpleState() ) ) + { + state = (ssgSimpleState*) st ; textureName = state->getTextureFilename(); + } + else + state = NULL ; if ( state || nc ) { @@ -230,30 +232,27 @@ const char *name = ent->getName() ; fprintf( f, "# %s (%s)\n", ent->getTypeName(), (name)?name:"unnamed") ; - ssgBranch *branch = dynamic_cast<ssgBranch*>( ent ) ; - if ( branch ) + if ( ent && ent -> isAKindOf ( ssgTypeBranch () ) ) { + ssgBranch *branch = (ssgBranch*) ent ; + // ssg's branch nodes are translated to inventor's separator node. indent( f ) ; fprintf( f,"Separator {\n" ) ; indentLevel++ ; - ssgTransform *transform = dynamic_cast<ssgTransform*>( branch ) ; - // If this branch is a transform, we need to convert it. - if ( transform ) - writeTransform( transform, f ) ; - } - ssgLeaf *leaf = dynamic_cast<ssgLeaf*>( ent ) ; - if ( leaf ) - writeLeaf( leaf, f ) ; + if ( branch -> isAKindOf ( ssgTypeTransform() ) ) + writeTransform( (ssgTransform*) branch, f ) ; + } + else + writeLeaf( (ssgLeaf*) ent, f ) ; } // Handles post-order traversal of the ssg hierarchy. static void postHandle ( ssgEntity *ent, FILE *f ) { - ssgBranch *branch = dynamic_cast<ssgBranch*>( ent ) ; - if ( branch ) + if ( ent && ent -> isAKindOf ( ssgTypeBranch() ) ) { // For branches, we use IV's Seperator, which we need to close now. indentLevel-- ; @@ -267,9 +266,10 @@ static void walkTree ( ssgEntity *ent, FILE *f ) { preHandle( ent, f ) ; - ssgBranch *branch = dynamic_cast<ssgBranch*>( ent ) ; - if ( branch ) + if ( ent && ent -> isAKindOf ( ssgTypeBranch() ) ) { + ssgBranch *branch = (ssgBranch*) ent ; + for ( int i=0; i<branch->getNumKids(); i++ ) { ssgEntity *kid = branch->getKid( i ); |