shape ops work in progress
authorcaryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 22 Jan 2013 12:55:54 +0000 (12:55 +0000)
committercaryclark@google.com <caryclark@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Tue, 22 Jan 2013 12:55:54 +0000 (12:55 +0000)
git-svn-id: http://skia.googlecode.com/svn/trunk@7303 2bbb7eff-a529-9590-31e7-b0007b416f81

13 files changed:
experimental/Intersection/CubicIntersection.cpp
experimental/Intersection/CubicIntersection_Test.cpp
experimental/Intersection/CubicParameterization_Test.cpp
experimental/Intersection/CubicSubDivide.cpp
experimental/Intersection/CubicUtilities.cpp
experimental/Intersection/CubicUtilities.h
experimental/Intersection/CurveIntersection.h
experimental/Intersection/Intersection_Tests.cpp
experimental/Intersection/LineUtilities.h
experimental/Intersection/QuadraticParameterization_Test.cpp
experimental/Intersection/QuadraticSubDivide.cpp
experimental/Intersection/QuadraticUtilities.h
experimental/Intersection/TestUtilities.cpp

index 2c6cc3f..4ae0d84 100644 (file)
@@ -4,6 +4,8 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
+#include "CubicUtilities.h"
 #include "CurveIntersection.h"
 #include "Intersections.h"
 #include "IntersectionUtilities.h"
