Revision: 42004
          http://brlcad.svn.sourceforge.net/brlcad/?rev=42004&view=rev
Author:   brlcad
Date:     2011-01-07 08:56:22 +0000 (Fri, 07 Jan 2011)

Log Message:
-----------
remove exact floating point comparisons, de-k&r functions, and quell global 
shadow warnings.

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

Modified: brlcad/trunk/src/conv/iges/g-iges.c
===================================================================
--- brlcad/trunk/src/conv/iges/g-iges.c 2011-01-07 08:52:59 UTC (rev 42003)
+++ brlcad/trunk/src/conv/iges/g-iges.c 2011-01-07 08:56:22 UTC (rev 42004)
@@ -102,31 +102,31 @@
 static int     solid_error=0;  /* Count indicating how many solids were not 
converted */
 static int     comb_error=0;   /* Count indicating  how many combinations were 
not converted */
 static int     ncpu = 1;       /* Number of processors */
-static char    *output_file = NULL;    /* output filename */
-static FILE    *fp_dir = NULL;         /* IGES start, global, and directory 
sections */
-static FILE    *fp_param = NULL;       /* IGES parameter section */
-static struct rt_tess_tol      ttol;
-static struct bn_tol           tol;
-static struct model            *the_model;
-struct db_i            *dbip;
+static char *output_file = NULL;       /* output filename */
+static FILE *fp_dir = NULL;    /* IGES start, global, and directory sections */
+static FILE *fp_param = NULL;  /* IGES parameter section */
+static struct rt_tess_tol ttol;
+static struct bn_tol tol;
+static struct model *the_model;
+struct db_i *DBIP;
 
 static struct db_tree_state    tree_state;     /* includes tol & model */
 
 /* function table for converting solids to iges */
