Revision: 41813
          http://brlcad.svn.sourceforge.net/brlcad/?rev=41813&view=rev
Author:   brlcad
Date:     2010-12-28 18:35:30 +0000 (Tue, 28 Dec 2010)

Log Message:
-----------
rename the VAPPROXEQUAL() macro to VNEAR_EQUAL() as a minimally impacting API 
change.  this parallels the VNEAR_ZERO() macro and helps with the addition of 
consistent non-vector EQUAL() and NEAR_EQUAL() macros.

Modified Paths:
--------------
    brlcad/trunk/include/vmath.h
    brlcad/trunk/src/conv/dxf/bot-bldxf.c
    brlcad/trunk/src/conv/iges/iges.c
    brlcad/trunk/src/conv/step/Axis2Placement3D.cpp
    brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp
    brlcad/trunk/src/libged/qray.c
    brlcad/trunk/src/libged/wdb_qray.c
    brlcad/trunk/src/liboptical/sh_billboard.c
    brlcad/trunk/src/librt/prep.c
    brlcad/trunk/src/librt/primitives/ars/ars.c
    brlcad/trunk/src/proc-db/brepintersect.cpp
    brlcad/trunk/src/rt/do.c
    brlcad/trunk/src/rt/hurt.c
    brlcad/trunk/src/vdeck/cgarbs.c

Modified: brlcad/trunk/include/vmath.h
===================================================================
--- brlcad/trunk/include/vmath.h        2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/include/vmath.h        2010-12-28 18:35:30 UTC (rev 41813)
@@ -287,11 +287,52 @@
 
 
 /**
- * return truthfully whether a value is within some epsilon from zero.
+ * Return truthfully whether a value is within a specified epsilon
+ * distance from zero.
  */
 #define NEAR_ZERO(val, epsilon)        (((val) > -epsilon) && ((val) < 
epsilon))
 
 /**
+ * Return truthfully whether all elements of a given vector are within
+ * a specified epsilon distance from zero.
+ */
+#define VNEAR_ZERO(v, tol) \
+       (NEAR_ZERO(v[X], tol) \
+        && NEAR_ZERO(v[Y], tol) \
+        && NEAR_ZERO(v[Z], tol))
+
+/**
+ * Return truthfully whether two values are within a specified epsilon
+ * distance from each other.
+ */
+#define NEAR_EQUAL(_a, _b, _tol) NEAR_ZERO((_a) - (_b), (_tol)) || 
NEAR_ZERO((_b) - (_a), (_tol))
+
+/**
+ * Return truthfully whether two vectors are approximately equal,
+ * within a specified absolute tolerance.
+ */
+#define VNEAR_EQUAL(_a, _b, _tol) \
+       (NEAR_ZERO((_a)[X]-(_b)[X], (_tol)) \
+        && NEAR_ZERO((_a)[Y]-(_b)[Y], (_tol)) \
+        && NEAR_ZERO((_a)[Z]-(_b)[Z], (_tol)))
+
+/**
+ * Return truthfully whether two values are within a minimum
+ * representation tolerance from each other.
+ *
+ * Unspecified unreliable tolerance.  Use not recommended.
+ */
+#define EQUAL(_a, _b) NEAR_EQUAL((_a), (_b), SMALL_FASTF)
+
+/**
+ * Return truthfully whether two vectors are equal within a minimum
+ * representation tolerance.
+ *
+ * Unspecified unreliable tolerance.  Use not recommended.
+ */
+#define VEQUAL(_a, _b) VNEAR_EQUAL((_a), (_b), SMALL_FASTF)
+
+/**
  * clamp a value to a low/high number.
  */
 #define CLAMP(_v, _l, _h) if ((_v) < (_l)) _v = _l; else if ((_v) > (_h)) _v = 
