2012-08-27 14:11:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2012-02-03 22:07:47 +00:00
|
|
|
#include "CurveIntersection.h"
|
2012-01-25 18:57:23 +00:00
|
|
|
#include "Intersection_Tests.h"
|
|
|
|
#include "QuadraticIntersection_TestData.h"
|
2012-01-10 21:46:10 +00:00
|
|
|
|
2012-05-18 20:50:33 +00:00
|
|
|
static const Quadratic testSet[] = {
|
2012-08-28 20:44:43 +00:00
|
|
|
// data for oneOffTest
|
2012-05-18 20:50:33 +00:00
|
|
|
{{8.0000000000000071, 8.0000000000000071},
|
|
|
|
{8.7289570079366854, 8.7289570079366889},
|
|
|
|
{9.3914917259458743, 9.0593802763083691}},
|
|
|
|
{{8.0000000000000142, 8.0000000000000142},
|
|
|
|
{8.1250000000000107, 8.1250000000000071},
|
2012-08-28 20:44:43 +00:00
|
|
|
{8.2500000000000071, 8.2187500000000053}},
|
|
|
|
// data for oneAtEndTest
|
|
|
|
{{0.91292418204644155, 0.41931201426549197},
|
|
|
|
{0.70491388044579517, 0.64754305977710236},
|
|
|
|
{0, 1 }},
|
|
|
|
{{0.21875, 0.765625 },
|
|
|
|
{0.125, 0.875 },
|
|
|
|
{0, 1 }}
|
2012-05-18 20:50:33 +00:00
|
|
|
};
|
|
|
|
|
2012-08-28 20:44:43 +00:00
|
|
|
static void oneAtEndTest() {
|
|
|
|
const Quadratic& quad1 = testSet[2];
|
|
|
|
const Quadratic& quad2 = testSet[3];
|
|
|
|
double minT = 0;
|
|
|
|
double maxT = 1;
|
|
|
|
bezier_clip(quad1, quad2, minT, maxT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-05-18 20:50:33 +00:00
|
|
|
static void oneOffTest() {
|
|
|
|
const Quadratic& quad1 = testSet[0];
|
|
|
|
const Quadratic& quad2 = testSet[1];
|
|
|
|
double minT = 0;
|
|
|
|
double maxT = 1;
|
|
|
|
bezier_clip(quad1, quad2, minT, maxT);
|
|
|
|
}
|
|
|
|
|
2012-06-01 17:44:28 +00:00
|
|
|
static void standardTestCases() {
|
2012-01-25 18:57:23 +00:00
|
|
|
for (size_t index = 0; index < quadraticTests_count; ++index) {
|
|
|
|
const Quadratic& quad1 = quadraticTests[index][0];
|
|
|
|
const Quadratic& quad2 = quadraticTests[index][1];
|
|
|
|
Quadratic reduce1, reduce2;
|
2013-02-17 01:41:25 +00:00
|
|
|
int order1 = reduceOrder(quad1, reduce1, kReduceOrder_TreatAsFill);
|
|
|
|
int order2 = reduceOrder(quad2, reduce2, kReduceOrder_TreatAsFill);
|
2012-01-25 18:57:23 +00:00
|
|
|
if (order1 < 3) {
|
2013-01-29 20:28:49 +00:00
|
|
|
SkDebugf("%s [%d] quad1 order=%d\n", __FUNCTION__, (int)index, order1);
|
2012-01-25 18:57:23 +00:00
|
|
|
}
|
|
|
|
if (order2 < 3) {
|
2013-01-29 20:28:49 +00:00
|
|
|
SkDebugf("%s [%d] quad2 order=%d\n", __FUNCTION__, (int)index, order2);
|
2012-01-25 18:57:23 +00:00
|
|
|
}
|
|
|
|
if (order1 == 3 && order2 == 3) {
|
|
|
|
double minT = 0;
|
|
|
|
double maxT = 1;
|
|
|
|
bezier_clip(reduce1, reduce2, minT, maxT);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-05-18 20:50:33 +00:00
|
|
|
|
|
|
|
void QuadraticBezierClip_Test() {
|
2012-08-28 20:44:43 +00:00
|
|
|
oneAtEndTest();
|
2012-05-18 20:50:33 +00:00
|
|
|
oneOffTest();
|
|
|
|
standardTestCases();
|
|
|
|
}
|