Revision: 50328
          http://brlcad.svn.sourceforge.net/brlcad/?rev=50328&view=rev
Author:   tbrowder2
Date:     2012-04-26 19:45:10 +0000 (Thu, 26 Apr 2012)
Log Message:
-----------
ws, style

Modified Paths:
--------------
    brlcad/trunk/src/conv/nmg/g-nmg.c

Modified: brlcad/trunk/src/conv/nmg/g-nmg.c
===================================================================
--- brlcad/trunk/src/conv/nmg/g-nmg.c   2012-04-26 18:56:44 UTC (rev 50327)
+++ brlcad/trunk/src/conv/nmg/g-nmg.c   2012-04-26 19:45:10 UTC (rev 50328)
@@ -75,7 +75,7 @@
     union tree *ret_tree = NULL;
 
     /* Begin bomb protection */
-    if ( !BU_SETJUMP ) {
+    if (!BU_SETJUMP) {
        /* try */
 
        ret_tree = nmg_booltree_evaluate(curtree, tsp->ts_tol, 
&rt_uniresource);        /* librt/nmg_bool.c */
@@ -87,8 +87,8 @@
        char *sofar;
 
        sofar = db_path_to_string(pathp);
-       bu_log( "FAILED: %s\n", sofar );
-       bu_free( (char *)sofar, "sofar" );
+       bu_log("FAILED: %s\n", sofar);
+       bu_free((char *)sofar, "sofar");
 
        /* Sometimes the NMG library adds debugging bits when
         * it detects an internal error, before bombing out.
@@ -102,7 +102,7 @@
        db_free_tree(curtree, &rt_uniresource); /* Does an nmg_kr() */
 
        /* Get rid of (m)any other intermediate structures */
-       if ( (*tsp->ts_m)->magic == NMG_MODEL_MAGIC ) {
+       if ((*tsp->ts_m)->magic == NMG_MODEL_MAGIC) {
            nmg_km(*tsp->ts_m);
        } else {
            bu_log("WARNING: tsp->ts_m pointer corrupted, ignoring it.\n");
@@ -162,33 +162,33 @@
 
     regions_converted++;
 
-    if ( ret_tree ) {
+    if (ret_tree) {
        r = ret_tree->tr_d.td_r;
-       if ( do_bots && r ) {
-           bot = nmg_bot( BU_LIST_FIRST( shell, &r->s_hd ), tsp->ts_tol );
+       if (do_bots && r) {
+           bot = nmg_bot(BU_LIST_FIRST(shell, &r->s_hd), tsp->ts_tol);
        }
     } else {
        if (verbose) {
-           printf( "\tNothing left of this region after Boolean evaluation\n" 
);
+           printf("\tNothing left of this region after Boolean evaluation\n");
        }
        r = (struct nmgregion *)NULL;
     }
 
     if (tsp->ts_mater.ma_shader) {
-       shader = strtok( tsp->ts_mater.ma_shader, tok_sep );
-       matparm = strtok( (char *)NULL, tok_sep );
+       shader = strtok(tsp->ts_mater.ma_shader, tok_sep);
+       matparm = strtok((char *)NULL, tok_sep);
     } else {
        shader = NULL;
        matparm = NULL;
     }
 
-    if ( matparm ) {
-       bu_vls_strcpy( &shader_params, matparm );
-       matparm = strtok( (char *)NULL, tok_sep );
-       while ( matparm ) {
-           bu_vls_putc( &shader_params, ' ' );
-           bu_vls_strcat( &shader_params, matparm );
-           matparm = strtok( (char *)NULL, tok_sep );
+    if (matparm) {
+       bu_vls_strcpy(&shader_params, matparm);
+       matparm = strtok((char *)NULL, tok_sep);
+       while (matparm) {
+           bu_vls_putc(&shader_params, ' ');
+           bu_vls_strcat(&shader_params, matparm);
+           matparm = strtok((char *)NULL, tok_sep);
        }
     }
     if (r != (struct nmgregion *)NULL) {
@@ -197,13 +197,13 @@
        int empty_model=0;
 
        /* Kill cracks */
-       s = BU_LIST_FIRST( shell, &r->s_hd );
-       while ( BU_LIST_NOT_HEAD( &s->l, &r->s_hd ) ) {
+       s = BU_LIST_FIRST(shell, &r->s_hd);
+       while (BU_LIST_NOT_HEAD(&s->l, &r->s_hd)) {
            struct shell *next_s;
 
-           next_s = BU_LIST_PNEXT( shell, &s->l );
-           if ( nmg_kill_cracks( s ) ) {
-               if ( nmg_ks( s ) ) {
+           next_s = BU_LIST_PNEXT(shell, &s->l);
+           if (nmg_kill_cracks(s)) {
+               if (nmg_ks(s)) {
                    empty_region = 1;
                    break;
                }
@@ -212,24 +212,24 @@
        }
 
        /* kill zero length edgeuses */
-       if ( !empty_region ) {
-           empty_model = nmg_kill_zero_length_edgeuses( *tsp->ts_m );
+       if (!empty_region) {
+           empty_model = nmg_kill_zero_length_edgeuses(*tsp->ts_m);
        }
 
-       if ( !empty_region && !empty_model ) {
+       if (!empty_region && !empty_model) {
            /* Write the nmgregion to the output file */
            nmg_count++;
-           sprintf( nmg_name, "nmg.%d", nmg_count );
+           sprintf(nmg_name, "nmg.%d", nmg_count);
 
-           if ( do_bots ) {
-               wdb_export( fp_out, nmg_name, (genptr_t)bot, ID_BOT, 1.0 );
+           if (do_bots) {
+               wdb_export(fp_out, nmg_name, (genptr_t)bot, ID_BOT, 1.0);
            } else {
-               mk_nmg( fp_out, nmg_name, r->m_p );
+               mk_nmg(fp_out, nmg_name, r->m_p);
            }
        }
 
        /* Now make a normal brlcad region */
-       if ( tsp->ts_mater.ma_color_valid ) {
+       if (tsp->ts_mater.ma_color_valid) {
            rgb[0] = (int)(tsp->ts_mater.ma_color[0] * 255.0);
            rgb[1] = (int)(tsp->ts_mater.ma_color[1] * 255.0);
            rgb[2] = (int)(tsp->ts_mater.ma_color[2] * 255.0);
@@ -238,27 +238,27 @@
        else
            color = (unsigned char *)NULL;
 
-       BU_LIST_INIT( &headp.l );
-       (void)mk_addmember( nmg_name, &headp.l, NULL, WMOP_UNION );
-       if ( mk_lrcomb( fp_out,
+       BU_LIST_INIT(&headp.l);
+       (void)mk_addmember(nmg_name, &headp.l, NULL, WMOP_UNION);
+       if (mk_lrcomb(fp_out,
                        pathp->fp_names[pathp->fp_len-1]->d_namep, &headp, 1,
-                       shader, bu_vls_addr( &shader_params ), color,
+                       shader, bu_vls_addr(&shader_params), color,
                        tsp->ts_regionid, tsp->ts_aircode, tsp->ts_gmater,
-                       tsp->ts_los, tsp->ts_mater.ma_cinherit ) ) {
-           bu_log( "G-nmg: error in making region (%s)\n", 
pathp->fp_names[pathp->fp_len-1]->d_namep );
+                       tsp->ts_los, tsp->ts_mater.ma_cinherit)) {
+           bu_log("G-nmg: error in making region (%s)\n", 
pathp->fp_names[pathp->fp_len-1]->d_namep);
        }
     } else {
-       BU_LIST_INIT( &headp.l );
-       if ( mk_lrcomb( fp_out,
+       BU_LIST_INIT(&headp.l);
+       if (mk_lrcomb(fp_out,
                        pathp->fp_names[pathp->fp_len-1]->d_namep, &headp, 1,
-                       shader, bu_vls_addr( &shader_params ), color,
+                       shader, bu_vls_addr(&shader_params), color,
                        tsp->ts_regionid, tsp->ts_aircode, tsp->ts_gmater,
-                       tsp->ts_los, tsp->ts_mater.ma_cinherit ) ) {
-           bu_log( "G-nmg: error in making region (%s)\n", 
pathp->fp_names[pathp->fp_len-1]->d_namep );
+                       tsp->ts_los, tsp->ts_mater.ma_cinherit)) {
+           bu_log("G-nmg: error in making region (%s)\n", 
pathp->fp_names[pathp->fp_len-1]->d_namep);
        }
     }
 
-    bu_vls_free( &shader_params );
+    bu_vls_free(&shader_params);
 
     /*
      *  Dispose of original tree, so that all associated dynamic
@@ -268,8 +268,8 @@
      */
     db_free_tree(curtree, &rt_uniresource);            /* Does an nmg_kr() */
 
-    if ( RT_G_DEBUG&DEBUG_MEM_FULL )
-       bu_prmem( "At end of do_region_end()" );
+    if (RT_G_DEBUG&DEBUG_MEM_FULL)
+       bu_prmem("At end of do_region_end()");
 
     BU_GET(curtree, union tree);
     RT_TREE_INIT(curtree);
@@ -294,12 +294,12 @@
     char matname[32];
     char matparm[60];
 
-    if ( dp->d_uses < 0 )
+    if (dp->d_uses < 0)
        return;
 
-    dp->d_uses = (-1);
+    dp->d_uses = -1;
 
-    if ( dp->d_flags & RT_DIR_REGION ) {
+    if (dp->d_flags & RT_DIR_REGION) {
        char **name;
 
        /* convert a region to NMG's */
@@ -312,13 +312,13 @@
 
        name = (&(dp->d_namep));
 
-       (void) db_walk_tree( db, 1, (const char **)name,
-                            1,
-                            &tree_state,
-                            0,
-                            do_region_end,
-                            nmg_booltree_leaf_tess,
-                            (genptr_t)NULL);
+       (void) db_walk_tree(db, 1, (const char **)name,
+                            1,
+                            &tree_state,
+                            0,
+                            do_region_end,
+                            nmg_booltree_leaf_tess,
+                            (genptr_t)NULL);
 
        /* Release dynamic storage */
        nmg_km(the_model);
@@ -328,49 +328,49 @@
 
     /* have a combination that is not a region */
 
-    if ( rt_db_get_internal( &intern, dp, db, (fastf_t *)NULL, &rt_uniresource 
) < 0 ) {
-       bu_log( "Cannot get internal form of combination (%s)\n", dp->d_namep );
+    if (rt_db_get_internal(&intern, dp, db, (fastf_t *)NULL, &rt_uniresource) 
< 0) {
+       bu_log("Cannot get internal form of combination (%s)\n", dp->d_namep);
        return;
     }
     comb = (struct rt_comb_internal *)intern.idb_ptr;
-    RT_CK_COMB( comb );
+    RT_CK_COMB(comb);
 
-    if ( verbose )
-       bu_log( "Combination - %s\n", dp->d_namep );
+    if (verbose)
+       bu_log("Combination - %s\n", dp->d_namep);
 
-    if ( comb->tree && db_ck_v4gift_tree( comb->tree ) < 0 )   {
-       db_non_union_push( comb->tree, &rt_uniresource );
-       if ( db_ck_v4gift_tree( comb->tree ) < 0 ) {
-           bu_log( "Cannot flatten tree (%s) for editing\n", dp->d_namep );
+    if (comb->tree && db_ck_v4gift_tree(comb->tree) < 0) {
+       db_non_union_push(comb->tree, &rt_uniresource);
+       if (db_ck_v4gift_tree(comb->tree) < 0) {
+           bu_log("Cannot flatten tree (%s) for editing\n", dp->d_namep);
            return;
        }
     }
-    node_count = db_tree_nleaves( comb->tree );
-    if ( node_count > 0 ) {
-       tree_list = (struct rt_tree_array *)bu_calloc( node_count,
-                                                      sizeof( struct 
rt_tree_array ), "tree list" );
-       actual_count = (struct rt_tree_array *)db_flatten_tree( tree_list,
-                                                               comb->tree, 
OP_UNION, 0, &rt_uniresource ) - tree_list;
-       BU_ASSERT_LONG( actual_count, ==, node_count );
+    node_count = db_tree_nleaves(comb->tree);
+    if (node_count > 0) {
+       tree_list = (struct rt_tree_array *)bu_calloc(node_count,
+                                                      sizeof(struct 
rt_tree_array), "tree list");
+       actual_count = (struct rt_tree_array *)db_flatten_tree(tree_list,
+                                                               comb->tree, 
OP_UNION, 0, &rt_uniresource) - tree_list;
+       BU_ASSERT_LONG(actual_count, ==, node_count);
     }
     else {
        tree_list = (struct rt_tree_array *)NULL;
        actual_count = 0;
     }
 
-    if ( actual_count < 1 ) {
-       bu_log( "Warning: empty combination (%s)\n", dp->d_namep );
+    if (actual_count < 1) {
+       bu_log("Warning: empty combination (%s)\n", dp->d_namep);
        dp->d_uses = 0;
        rt_db_free_internal(&intern);
        return;
     }
 
-    BU_LIST_INIT( &headp.l );
+    BU_LIST_INIT(&headp.l);
 
-    for ( i=0; i<actual_count; i++ ) {
+    for (i = 0; i < actual_count; i++) {
        char op;
 
-       switch ( tree_list[i].tl_op ) {
+       switch (tree_list[i].tl_op) {
            case OP_UNION:
                op = 'u';
                break;
@@ -381,39 +381,39 @@
                op = '-';
                break;
            default:
-               bu_log( "Unrecognized Boolean operator in combination (%s)\n", 
dp->d_namep );
-               bu_free( (char *)tree_list, "tree_list" );
+               bu_log("Unrecognized Boolean operator in combination (%s)\n", 
dp->d_namep);
+               bu_free((char *)tree_list, "tree_list");
                rt_db_free_internal(&intern);
                return;
        }
-       wm = mk_addmember( tree_list[i].tl_tree->tr_l.tl_name, &headp.l, NULL, 
op );
-       if ( tree_list[i].tl_tree->tr_l.tl_mat )
-           MAT_COPY( wm->wm_mat, tree_list[i].tl_tree->tr_l.tl_mat );
+       wm = mk_addmember(tree_list[i].tl_tree->tr_l.tl_name, &headp.l, NULL, 
op);
+       if (tree_list[i].tl_tree->tr_l.tl_mat)
+           MAT_COPY(wm->wm_mat, tree_list[i].tl_tree->tr_l.tl_mat);
     }
 
-    if ( comb->rgb_valid  )
+    if (comb->rgb_valid)
        color = comb->rgb;
     else
        color = (unsigned char *)NULL;
 
-    endp = strchr( bu_vls_addr(&comb->shader), ' ' );
-    if ( endp ) {
+    endp = strchr(bu_vls_addr(&comb->shader), ' ');
+    if (endp) {
        len = endp - bu_vls_addr(&comb->shader);
-       if( len > sizeof(matname) ) len = sizeof(matname);
-       bu_strlcpy( matname, bu_vls_addr(&comb->shader), len );
-       bu_strlcpy( matparm, endp+1, sizeof(matparm) );
+       if (len > sizeof(matname)) len = sizeof(matname);
+       bu_strlcpy(matname, bu_vls_addr(&comb->shader), len);
+       bu_strlcpy(matparm, endp+1, sizeof(matparm));
     }
     else {
-       bu_strlcpy( matname, bu_vls_addr(&comb->shader), sizeof(matname) );
+       bu_strlcpy(matname, bu_vls_addr(&comb->shader), sizeof(matname));
        matparm[0] = '\0';
     }
 
-    if ( mk_lrcomb( fp_out, dp->d_namep, &headp, comb->region_flag,
-                   matname, matparm,
-                   color, comb->region_id,
-                   comb->aircode, comb->GIFTmater, comb->los,
-                   comb->inherit ) ) {
-       bu_log( "G-nmg: error in making region (%s)\n", dp->d_namep );
+    if (mk_lrcomb(fp_out, dp->d_namep, &headp, comb->region_flag,
+                  matname, matparm,
+                  color, comb->region_id,
+                  comb->aircode, comb->GIFTmater, comb->los,
+                  comb->inherit)) {
+       bu_log("G-nmg: error in making region (%s)\n", dp->d_namep);
     }
 }
 
@@ -428,9 +428,9 @@
     double percent;
 
     bu_setprogname(argv[0]);
-    bu_setlinebuf( stderr );
+    bu_setlinebuf(stderr);
 
-    BU_LIST_INIT( &rt_g.rtg_vlfree );  /* for vlist macros */
+    BU_LIST_INIT(&rt_g.rtg_vlfree);    /* for vlist macros */
 
     ttol.magic = RT_TESS_TOL_MAGIC;
     /* Defaults, updated by command line options. */
@@ -445,7 +445,7 @@
     tol.perp = 1e-6;
     tol.para = 1 - tol.perp;
 
-    rt_init_resource( &rt_uniresource, 0, NULL );
+    rt_init_resource(&rt_uniresource, 0, NULL);
 
     /* Get command line arguments. */
     while ((c = bu_getopt(argc, argv, "t:a:n:o:r:bvx:P:X:")) != -1) {
@@ -454,7 +454,7 @@
                do_bots = 1;
                break;
            case 't':           /* calculational tolerance */
-               tol.dist = atof( bu_optarg );
+               tol.dist = atof(bu_optarg);
                tol.dist_sq = tol.dist * tol.dist;
                break;
            case 'a':           /* Absolute tolerance. */
@@ -478,14 +478,14 @@
                rt_g.debug = 1;
                break;
            case 'x':
-               sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.debug );
-               bu_printb( "librt RT_G_DEBUG", RT_G_DEBUG, DEBUG_FORMAT );
+               sscanf(bu_optarg, "%x", (unsigned int *)&rt_g.debug);
+               bu_printb("librt RT_G_DEBUG", RT_G_DEBUG, DEBUG_FORMAT);
                bu_log("\n");
                break;
            case 'X':
-               sscanf( bu_optarg, "%x", (unsigned int *)&rt_g.NMG_debug );
+               sscanf(bu_optarg, "%x", (unsigned int *)&rt_g.NMG_debug);
                NMG_debug = rt_g.NMG_debug;
-               bu_printb( "librt rt_g.NMG_debug", rt_g.NMG_debug, 
NMG_DEBUG_FORMAT );
+               bu_printb("librt rt_g.NMG_debug", rt_g.NMG_debug, 
NMG_DEBUG_FORMAT);
                bu_log("\n");
                break;
            default:
@@ -498,33 +498,33 @@
     }
 
     /* Open BRL-CAD database */
-    if ((dbip = db_open( argv[bu_optind], "r")) == DBI_NULL) {
+    if ((dbip = db_open(argv[bu_optind], "r")) == DBI_NULL) {
        perror(argv[0]);
        bu_exit(1, "Cannot open %s\n", argv[bu_optind]);
     }
-    if ( db_dirbuild( dbip ) ) {
+    if (db_dirbuild(dbip)) {
        bu_exit(1, "db_dirbuild failed\n");
     }
 
-    if ((fp_out = wdb_fopen( out_file )) == NULL) {
-       perror( out_file );
-       bu_exit(2, "ERROR: Cannot open %s for reading\n", out_file );
+    if ((fp_out = wdb_fopen(out_file)) == NULL) {
+       perror(out_file);
+       bu_exit(2, "ERROR: Cannot open %s for reading\n", out_file);
     }
 
     bu_optind++;
 
-    mk_id_editunits( fp_out, dbip->dbi_title, dbip->dbi_local2base );
+    mk_id_editunits(fp_out, dbip->dbi_title, dbip->dbi_local2base);
 
     /* Walk the trees outputting regions and combinations */
-    for ( i=bu_optind; i<argc; i++ ) {
+    for (i = bu_optind; i < argc; i++) {
        struct directory *dp;
 
-       dp = db_lookup( dbip, argv[i], 0 );
-       if ( dp == RT_DIR_NULL ) {
-           bu_log( "WARNING: Could not find %s, skipping\n", argv[i] );
+       dp = db_lookup(dbip, argv[i], 0);
+       if (dp == RT_DIR_NULL) {
+           bu_log("WARNING: Could not find %s, skipping\n", argv[i]);
            continue;
        }
-       db_functree( dbip, dp, csg_comb_func, 0, &rt_uniresource, NULL );
+       db_functree(dbip, dp, csg_comb_func, 0, &rt_uniresource, NULL);
     }
 
     /* write the current color table */
@@ -534,11 +534,11 @@
     db_close(dbip);
 
     percent = 100;
-    if ( regions_tried > 0 )
+    if (regions_tried > 0)
        percent = ((double)regions_converted * 100) / regions_tried;
 
-    printf( "Tried %d regions, %d converted successfully.  %g%%\n",
-           regions_tried, regions_converted, percent );
+    printf("Tried %d regions, %d converted successfully.  %g%%\n",
+           regions_tried, regions_converted, percent);
 
     wdb_close(fp_out);
     return 0;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to