diff options
author | 2012-10-09 14:11:58 +0000 | |
---|---|---|
committer | 2012-10-09 14:11:58 +0000 | |
commit | 6aea33f92c611d6fdc88bc2352c5c966168af83b (patch) | |
tree | 0afc954993f542c618413c659d21f1680065221a /experimental/Intersection/QuadraticIntersection_Test.cpp | |
parent | 9598f4256d729434a9e7273a7de1e4876eaacee9 (diff) |
checkpoint for shape ops
at minimum, the unit tests in SimplyNew_Test pass
git-svn-id: http://skia.googlecode.com/svn/trunk@5860 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'experimental/Intersection/QuadraticIntersection_Test.cpp')
-rw-r--r-- | experimental/Intersection/QuadraticIntersection_Test.cpp | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/experimental/Intersection/QuadraticIntersection_Test.cpp b/experimental/Intersection/QuadraticIntersection_Test.cpp index 08736cc948..e077bd5f93 100644 --- a/experimental/Intersection/QuadraticIntersection_Test.cpp +++ b/experimental/Intersection/QuadraticIntersection_Test.cpp @@ -59,6 +59,10 @@ static void standardTestCases() { } static const Quadratic testSet[] = { + {{400.121704, 149.468719}, {391.949493, 161.037186}, {391.949493, 181.202423}}, + {{391.946747, 181.839218}, {391.946747, 155.62442}, {406.115479, 138.855438}}, + {{360.048828125, 229.2578125}, {360.048828125, 224.4140625}, {362.607421875, 221.3671875}}, + {{362.607421875, 221.3671875}, {365.166015625, 218.3203125}, {369.228515625, 218.3203125}}, {{8, 8}, {10, 10}, {8, -10}}, {{8, 8}, {12, 12}, {14, 4}}, {{8, 8}, {9, 9}, {10, 8}} @@ -71,12 +75,13 @@ static void oneOffTest() { for (size_t inner = outer + 1; inner < testSetCount; ++inner) { const Quadratic& quad1 = testSet[outer]; const Quadratic& quad2 = testSet[inner]; + double tt1, tt2; + #if 0 // enable to test bezier clip style intersection Intersections intersections; intersect(quad1, quad2, intersections); if (!intersections.intersected()) { SkDebugf("%s no intersection!\n", __FUNCTION__); } - double tt1, tt2; for (int pt = 0; pt < intersections.used(); ++pt) { tt1 = intersections.fT[0][pt]; double tx1, ty1; @@ -97,8 +102,10 @@ static void oneOffTest() { SkDebugf("%s [%d][%d] t1=%1.9g (%1.9g, %1.9g) t2=%1.9g\n", __FUNCTION__, outer, inner, tt1, tx1, tx2, tt2); } + #endif Intersections intersections2; intersect2(quad1, quad2, intersections2); + #if 0 SkASSERT(intersections.used() == intersections2.used()); for (int pt = 0; pt < intersections2.used(); ++pt) { tt1 = intersections2.fT[0][pt]; @@ -106,6 +113,28 @@ static void oneOffTest() { tt2 = intersections2.fT[1][pt]; SkASSERT(approximately_equal(intersections.fT[1][pt], tt2)); } + #endif + for (int pt = 0; pt < intersections2.used(); ++pt) { + tt1 = intersections2.fT[0][pt]; + double tx1, ty1; + xy_at_t(quad1, tt1, tx1, ty1); + int pt2 = intersections2.fFlip ? intersections2.used() - pt - 1 : pt; + tt2 = intersections2.fT[1][pt2]; + double tx2, ty2; + xy_at_t(quad2, tt2, tx2, ty2); + if (!approximately_equal(tx1, tx2)) { + SkDebugf("%s [%d,%d] x!= t1=%g (%g,%g) t2=%g (%g,%g)\n", + __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2); + SkASSERT(0); + } + if (!approximately_equal(ty1, ty2)) { + SkDebugf("%s [%d,%d] y!= t1=%g (%g,%g) t2=%g (%g,%g)\n", + __FUNCTION__, (int)index, pt, tt1, tx1, ty1, tt2, tx2, ty2); + SkASSERT(0); + } + SkDebugf("%s [%d][%d] t1=%1.9g (%1.9g, %1.9g) t2=%1.9g\n", __FUNCTION__, + outer, inner, tt1, tx1, tx2, tt2); + } } } } @@ -148,7 +177,7 @@ static void coincidentTest() { } void QuadraticIntersection_Test() { - coincidentTest(); oneOffTest(); + coincidentTest(); standardTestCases(); } |