Revision: 65565
          http://sourceforge.net/p/brlcad/code/65565
Author:   ejno
Date:     2015-07-10 21:01:40 +0000 (Fri, 10 Jul 2015)
Log Message:
-----------
better test for non-truncated cones

Modified Paths:
--------------
    brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp

Modified: brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp
===================================================================
--- brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp    2015-07-10 
20:49:37 UTC (rev 65564)
+++ brlcad/trunk/src/libgcv/conv/fastgen4/fastgen4_write.cpp    2015-07-10 
21:01:40 UTC (rev 65565)
@@ -1087,6 +1087,16 @@
 }
 
 
+HIDDEN bool
+mutually_orthogonal(const fastf_t *vect_a, const fastf_t *vect_b,
+                   const fastf_t *vect_c)
+{
+    return NEAR_ZERO(VDOT(vect_a, vect_b), RT_DOT_TOL)
+          && NEAR_ZERO(VDOT(vect_a, vect_c), RT_DOT_TOL)
+          && NEAR_ZERO(VDOT(vect_b, vect_c), RT_DOT_TOL);
+}
+
+
 // Determines whether a tgc can be represented by a CCONE2 object.
 // Assumes that `tgc` is a valid rt_tgc_internal.
 HIDDEN bool
@@ -1094,10 +1104,7 @@
 {
     RT_TGC_CK_MAGIC(&tgc);
 
-    // ensure non-zero magnitudes
-    if (NEAR_ZERO(MAGNITUDE(tgc.h), RT_LEN_TOL)
-       || NEAR_ZERO(MAGNITUDE(tgc.a), RT_LEN_TOL)
-       || NEAR_ZERO(MAGNITUDE(tgc.b), RT_LEN_TOL))
+    if (NEAR_ZERO(MAGNITUDE(tgc.h), RT_LEN_TOL))
        return false;
 
     // ensure |A| == |B| and |C| == |D|
@@ -1105,16 +1112,15 @@
        || !NEAR_EQUAL(MAGNITUDE(tgc.c), MAGNITUDE(tgc.d), RT_LEN_TOL))
        return false;
 
-    // ensure h, a, b are mutually orthogonal
-    if (!NEAR_ZERO(VDOT(tgc.h, tgc.a), RT_DOT_TOL)
-       || !NEAR_ZERO(VDOT(tgc.h, tgc.b), RT_DOT_TOL)
-       || !NEAR_ZERO(VDOT(tgc.a, tgc.b), RT_DOT_TOL))
+    // handle non-truncated cones
+    if (NEAR_ZERO(MAGNITUDE(tgc.a), RT_LEN_TOL))
+       return mutually_orthogonal(tgc.h, tgc.c, tgc.d);
+    else if (NEAR_ZERO(MAGNITUDE(tgc.c), RT_LEN_TOL))
+       return mutually_orthogonal(tgc.h, tgc.a, tgc.b);
+
+    if (!mutually_orthogonal(tgc.h, tgc.a, tgc.b))
        return false;
 
-    // check for non-truncated cone
-    if (VNEAR_ZERO(tgc.c, RT_LEN_TOL))
-       return true;
-
     {
        // ensure unit vectors are equal
        vect_t a_norm, b_norm, c_norm, d_norm;

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


------------------------------------------------------------------------------
Don't Limit Your Business. Reach for the Cloud.
GigeNET's Cloud Solutions provide you with the tools and support that
you need to offload your IT needs and focus on growing your business.
Configured For All Businesses. Start Your Cloud Today.
https://www.gigenetcloud.com/
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to