@@ -162,10 +164,12 @@ bool intersect(const Cubic& c1, const Cubic& c2, Intersections& i) {
 #include "CubicUtilities.h"
 
 // FIXME: ? if needed, compute the error term from the tangent length
+start here;
+// need better delta computation -- assert fails
 static double computeDelta(const Cubic& cubic, double t, double scale) {
-    double attempt = scale / precisionUnit;
+    double attempt = scale / precisionUnit * 2;
 #if SK_DEBUG
-    double precision = calcPrecision(cubic);
+    double precision = calcPrecision(cubic, t, scale);
     _Point dxy;
     dxdy_at_t(cubic, t, dxy);
     _Point p1, p2;
index c3ddded..8c2263e 100644 (file)
@@ -269,7 +269,6 @@ void CubicIntersection_RandTestOld() {
 void CubicIntersection_RandTest() {
     srand(0);
     const int tests = 1000000; // 10000000;
- //   double largestFactor = DBL_MAX;
     for (int test = 0; test < tests; ++test) {
         Cubic cubic1, cubic2;
         for (int i = 0; i < 4; ++i) {
@@ -292,7 +291,6 @@ void CubicIntersection_RandTest() {
         rect2.setBounds(cubic2);
         bool boundsIntersect = rect1.left <= rect2.right && rect2.left <= rect2.right
                 && rect1.top <= rect2.bottom && rect2.top <= rect1.bottom;
-        Intersections i1, i2;
         if (test == -1) {
             SkDebugf("ready...\n");
         }
index 114331a..517ae11 100644 (file)
@@ -4,6 +4,7 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+#include "QuadraticUtilities.h"
 #include "CurveIntersection.h"
 #include "Intersection_Tests.h"
 #include "Parameterization_Test.h"
index fa2025f..b7cc127 100644 (file)
@@ -4,7 +4,7 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
-#include "CurveIntersection.h"
+#include "CubicUtilities.h"
 #include "IntersectionUtilities.h"
 
 /*
index 36fc17e..19f16c6 100644 (file)
@@ -18,6 +18,15 @@ double calcPrecision(const Cubic& cubic) {
     return (width > height ? width : height) / precisionUnit;
 }
 
+#if SK_DEBUG
+double calcPrecision(const Cubic& cubic, double t, double scale) {
+    Cubic part;
+    sub_divide(cubic, SkMax32(0, t - scale), SkMin32(1, t + scale), part);
+    return calcPrecision(part);
+}
+#endif
+
+
 void coefficients(const double* cubic, double& A, double& B, double& C, double& D) {
     A = cubic[6]; // d
     B = cubic[4] * 3; // 3*c
index 6788b9c..5205574 100644 (file)
 #include "SkTDArray.h"
 
 double calcPrecision(const Cubic& cubic);
+#if SK_DEBUG
+double calcPrecision(const Cubic& cubic, double t, double scale);
+#endif
+void chop_at(const Cubic& src, CubicPair& dst, double t);
 double cube_root(double x);
 int cubic_to_quadratics(const Cubic& cubic, double precision,
         SkTDArray<Quadratic>& quadratics);
@@ -24,6 +28,7 @@ double dy_at_t(const Cubic& , double t);
 void dxdy_at_t(const Cubic& , double t, _Point& y);
 int find_cubic_inflections(const Cubic& src, double tValues[]);
 bool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath);
+void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
 void xy_at_t(const Cubic& , double t, double& x, double& y);
 
 extern const int precisionUnit;
index 4b34b31..5f27456 100644 (file)
@@ -15,17 +15,12 @@ class Intersections;
 double axialIntersect(const Quadratic& q1, const _Point& p, bool vert);
 bool bezier_clip(const Cubic& cubic1, const Cubic& cubic2, double& minT, double& maxT);
 bool bezier_clip(const Quadratic& q1, const Quadratic& q2, double& minT, double& maxT);
-void chop_at(const Cubic& src, CubicPair& dst, double t);
-void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
 int convex_hull(const Cubic& cubic, char order[4]);
 bool convex_x_hull(const Cubic& cubic, char connectTo0[2], char connectTo3[2]);
 bool implicit_matches(const Cubic& cubic1, const Cubic& cubic2);
 bool implicit_matches(const _Line& line1, const _Line& line2);
 bool implicit_matches_ulps(const _Line& one, const _Line& two, int ulps);
 bool implicit_matches(const Quadratic& quad1, const Quadratic& quad2);
-void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
-void sub_divide(const _Line& src, double t1, double t2, _Line& dst);
-void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
 void tangent(const Cubic& cubic, double t, _Point& result);
 void tangent(const _Line& line, _Point& result);
 void tangent(const Quadratic& quad, double t, _Point& result);
index 8e6e63e..cfa340f 100644 (file)
@@ -15,9 +15,9 @@ void cubecode_test(int test);
 void Intersection_Tests() {
     int testsRun = 0;
 
+    CubicIntersection_RandTest();
     QuadraticIntersection_Test();
     CubicIntersection_OneOffTest();
-    CubicIntersection_RandTest();
     SimplifyNew_Test();
     CubicsToQuadratics_RandTest();
     CubicToQuadratics_Test();
index 49e6a32..498b925 100644 (file)
@@ -8,7 +8,7 @@
 
 bool implicitLine(const _Line& line, double& slope, double& axisIntercept);
 int reduceOrder(const _Line& line, _Line& reduced);
-
+void sub_divide(const _Line& src, double t1, double t2, _Line& dst);
 double t_at(const _Line&, const _Point& );
 void xy_at_t(const _Line& , double t, double& x, double& y);
 
index df239dc..95eaccd 100644 (file)
@@ -7,6 +7,7 @@
 #include "CurveIntersection.h"
 #include "Intersection_Tests.h"
 #include "Parameterization_Test.h"
+#include "QuadraticUtilities.h"
 
 const Quadratic quadratics[] = {
     {{0, 0}, {1, 0}, {1, 1}},
index 436b5a9..a889825 100644 (file)
@@ -6,6 +6,7 @@
  */
 #include "CurveIntersection.h"
 #include "IntersectionUtilities.h"
+#include "QuadraticUtilities.h"
 
 /*
 Given a quadratic q, t1, and t2, find a small quadratic segment.
index 13893a1..0fe8be8 100644 (file)
@@ -9,6 +9,8 @@
 #define QUADRATIC_UTILITIES_H
 
 #include "DataTypes.h"
+
+void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
 double dx_at_t(const Quadratic& , double t);
 double dy_at_t(const Quadratic& , double t);
 void dxdy_at_t(const Quadratic& , double t, _Point& xy);
@@ -30,6 +32,7 @@ inline void set_abc(const double* quad, double& a, double& b, double& c) {
 
 int quadraticRoots(double A, double B, double C, double t[2]);
 int quadraticRootsX(const double A, const double B, const double C, double s[2]);
+void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
 void xy_at_t(const Quadratic& , double t, double& x, double& y);
 
 #endif
index 95ed1e0..0477ed4 100644 (file)
@@ -4,6 +4,8 @@
  * Use of this source code is governed by a BSD-style license that can be
  * found in the LICENSE file.
  */
+
+#include "CubicUtilities.h"
 #include "CurveIntersection.h"
 #include "TestUtilities.h"