_h
@@ -1162,27 +1203,6 @@
        (fabs(MAGSQ(_vec)) < 0.0001 || fabs(fabs(MAGSQ(_vec))-1) > 0.0001)
 
 /**
- * @brief Compare two vectors for equality within minimum computation
- * tolerance.  Use carefully.
- */
-#define VEQUAL(a, b) VAPPROXEQUAL(a, b, SMALL_FASTF)
-
-/**
- * @brief Compare two vectors for approximate equality, within the
- * specified absolute tolerance.
- */
-#define VAPPROXEQUAL(a, b, tol) \
-       (NEAR_ZERO((a)[X]-(b)[X], tol) \
-        && NEAR_ZERO((a)[Y]-(b)[Y], tol) \
-        && NEAR_ZERO((a)[Z]-(b)[Z], tol))
-
-/** @brief Test for all elements of `v' being smaller than `tol'. */
-#define VNEAR_ZERO(v, tol) \
-       (NEAR_ZERO(v[X], tol) \
-        && NEAR_ZERO(v[Y], tol) \
-        && NEAR_ZERO(v[Z], tol))
-
-/**
  * @brief Included below are macros to update min and max X, Y, Z
  * values to contain a point
  */

Modified: brlcad/trunk/src/conv/dxf/bot-bldxf.c
===================================================================
--- brlcad/trunk/src/conv/dxf/bot-bldxf.c       2010-12-28 18:25:29 UTC (rev 
41812)
+++ brlcad/trunk/src/conv/dxf/bot-bldxf.c       2010-12-28 18:35:30 UTC (rev 
41813)
@@ -175,7 +175,7 @@
     }
 
     /* if the normals are out of tolerance, simply give up */
