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"
|
2012-02-03 22:07:47 +00:00
|
|
|
#include "Parameterization_Test.h"
|
2013-01-22 12:55:54 +00:00
|
|
|
#include "QuadraticUtilities.h"
|
2012-01-10 21:46:10 +00:00
|
|
|
|
|
|
|
const Quadratic quadratics[] = {
|
|
|
|
{{0, 0}, {1, 0}, {1, 1}},
|
|
|
|
};
|
|
|
|
|
|
|
|
const size_t quadratics_count = sizeof(quadratics) / sizeof(quadratics[0]);
|
|
|
|
|
|
|
|
int firstQuadraticCoincidenceTest = 0;
|
|
|
|
|
|
|
|
void QuadraticCoincidence_Test() {
|
|
|
|
// split large quadratic
|
|
|
|
// compare original, parts, to see if the are coincident
|
|
|
|
for (size_t index = firstQuadraticCoincidenceTest; index < quadratics_count; ++index) {
|
|
|
|
const Quadratic& test = quadratics[index];
|
|
|
|
QuadraticPair split;
|
|
|
|
chop_at(test, split, 0.5);
|
|
|
|
Quadratic midThird;
|
|
|
|
sub_divide(test, 1.0/3, 2.0/3, midThird);
|
2012-01-25 18:57:23 +00:00
|
|
|
const Quadratic* quads[] = {
|
|
|
|
&test, &midThird, &split.first(), &split.second()
|
|
|
|
};
|
|
|
|
size_t quadsCount = sizeof(quads) / sizeof(quads[0]);
|
|
|
|
for (size_t one = 0; one < quadsCount; ++one) {
|
|
|
|
for (size_t two = 0; two < quadsCount; ++two) {
|
|
|
|
for (size_t inner = 0; inner < 3; inner += 2) {
|
|
|
|
if (!point_on_parameterized_curve(*quads[one], (*quads[two])[inner])) {
|
2013-01-29 20:28:49 +00:00
|
|
|
SkDebugf("%s %zu [%zu,%zu] %zu parameterization failed\n",
|
2012-01-25 18:57:23 +00:00
|
|
|
__FUNCTION__, index, one, two, inner);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!implicit_matches(*quads[one], *quads[two])) {
|
2013-01-29 20:28:49 +00:00
|
|
|
SkDebugf("%s %zu [%zu,%zu] coincidence failed\n", __FUNCTION__,
|
2012-01-25 18:57:23 +00:00
|
|
|
index, one, two);
|
|
|
|
}
|
|
|
|
}
|
2012-01-10 21:46:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|