-BU_EXTERN( int null_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int arb_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int ell_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int sph_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int tor_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int tgc_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int nmg_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( int sketch_to_iges, ( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
-BU_EXTERN( void iges_init, ( struct bn_tol *set_tol, struct rt_tess_tol 
*set_ttol, int set_verbose, struct db_i *dbip_set ) );
-BU_EXTERN( void Print_stats, ( FILE *fp ) );
+BU_EXTERN( int null_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int arb_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int ell_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int sph_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int tor_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int tgc_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int nmg_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( int sketch_to_iges, ( struct rt_db_internal *, char *, FILE *, FILE 
*));
+BU_EXTERN( void iges_init, ( struct bn_tol *, struct rt_tess_tol *, int, 
struct db_i *) );
+BU_EXTERN( void Print_stats, ( FILE * ) );
 
 struct iges_functab
 {
-    int (*do_iges_write) BU_ARGS(( struct rt_db_internal *ip, char *name, FILE 
*fp_dir, FILE *fp_param ));
+    int (*do_iges_write) BU_ARGS(( struct rt_db_internal *, char *, FILE *, 
FILE * ));
 };
 
 struct iges_functab iges_write[ID_MAXIMUM+1]={
@@ -277,20 +277,20 @@
     argc -= bu_optind;
     argv += bu_optind;
     db_name = argv[0];
-    if ((dbip = db_open(db_name, "r")) == DBI_NULL) {
+    if ((DBIP = db_open(db_name, "r")) == DBI_NULL) {
        perror("g-iges");
        bu_exit(1, "ERROR: unable to open geometry file (%s)\n", db_name);
     }
 
     /* Scan the database */
-    if ( db_dirbuild( dbip ) ) {
+    if ( db_dirbuild( DBIP ) ) {
        bu_exit(1, "db_dirbuild failed\n" );
     }
 
     if ( !multi_file )
     {
        /* let the IGES routines know the selected tolerances and the database 
pointer */
-       iges_init( &tol, &ttol, verbose, dbip );
+       iges_init( &tol, &ttol, verbose, DBIP );
 
        /* Open the output file */
        if ( output_file == NULL )
@@ -330,8 +330,8 @@
     /* Count object references */
 /*     for ( i=1; i<argc; i++ )
        {
-       dp = db_lookup( dbip, argv[i], 1 );
-       db_functree( dbip, dp, count_refs, 0, NULL );
+       dp = db_lookup( DBIP, argv[i], 1 );
+       db_functree( DBIP, dp, count_refs, 0, NULL );
        }       */
 
     /* tree tops must have independent status, so we need to remember them */
@@ -343,7 +343,7 @@
        /* Walk indicated tree(s).  Each region will be output
         * as a single manifold solid BREP object */
 
-       ret = db_walk_tree(dbip, argc-1, (const char **)(argv+1),
+       ret = db_walk_tree(DBIP, argc-1, (const char **)(argv+1),
                           ncpu,
                           &tree_state,
                           0,                   /* take all regions */
@@ -367,12 +367,12 @@
                } else {
                    ptr = argv[i];
                }
-               dp = db_lookup( dbip, ptr, 1 );
+               dp = db_lookup( DBIP, ptr, 1 );
                if (!dp) {
                    bu_log("WARNING: Unable to locate %s in %s\n, skipping\n", 
ptr, db_name);
                    continue;
                }
-               db_functree( dbip, dp, csg_comb_func, 0, &rt_uniresource, NULL 
);
+               db_functree( DBIP, dp, csg_comb_func, 0, &rt_uniresource, NULL 
);
            }
        }
     }
@@ -384,12 +384,12 @@
 
        for ( i=1; i<(size_t)argc; i++ )
        {
-           dp = db_lookup( dbip, argv[i], 1 );
+           dp = db_lookup( DBIP, argv[i], 1 );
            if (!dp) {
                bu_log("WARNING: Unable to locate %s in %s\n, skipping\n", 
argv[i], db_name);
                continue;
            }
-           db_functree( dbip, dp, csg_comb_func, csg_leaf_func, 
&rt_uniresource, NULL );
+           db_functree( DBIP, dp, csg_comb_func, csg_leaf_func, 
&rt_uniresource, NULL );
        }
     }
     else if ( mode == TRIMMED_SURF_MODE )
@@ -397,7 +397,7 @@
        /* Walk the indicated tree(s). Each region is output as a collection
         * of trimmed NURBS */
 
-       ret = db_walk_tree(dbip, argc-1, (const char **)(argv+1),
+       ret = db_walk_tree(DBIP, argc-1, (const char **)(argv+1),
                           ncpu,
                           &tree_state,
                           0,                   /* take all regions */
@@ -461,7 +461,7 @@
  *  This routine must be prepared to run in parallel.
  */
 union tree *
-do_nmg_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, 
union tree *curtree, genptr_t client_data)
+do_nmg_region_end(struct db_tree_state *tsp, const struct db_full_path *pathp, 
union tree *curtree, genptr_t UNUSED(client_data))
 {
     union tree         *result;
     struct nmgregion   *r;
@@ -510,7 +510,7 @@
        db_free_tree(curtree, &rt_uniresource);         /* Does an nmg_kr() */
 
        /* Get rid of (m)any other intermediate structures */
-       if ( (*tsp->ts_m)->magic != -1L )
+       if ( (*tsp->ts_m)->magic == NMG_MODEL_MAGIC )
            nmg_km(*tsp->ts_m);
 
        /* Now, make a new, clean model structure for next pass. */
@@ -555,8 +555,6 @@
                suffix[0]--;
                while ( !unique )
                {
-                   size_t i;
-
                    if ( stat( multi_name, &stat_ptr ) )
                    {
                        unique = 1;
@@ -599,7 +597,7 @@
            }
 
            /* let the IGES routines know the selected tolerances and the 
database pointer */
-           iges_init( &tol, &ttol, verbose, dbip );
+           iges_init( &tol, &ttol, verbose, DBIP );
 
            /* Write start and global sections of the IGES file */
            w_start_global( fp_dir, fp_param, db_name, prog_name, output_file, 
__DATE__, brlcad_version() );
@@ -687,7 +685,7 @@
        {
            struct directory *dp_M;
 
-           dp_M = db_lookup( dbip, tp->tr_l.tl_name, LOOKUP_NOISY );
+           dp_M = db_lookup( DBIP, tp->tr_l.tl_name, LOOKUP_NOISY );
            if ( dp_M == DIR_NULL )
                return 1;
 
@@ -727,10 +725,7 @@
 }
 
 void
-csg_comb_func( dbip, dp, ptr )
-    struct db_i *dbip;
-    struct directory *dp;
-    genptr_t   ptr;
+csg_comb_func(struct db_i *dbip, struct directory *dp, genptr_t UNUSED(ptr))
 {
     struct rt_db_internal intern;
     struct rt_comb_internal *comb;
@@ -820,10 +815,7 @@
 }
 
 void
-csg_leaf_func( dbip, dp, ptr )
-    struct db_i *dbip;
-    struct directory *dp;
-    genptr_t ptr;
+csg_leaf_func(struct db_i *dbip, struct directory *dp, genptr_t UNUSED(ptr))
 {
     struct rt_db_internal      ip;
 
@@ -855,11 +847,7 @@
 }
 
 void
-incr_refs( dbip, comb, tp, user_ptr1, user_ptr2, user_ptr3 )
-    struct db_i                *dbip;
-    struct rt_comb_internal    *comb;
-    union tree         *tp;
-    genptr_t           user_ptr1, user_ptr2, user_ptr3;
+incr_refs(struct db_i *dbip, struct rt_comb_internal *comb, union tree *tp, 
genptr_t UNUSED(user_ptr1), genptr_t UNUSED(user_ptr2), genptr_t 
UNUSED(user_ptr3))
 {
     struct directory *dp;
 
@@ -873,11 +861,9 @@
     dp->d_nref++;
 }
 
+
 void
-count_refs( dbip, dp, ptr )
-    struct db_i *dbip;
-    struct directory *dp;
-    genptr_t ptr;
+count_refs(struct db_i *dbip, struct directory *dp, genptr_t UNUSED(ptr))
 {
     struct rt_db_internal intern;
     struct rt_comb_internal *comb;

Modified: brlcad/trunk/src/conv/iges/getcurve.c
===================================================================
--- brlcad/trunk/src/conv/iges/getcurve.c       2011-01-07 08:52:59 UTC (rev 
42003)
+++ brlcad/trunk/src/conv/iges/getcurve.c       2011-01-07 08:56:22 UTC (rev 
42004)
@@ -426,7 +426,7 @@
                a = A*C - B*B/4.0;
                if (fabs(a) < 1.0  && fabs(a) > TOL) {
                    a = fabs(A);
-                   if (fabs(B)<a && B != 0.0)
+                   if (fabs(B)<a && !NEAR_ZERO(B, SMALL_FASTF))
                        a = fabs(B);
                    if (fabs(C)<a)
                        a = fabs(C);
@@ -443,7 +443,7 @@
                    /* check for type of conic */
                    del = 
A*(C*F-E*E/4.0)-0.5*B*(B*F/2.0-D*E/4.0)+0.5*D*(B*E/4.0-C*D/2.0);
                    I = A+C;
-                   if (del == 0.0) {
+                   if (NEAR_ZERO(del, SMALL_FASTF)) {
                        /* not a conic */
                        bu_log("Entity #%d, claims to be conic arc, but 
isn't\n", curve);
                        break;
@@ -451,7 +451,7 @@
                        type = 1; /* ellipse */
                    else if (a < 0.0)
                        type = 2; /* hyperbola */
-                   else if (a == 0.0)
+                   else if (NEAR_ZERO(a, SMALL_FASTF))
                        type = 3; /* parabola */
                    else {
                        /* imaginary ellipse */
@@ -467,7 +467,7 @@
                    case 3:     /* parabola */
 
                        /* make A+C == 1.0 */
-                       if (A+C != 1.0) {
+                       if (!EQUAL(A+C, 1.0)) {
                            b = A+C;
                            A = A/b;
                            B = B/b;
@@ -571,7 +571,7 @@
 
                            /* theta is angle that the curve axis is rotated 
about
                               the origin from the x-axis */
-                           if (B != 0.0)
+                           if (!NEAR_ZERO(B, SMALL_FASTF))
                                theta = 0.5*atan2(B, A-C);
                            else
                                theta = 0.0;
@@ -613,7 +613,7 @@
                               beta = terminate angle
                            */
                            beta = 0.0;
-                           if (v2[0] == v1[0] && v2[1] == v1[1]) {
+                           if (EQUAL(v2[0], v1[0]) && EQUAL(v2[1], v1[1])) {
                                /* full circle */
                                alpha = 0.0;
                                beta = 2.0*pi;
@@ -624,7 +624,7 @@
                            if (type == 1) {
                                /* ellipse */
                                alpha = atan2(a*v1[1], b*v1[0]);
-                               if (beta == 0.0) {
+                               if (NEAR_ZERO(beta, SMALL_FASTF)) {
                                    beta = atan2(a*v2[1], b*v2[0]);
                                    beta = beta - alpha;
                                }


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

------------------------------------------------------------------------------
Gaining the trust of online customers is vital for the success of any company
that requires sensitive data to be transmitted over the Web.   Learn how to 
best implement a security strategy that keeps consumers' information secure 
and instills the confidence they need to proceed with transactions.
http://p.sf.net/sfu/oracle-sfdevnl 
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to