Revision: 55999
          http://sourceforge.net/p/brlcad/code/55999
Author:   phoenixyjll
Date:     2013-07-11 03:20:08 +0000 (Thu, 11 Jul 2013)
Log Message:
-----------
Clean up the code, and add a function for curve fitting, so that we can add 
more fitting methods (e.g. arc, ellipse, ...).

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

Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp      2013-07-10 21:43:36 UTC (rev 
55998)
+++ brlcad/trunk/src/libbrep/intersect.cpp      2013-07-11 03:20:08 UTC (rev 
55999)
@@ -1848,6 +1848,22 @@
 }
 
 
+ON_Curve*
+curve_fitting(ON_Curve* in, double fitting_tolerance, bool delete_curve = 
false)
+{
+    if (in == NULL)
+       return NULL;
+
+    if (in->IsLinear(fitting_tolerance)) {
+       ON_LineCurve *linecurve = new ON_LineCurve(in->PointAtStart(), 
in->PointAtEnd());
+       linecurve->ChangeDimension(in->Dimension());
+       if (delete_curve) delete in;
+       return linecurve;
+    }
+
+    return in;
+}
+
 int
 ON_Intersect(const ON_Surface* surfA,
             const ON_Surface* surfB,
@@ -2256,13 +2272,7 @@
            }
            curve = new ON_PolylineCurve(ptarray);
            curve->ChangeDimension(2);
-           if (curve->IsLinear(fitting_tolerance_A)) {
-               ON_LineCurve *linecurve = new 
ON_LineCurve(curve->PointAtStart(), curve->PointAtEnd());
-               linecurve->ChangeDimension(2);
-               intersect_uv2d.Append(linecurve);
-           } else {
-               intersect_uv2d.Append(curve);
-           }
+           intersect_uv2d.Append(curve_fitting(curve, fitting_tolerance_A, 
true));
 
            // The intersection curves in the 2d UV parameter space (surfB)
            ptarray.Empty();
@@ -2277,13 +2287,7 @@
            }
            curve = new ON_PolylineCurve(ptarray);
            curve->ChangeDimension(2);
-           if (curve->IsLinear(fitting_tolerance_B)) {
-               ON_LineCurve *linecurve = new 
ON_LineCurve(curve->PointAtStart(), curve->PointAtEnd());
-               linecurve->ChangeDimension(2);
-               intersect_st2d.Append(linecurve);
-           } else {
-               intersect_st2d.Append(curve);
-           }
+           intersect_st2d.Append(curve_fitting(curve, fitting_tolerance_B, 
true));
 
            delete polylines[i];
        }

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


------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to