shape ops work in progress

M    Intersection/DataTypes.cpp
M    Intersection/QuadraticIntersection_Test.cpp
M    Intersection/EdgeWalker.cpp
M    Intersection/LineQuadraticIntersection_Test.cpp
M    Intersection/LineIntersection_Test.cpp
M    Intersection/LineIntersection.cpp
D    Intersection/edge.xcodeproj
M    Intersection/SimplifyFindTop_Test.cpp
M    Intersection/DataTypes.h
A    Intersection/SimplifyRect4x4_Test.cpp
M    Intersection/CubicIntersection_Test.cpp
M    Intersection/QuadraticUtilities.h
M    Intersection/LineCubicIntersection_Test.cpp
A    Intersection/CurveUtilities.h
M    Intersection/QuadraticBezierClip.cpp
M    Intersection/QuadraticBounds.cpp
M    Intersection/LineUtilities.h
M    Intersection/Intersection_Tests.cpp
M    Intersection/Simplify.cpp
M    Intersection/EdgeWalker_TestUtility.cpp
M    Intersection/QuadraticUtilities.cpp
M    Intersection/thingsToDo.txt
M    Intersection/LineUtilities.cpp
M    Intersection/CubicUtilities.h
M    Intersection/SimplifyFindNext_Test.cpp
M    Intersection/Intersection_Tests.h
M    Intersection/CubicBezierClip.cpp
M    Intersection/ActiveEdge_Test.cpp
M    Intersection/CubicBounds.cpp
M    Intersection/Simplify.h
M    Intersection/SimplifyNew_Test.cpp
M    Intersection/EdgeWalker_Test.h
M    Intersection/CubicUtilities.cpp
M    Intersection/op.htm
M    Intersection/ConvexHull.cpp
D    Intersection/RectUtilities.cpp
M    Intersection/SimplifyAddIntersectingTs_Test.cpp



git-svn-id: http://skia.googlecode.com/svn/trunk@4429 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/experimental/Intersection/LineUtilities.cpp b/experimental/Intersection/LineUtilities.cpp
index ca94544..8a1c0d7 100644
--- a/experimental/Intersection/LineUtilities.cpp
+++ b/experimental/Intersection/LineUtilities.cpp
@@ -58,3 +58,64 @@
 }
 #endif
 
+double t_at(const _Line& line, const _Point& pt) {
+    double dx = line[1].x - line[0].x;
+    double dy = line[1].y - line[0].y;
+    if (fabs(dx) > fabs(dy)) {
+        if (approximately_zero(dx)) {
+            return 0;
+        }
+        return (pt.x - line[0].x) / dx;
+    }
+    if (approximately_zero(dy)) {
+        return 0;
+    }
+    return (pt.y - line[0].y) / dy;
+}
+
+static void setMinMax(double x, int flags, double& minX, double& maxX) {
+    if (minX > x && (flags & (kFindTopMin | kFindBottomMin))) {
+        minX = x;
+    }
+    if (maxX < x && (flags & (kFindTopMax | kFindBottomMax))) {
+        maxX = x;
+    }
+}
+
+void x_at(const _Point& p1, const _Point& p2, double top, double bottom,
+        int flags, double& minX, double& maxX) {
+    if (approximately_equal(p1.y, p2.y)) {
+        // It should be OK to bail early in this case. There's another edge
+        // which shares this end point which can intersect without failing to 
+        // have a slope ... maybe
+        return;
+    }
+    
+    // p2.x is always greater than p1.x -- the part of points (p1, p2) are
+    // moving from the start of the cubic towards its end.
+    // if p1.y < p2.y, minX can be affected
+    // if p1.y > p2.y, maxX can be affected 
+    double slope = (p2.x - p1.x) / (p2.y - p1.y);
+    int topFlags = flags & (kFindTopMin | kFindTopMax);
+    if (topFlags && (top <= p1.y && top >= p2.y
+            || top >= p1.y && top <= p2.y)) {
+        double x = p1.x + (top - p1.y) * slope;
+        setMinMax(x, topFlags, minX, maxX);
+    }
+    int bottomFlags = flags & (kFindBottomMin | kFindBottomMax);
+    if (bottomFlags && (bottom <= p1.y && bottom >= p2.y
+            || bottom >= p1.y && bottom <= p2.y)) {
+        double x = p1.x + (bottom - p1.y) * slope;
+        setMinMax(x, bottomFlags, minX, maxX);
+    }
+}
+
+void xy_at_t(const _Line& line, double t, double& x, double& y) {
+    double one_t = 1 - t;
+    if (&x) {
+        x = one_t * line[0].x + t * line[1].x;
+    }
+    if (&y) {
+        y = one_t * line[0].y + t * line[1].y;
+    }
+}