Revision: 56655
          http://sourceforge.net/p/brlcad/code/56655
Author:   phoenixyjll
Date:     2013-08-07 02:22:50 +0000 (Wed, 07 Aug 2013)
Log Message:
-----------
The result after the Newton iterations might be nan.

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/intersect.cpp

Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp      2013-08-07 00:58:30 UTC (rev 
56654)
+++ brlcad/trunk/src/libbrep/intersect.cpp      2013-08-07 02:22:50 UTC (rev 
56655)
@@ -1220,13 +1220,20 @@
            newton_cci(t_a1, t_b1, curveA, curveB, intersection_tolerance);
            double t_a2 = i->first->m_t.Max(), t_b2 = i->second->m_t.Max();
            newton_cci(t_a2, t_b2, curveA, curveB, intersection_tolerance);
+           if (isnan(t_a1) || isnan(t_b1)) {
+               // The first iteration result is not sufficient
+               std::swap(t_a1, t_a2);
+               std::swap(t_b1, t_b2);
+           }
+           if (isnan(t_a1) || isnan(t_b1))
+               continue;
 
            ON_3dPoint pointA1 = curveA->PointAt(t_a1);
            ON_3dPoint pointB1 = curveB->PointAt(t_b1);
            ON_3dPoint pointA2 = curveA->PointAt(t_a2);
            ON_3dPoint pointB2 = curveB->PointAt(t_b2);
-           if (pointA1.DistanceTo(pointA2) < intersection_tolerance
-               && pointB1.DistanceTo(pointB2) < intersection_tolerance) {
+           if ((pointA1.DistanceTo(pointA2) < intersection_tolerance && 
pointB1.DistanceTo(pointB2) < intersection_tolerance)
+               || (isnan(t_a2) || isnan(t_b2))) {
                // it's considered the same point
                ON_3dPoint pointA = curveA->PointAt(t_a1);
                ON_3dPoint pointB = curveB->PointAt(t_b1);

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


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to