-    if ( ! VAPPROXEQUAL(N1, N2, 0.005)) {
+    if (!VNEAR_EQUAL(N1, N2, 0.005)) {
        if (debug&DEBUG_QUAD)
            fprintf(stderr, "normals don't match  %g %g %g   %g %g %g\n",
                    V3ARGS(N1), V3ARGS(N2));

Modified: brlcad/trunk/src/conv/iges/iges.c
===================================================================
--- brlcad/trunk/src/conv/iges/iges.c   2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/conv/iges/iges.c   2010-12-28 18:35:30 UTC (rev 41813)
@@ -2025,32 +2025,32 @@
     for ( i=5; i<8; i++ )
     {
        VSUB2( v1, arb->pt[i], arb->pt[i-4] );
-       if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+       if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
            return 0;
     }
 
     /* check the width vectors */
     VSUB2( v0, arb->pt[1], arb->pt[0] );
     VSUB2( v1, arb->pt[2], arb->pt[3] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
     VSUB2( v1, arb->pt[6], arb->pt[7] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
     VSUB2( v1, arb->pt[5], arb->pt[4] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
 
     /* check the depth vectors */
     VSUB2( v0, arb->pt[3], arb->pt[0] );
     VSUB2( v1, arb->pt[2], arb->pt[1] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
     VSUB2( v1, arb->pt[6], arb->pt[5] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
     VSUB2( v1, arb->pt[7], arb->pt[4] );
-    if ( !VAPPROXEQUAL( v0, v1, tol.dist ) )
+    if ( !VNEAR_EQUAL( v0, v1, tol.dist ) )
        return 0;
 
     /* check for a right angle corner */

Modified: brlcad/trunk/src/conv/step/Axis2Placement3D.cpp
===================================================================
--- brlcad/trunk/src/conv/step/Axis2Placement3D.cpp     2010-12-28 18:25:29 UTC 
(rev 41812)
+++ brlcad/trunk/src/conv/step/Axis2Placement3D.cpp     2010-12-28 18:35:30 UTC 
(rev 41813)
@@ -110,8 +110,8 @@
     if (refdir == NULL) {
        double xplus[3]=  {1.0,0.0,0.0};
        double xminus[3]=  {-1.0,0.0,0.0};
-       if (!VAPPROXEQUAL(z, xplus, TOL) &&
-                       !VAPPROXEQUAL(z, xminus, TOL))  {
+       if (!VNEAR_EQUAL(z, xplus, TOL) &&
+                       !VNEAR_EQUAL(z, xminus, TOL))  {
                VSET(v,1.0,0.0,0.0);
        } else {
                VSET(v,0.0,1.0,0.0);

Modified: brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp
===================================================================
--- brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp  2010-12-28 18:25:29 UTC 
(rev 41812)
+++ brlcad/trunk/src/conv/step/OpenNurbsInterfaces.cpp  2010-12-28 18:35:30 UTC 
(rev 41813)
@@ -2432,27 +2432,27 @@
 
     ON_2dPoint start, end;
     ON_Surface::ISO iso;
-    if (VAPPROXEQUAL(vertex, corner[0], POINT_CLOSENESS_TOLERANCE)) {
+    if (VNEAR_EQUAL(vertex, corner[0], POINT_CLOSENESS_TOLERANCE)) {
        start = ON_2dPoint(U.m_t[0], V.m_t[0]);
-       if (VAPPROXEQUAL(vertex, corner[1], POINT_CLOSENESS_TOLERANCE)) {
+       if (VNEAR_EQUAL(vertex, corner[1], POINT_CLOSENESS_TOLERANCE)) {
            //south;
            end = ON_2dPoint(U.m_t[1], V.m_t[0]);
            iso = ON_Surface::S_iso;
-       } else if (VAPPROXEQUAL(vertex, corner[2], POINT_CLOSENESS_TOLERANCE)) {
+       } else if (VNEAR_EQUAL(vertex, corner[2], POINT_CLOSENESS_TOLERANCE)) {
            //west
            end = ON_2dPoint(U.m_t[0], V.m_t[1]);
            iso = ON_Surface::W_iso;
        }
-    } else if (VAPPROXEQUAL(vertex, corner[1], POINT_CLOSENESS_TOLERANCE)) {
+    } else if (VNEAR_EQUAL(vertex, corner[1], POINT_CLOSENESS_TOLERANCE)) {
        start = ON_2dPoint(U.m_t[1], V.m_t[0]);
-       if (VAPPROXEQUAL(vertex, corner[3], POINT_CLOSENESS_TOLERANCE)) {
+       if (VNEAR_EQUAL(vertex, corner[3], POINT_CLOSENESS_TOLERANCE)) {
            //east
            end = ON_2dPoint(U.m_t[1], V.m_t[1]);
            iso = ON_Surface::E_iso;
        }
-    } else if (VAPPROXEQUAL(vertex, corner[2], POINT_CLOSENESS_TOLERANCE)) {
+    } else if (VNEAR_EQUAL(vertex, corner[2], POINT_CLOSENESS_TOLERANCE)) {
        start = ON_2dPoint(U.m_t[0], V.m_t[1]);
-       if (VAPPROXEQUAL(vertex, corner[3], POINT_CLOSENESS_TOLERANCE)) {
+       if (VNEAR_EQUAL(vertex, corner[3], POINT_CLOSENESS_TOLERANCE)) {
            //north
            end = ON_2dPoint(U.m_t[1], V.m_t[1]);
            iso = ON_Surface::N_iso;

Modified: brlcad/trunk/src/libged/qray.c
===================================================================
--- brlcad/trunk/src/libged/qray.c      2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/libged/qray.c      2010-12-28 18:35:30 UTC (rev 41813)
@@ -495,7 +495,7 @@
        RT_ADD_VLIST(vhead, in_pt, BN_VLIST_LINE_MOVE);
        RT_ADD_VLIST(vhead, out_pt, BN_VLIST_LINE_DRAW);
 
-       if (!do_overlaps && i > 1 && !VAPPROXEQUAL(last_out_pt, in_pt, 
SQRT_SMALL_FASTF)) {
+       if (!do_overlaps && i > 1 && !VNEAR_EQUAL(last_out_pt, in_pt, 
SQRT_SMALL_FASTF)) {
            vhead = rt_vlblock_find(vbp,
                                    gedp->ged_gdp->gd_qray_void_color.r,
                                    gedp->ged_gdp->gd_qray_void_color.g,

Modified: brlcad/trunk/src/libged/wdb_qray.c
===================================================================
--- brlcad/trunk/src/libged/wdb_qray.c  2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/libged/wdb_qray.c  2010-12-28 18:35:30 UTC (rev 41813)
@@ -553,7 +553,7 @@
        RT_ADD_VLIST(vhead, in_pt, BN_VLIST_LINE_MOVE);
        RT_ADD_VLIST(vhead, out_pt, BN_VLIST_LINE_DRAW);
 
-       if (!do_overlaps && i > 1 && !VAPPROXEQUAL(last_out_pt, in_pt, 
SQRT_SMALL_FASTF)) {
+       if (!do_overlaps && i > 1 && !VNEAR_EQUAL(last_out_pt, in_pt, 
SQRT_SMALL_FASTF)) {
            vhead = rt_vlblock_find(vbp,
                                    dgop->dgo_qray_void_color.r,
                                    dgop->dgo_qray_void_color.g,

Modified: brlcad/trunk/src/liboptical/sh_billboard.c
===================================================================
--- brlcad/trunk/src/liboptical/sh_billboard.c  2010-12-28 18:25:29 UTC (rev 
41812)
+++ brlcad/trunk/src/liboptical/sh_billboard.c  2010-12-28 18:35:30 UTC (rev 
41813)
@@ -347,7 +347,7 @@
     /* red line from ray origin to hit point */
     VJOIN1(pp->pt_inhit->hit_point, ap->a_ray.r_pt, pp->pt_inhit->hit_dist,
           ap->a_ray.r_dir);
-    if (VAPPROXEQUAL(ap->a_ray.r_pt, pp->pt_inhit->hit_point, 0.125)) {
+    if (VNEAR_EQUAL(ap->a_ray.r_pt, pp->pt_inhit->hit_point, 0.125)) {
        /* start and hit point identical, make special allowance */
        vect_t vtmp;
 

Modified: brlcad/trunk/src/librt/prep.c
===================================================================
--- brlcad/trunk/src/librt/prep.c       2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/librt/prep.c       2010-12-28 18:35:30 UTC (rev 41813)
@@ -1870,8 +1870,8 @@
 
     bu_ptbl_free(&rtip->rti_new_solids);
 
-    if (!VAPPROXEQUAL(rtip->mdl_min, old_min, SMALL_FASTF)
-       || !VAPPROXEQUAL(rtip->mdl_max, old_min, SMALL_FASTF))
+    if (!VNEAR_EQUAL(rtip->mdl_min, old_min, SMALL_FASTF)
+       || !VNEAR_EQUAL(rtip->mdl_max, old_min, SMALL_FASTF))
     {
        /* fill out BSP, it must completely fill the model BB */
        fastf_t bb[6];

Modified: brlcad/trunk/src/librt/primitives/ars/ars.c
===================================================================
--- brlcad/trunk/src/librt/primitives/ars/ars.c 2010-12-28 18:25:29 UTC (rev 
41812)
+++ brlcad/trunk/src/librt/primitives/ars/ars.c 2010-12-28 18:35:30 UTC (rev 
41813)
@@ -506,7 +506,7 @@
            vect_t pca;
            int code;
 
-           if (VAPPROXEQUAL(ARS_PT(0, -2), ARS_PT(0, -1), tol->dist))
+           if (VNEAR_EQUAL(ARS_PT(0, -2), ARS_PT(0, -1), tol->dist))
                continue;
 
            code = bn_dist_pt3_lseg3(&dist, pca, ARS_PT(0, -2), ARS_PT(0, -1), 
ARS_PT(0, 0), tol);
@@ -548,9 +548,7 @@
        int double_ended;
 
        if (k != 1
-           && VAPPROXEQUAL(&arip->curves[i][1*ELEMENTS_PER_VECT],
-                           &arip->curves[i][k*ELEMENTS_PER_VECT],
-                           tol->dist))
+           && VNEAR_EQUAL(&arip->curves[i][1*ELEMENTS_PER_VECT], 
&arip->curves[i][k*ELEMENTS_PER_VECT], tol->dist))
        {
            double_ended = 1;
        } else {

Modified: brlcad/trunk/src/proc-db/brepintersect.cpp
===================================================================
--- brlcad/trunk/src/proc-db/brepintersect.cpp  2010-12-28 18:25:29 UTC (rev 
41812)
+++ brlcad/trunk/src/proc-db/brepintersect.cpp  2010-12-28 18:35:30 UTC (rev 
41813)
@@ -102,21 +102,21 @@
            return true;
        } else if (VNEAR_ZERO(v3, tol)) {
            return true;
-       } else if (VAPPROXEQUAL(v2, v3, tol)) {
+       } else if (VNEAR_EQUAL(v2, v3, tol)) {
            return true;
        } else
            return false;
     } else if (VNEAR_ZERO(v2, tol)) {
        if (VNEAR_ZERO(v3, tol)) {
            return true;
-       } else if (VAPPROXEQUAL(v1, v3, tol)) {
+       } else if (VNEAR_EQUAL(v1, v3, tol)) {
            return true;
        } else
            return false;
-    } else if (VAPPROXEQUAL(v1, v2, tol)) {
+    } else if (VNEAR_EQUAL(v1, v2, tol)) {
        if (VNEAR_ZERO(v3, tol)) {
            return true;
-       } else if (VAPPROXEQUAL(v2, v3, tol)) {
+       } else if (VNEAR_EQUAL(v2, v3, tol)) {
            return true;
        } else
            return false;
@@ -335,7 +335,7 @@
        if (-tol <= s && s <= 1.0 + tol && -tol <= t && t <= 1.0 + tol) {
            ON_3dPoint Ps = x1 + s * (x2 - x1); /* The answer according to 
equation P*/
            ON_3dPoint Qt = x3 + t * (x4 - x3); /* The answer according to 
equation Q*/
-           assert(VAPPROXEQUAL(Ps, Qt, tol)); /* check to see if they agree, 
just a sanity check*/
+           assert(VNEAR_EQUAL(Ps, Qt, tol)); /* check to see if they agree, 
just a sanity check*/
            x[0] = Ps;
            return 1;
        } else {
@@ -472,7 +472,7 @@
                for (i = 0; i < 3; i++) {
                    rv = SegmentSegmentIntersect(triangle[i], 
triangle[(i+1)%3], p, q, x, tol);
                    if (rv == 1) {
-                       if (points_found == 0 || !VAPPROXEQUAL(out[0], x[0], 
tol)) { /* in rare cases we can get the same point twice*/
+                       if (points_found == 0 || !VNEAR_EQUAL(out[0], x[0], 
tol)) { /* in rare cases we can get the same point twice*/
                            out[points_found] = x[0];
                            points_found++;
                        }
@@ -538,7 +538,7 @@
            ON_3dPoint P = result[j];
            bool dup = false;
            for (k = 0; k < number_found; k++) {
-               if (VAPPROXEQUAL(out[k], P, tol)) {
+               if (VNEAR_EQUAL(out[k], P, tol)) {
                    dup = true;
                    break;
                }
@@ -558,7 +558,7 @@
            ON_3dPoint P = result[j];
            bool dup = false;
            for (k = 0; k < number_found; k++) {
-               if (VAPPROXEQUAL(out[k], P, tol)) {
+               if (VNEAR_EQUAL(out[k], P, tol)) {
                    dup = true;
                    break;
                }
@@ -863,13 +863,13 @@
        while (!outline.IsClosed(tol)) {
            if (i >= segments.Count()) {
                return -1;
-           } else if (VAPPROXEQUAL(segments[i].from, outline[outline.Count() - 
1], tol)) {
+           } else if (VNEAR_EQUAL(segments[i].from, outline[outline.Count() - 
1], tol)) {
                outline.Append(segments[i].to);
-           } else if (VAPPROXEQUAL(segments[i].to, outline[0], tol)) {
+           } else if (VNEAR_EQUAL(segments[i].to, outline[0], tol)) {
                outline.Insert(0, segments[i].from);
-           } else if (VAPPROXEQUAL(segments[i].from, outline[0], tol) && 
flippable[i]) {
+           } else if (VNEAR_EQUAL(segments[i].from, outline[0], tol) && 
flippable[i]) {
                outline.Insert(0, segments[i].to);
-           } else if (VAPPROXEQUAL(segments[i].to, outline[outline.Count() - 
1], tol) && flippable[i]) {
+           } else if (VNEAR_EQUAL(segments[i].to, outline[outline.Count() - 
1], tol) && flippable[i]) {
                outline.Append(segments[i].from);
            } else {
                i++;
@@ -918,7 +918,7 @@
 {
     /* This will eventually be implemented in a much more efficient way */
     for (int i = 0; i < mesh->m_V.Count(); i++) {
-       if (VAPPROXEQUAL(mesh->m_V[i], P, tol)) {
+       if (VNEAR_EQUAL(mesh->m_V[i], P, tol)) {
            return i;
        }
     }

Modified: brlcad/trunk/src/rt/do.c
===================================================================
--- brlcad/trunk/src/rt/do.c    2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/rt/do.c    2010-12-28 18:35:30 UTC (rev 41813)
@@ -266,7 +266,7 @@
      * from the lookat point or the lookat point will be from the
      * "front"
      */
-    if (VAPPROXEQUAL(pt, eye_model, VDIVIDE_TOL)) {
+    if (VNEAR_EQUAL(pt, eye_model, VDIVIDE_TOL)) {
        VSETALLN(quat, 0.5, 4);
        quat_quat2mat(Viewrotscale, quat); /* front */
     } else {

Modified: brlcad/trunk/src/rt/hurt.c
===================================================================
--- brlcad/trunk/src/rt/hurt.c  2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/rt/hurt.c  2010-12-28 18:35:30 UTC (rev 41813)
@@ -760,7 +760,7 @@
      *  different from the lookat point or the lookat point will
      *  be from the "front"
      */
-    if (VAPPROXEQUAL(pt, eye_model, VDIVIDE_TOL)) {
+    if (VNEAR_EQUAL(pt, eye_model, VDIVIDE_TOL)) {
        VSETALLN(quat, 0.5, 4);
        quat_quat2mat(Viewrotscale, quat); /* front */
     } else {

Modified: brlcad/trunk/src/vdeck/cgarbs.c
===================================================================
--- brlcad/trunk/src/vdeck/cgarbs.c     2010-12-28 18:25:29 UTC (rev 41812)
+++ brlcad/trunk/src/vdeck/cgarbs.c     2010-12-28 18:35:30 UTC (rev 41813)
@@ -71,7 +71,7 @@
        if (done == NO)
            svec[si] = i;
        for (j=i+1; j<8; j++) {
-           if ( VAPPROXEQUAL( gp->pt[i], gp->pt[j], dist_tol ) )  {
+           if ( VNEAR_EQUAL( gp->pt[i], gp->pt[j], dist_tol ) )  {
                if ( done == NO ) svec[++si] = j;
                unique = NO;
            }


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

------------------------------------------------------------------------------
Learn how Oracle Real Application Clusters (RAC) One Node allows customers
to consolidate database storage, standardize their database environment, and, 
should the need arise, upgrade to a full multi-node Oracle RAC database 
without downtime or disruption
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