00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef lint
00038 static const char RCSid[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/librt/comb.c,v 14.14 2006/09/16 02:04:24 lbutler Exp $ (ARL)";
00039 #endif
00040
00041 #include "common.h"
00042
00043 #include <stdlib.h>
00044 #include <stdio.h>
00045 #include <math.h>
00046 #include <string.h>
00047
00048 #include "machine.h"
00049 #include "bu.h"
00050 #include "vmath.h"
00051 #include "bn.h"
00052 #include "nmg.h"
00053 #include "rtgeom.h"
00054 #include "raytrace.h"
00055 #include "../librt/debug.h"
00056
00057
00058
00059
00060 void
00061 Print_tree(union tree *tree)
00062 {
00063 char *str;
00064
00065 str = (char *)rt_pr_tree_str( tree );
00066 if( str != NULL )
00067 {
00068 printf( "%s\n" , str );
00069 bu_free( str , "Print_tree" );
00070 }
00071 else
00072 printf( "NULL Tree\n" );
00073 }
00074
00075 int
00076 main(int argc, char *argv[])
00077 {
00078 struct db_i *dbip;
00079 struct directory *dp;
00080 struct rt_db_internal ip;
00081 struct rt_comb_internal *comb;
00082 mat_t identity_mat;
00083 int i;
00084 struct bu_vls file;
00085
00086 bu_debug = BU_DEBUG_MEM_CHECK | BU_DEBUG_COREDUMP;
00087
00088 if( argc < 3 )
00089 {
00090 fprintf( stderr , "Usage:\n\t%s db_file object1 object2 ...\n" , argv[0] );
00091 return 1;
00092 }
00093
00094 MAT_IDN( identity_mat );
00095 bu_vls_init( &file );
00096
00097 if( (dbip = db_open( argv[1] , "r" ) ) == NULL )
00098 {
00099 fprintf( stderr , "Cannot open %s\n" , argv[1] );
00100 perror( "test" );
00101 return 1;
00102 }
00103
00104 rt_init_resource( &rt_uniresource, 0, NULL );
00105
00106
00107 db_dirbuild( dbip );
00108
00109 for( i=2 ; i<argc ; i++ )
00110 {
00111 printf( "%s\n" , argv[i] );
00112
00113 dp = db_lookup( dbip , argv[i] , 1 );
00114
00115 if( rt_db_get_internal( &ip, dp, dbip, NULL, &rt_uniresource ) < 0 ) {
00116 bu_log("import of %s failed\n", dp->d_namep);
00117 continue;
00118 }
00119
00120 RT_CK_DB_INTERNAL( &ip );
00121 bu_mem_barriercheck();
00122
00123 if( ip.idb_type != ID_COMBINATION )
00124 {
00125 bu_log( "idb_type = %d\n" , ip.idb_type );
00126 rt_db_free_internal( &ip, &rt_uniresource );
00127 continue;
00128 }
00129
00130 comb = (struct rt_comb_internal *)ip.idb_ptr;
00131 RT_CK_COMB(comb);
00132 if( comb->region_flag )
00133 {
00134 bu_log( "\tRegion id = %d, aircode = %d GIFTmater = %d, los = %d\n",
00135 comb->region_id, comb->aircode, comb->GIFTmater, comb->los );
00136 }
00137 bu_log( "\trgb_valid = %d, color = %d/%d/%d\n" , comb->rgb_valid , V3ARGS( comb->rgb ) );
00138 bu_log( "\tshader = %s (%s)\n" ,
00139 bu_vls_addr( &comb->shader ),
00140 bu_vls_addr( &comb->material )
00141 );
00142
00143
00144 bu_log( "Pretty print:\n" );
00145 Print_tree( comb->tree );
00146
00147
00148 bu_log( "Standard print:\n" );
00149 rt_pr_tree( comb->tree, 1 );
00150
00151
00152 {
00153 struct bu_vls str;
00154 bu_vls_init( &str );
00155 rt_pr_tree_vls( &str, comb->tree );
00156 bu_log("%s\n", bu_vls_addr(&str) );
00157 bu_vls_free(&str );
00158 }
00159
00160
00161 if( db_ck_v4gift_tree( comb->tree ) < 0 )
00162 bu_log("ERROR: db_ck_v4gift_tree is unhappy\n");
00163
00164
00165 rt_db_free_internal( &ip, &rt_uniresource );
00166
00167 }
00168
00169 return 0;
00170 }
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180