static void oneOffTests(skiatest::Reporter* reporter) {
    for (int outer = 0; outer < testSetCount - 1; ++outer) {
        for (int inner = outer + 1; inner < testSetCount; ++inner) {
            oneOff(reporter, outer, inner);
        }
    }
}
Example #2
0
void CubicIntersection_OneOffTest() {
    for (size_t outer = 0; outer < testSetCount - 1; ++outer) {
#if ONE_OFF_DEBUG
        SkDebugf("%s quads1[%d]\n", __FUNCTION__, outer);
#endif
        const Cubic& cubic1 = testSet[outer];
        for (size_t inner = outer + 1; inner < testSetCount; ++inner) {
#if ONE_OFF_DEBUG
        SkDebugf("%s quads2[%d]\n", __FUNCTION__, inner);
#endif
            const Cubic& cubic2 = testSet[inner];
            oneOff(cubic1, cubic2);
        }
    }
}
void outputPairsFile(FILE *out, int numRows, int numCols, 
		     struct lqRecord ***lqMatrix, struct cel ***celMatrix)
{
int i,j;
struct nmerAlign *nmer;
outputPairHeader(out);
for(i=0; i<numRows; i++)
    {
    for(j=0; j<numCols; j+=2)
	{
	struct lqRecord *pmLq=NULL, *mmLq = NULL;
	pmLq = lqMatrix[i][j];
	mmLq = lqMatrix[i][j+1];
	if(pmLq->nmerList != NULL && oneOff(pmLq->cols[2], mmLq->cols[2]))
	    {
	    for(nmer = pmLq->nmerList; nmer != NULL; nmer = nmer->next)
		{
		outputPair(out, pmLq, nmer, celMatrix[i][j], celMatrix[i][j+1]);
		}
	    }
	}
    }
}
Example #4
0
void CubicIntersection_RandTestOld() {
    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) {
            cubic1[i].x = (double) rand() / RAND_MAX * 100;
            cubic1[i].y = (double) rand() / RAND_MAX * 100;
            cubic2[i].x = (double) rand() / RAND_MAX * 100;
            cubic2[i].y = (double) rand() / RAND_MAX * 100;
        }
        if (test == 2513) { // the pair crosses three times, but the quadratic approximation
            continue; // only sees one -- should be OK to ignore the other two?
        }
        if (test == 12932) { // this exposes a weakness when one cubic touches the other but
            continue; // does not touch the quad approximation. Captured in qc.htm as cubic15
        }
    #if DEBUG_CRASH
        char str[1024];
        sprintf(str, "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n"
            "{{%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}, {%1.9g, %1.9g}},\n",
                cubic1[0].x, cubic1[0].y,  cubic1[1].x, cubic1[1].y, cubic1[2].x, cubic1[2].y,
                cubic1[3].x, cubic1[3].y,
                cubic2[0].x, cubic2[0].y,  cubic2[1].x, cubic2[1].y, cubic2[2].x, cubic2[2].y,
                cubic2[3].x, cubic2[3].y);
    #endif
        _Rect rect1, rect2;
        rect1.setBounds(cubic1);
        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 TRY_OLD
        bool oldIntersects = intersect(cubic1, cubic2, i1);
    #else
        bool oldIntersects = false;
    #endif
        if (test == -1) {
            SkDebugf("ready...\n");
        }
        bool newIntersects = intersect2(cubic1, cubic2, i2);
        if (!boundsIntersect && (oldIntersects || newIntersects)) {
            SkDebugf("%s %d unexpected intersection boundsIntersect=%d oldIntersects=%d"
                    " newIntersects=%d\n%s %s\n", __FUNCTION__, test, boundsIntersect,
                    oldIntersects, newIntersects, __FUNCTION__, str);
            assert(0);
        }
        if (oldIntersects && !newIntersects) {
            SkDebugf("%s %d missing intersection oldIntersects=%d newIntersects=%d\n%s %s\n",
                    __FUNCTION__, test, oldIntersects, newIntersects, __FUNCTION__, str);
            assert(0);
        }
        if (!oldIntersects && !newIntersects) {
            continue;
        }
        if (i2.used() > 1) {
            continue;
            // just look at single intercepts for simplicity
        }
        Intersections self1, self2; // self-intersect checks
        if (intersect(cubic1, self1)) {
            continue;
        }
        if (intersect(cubic2, self2)) {
            continue;
        }
        // binary search for range necessary to enclose real intersection
        CubicChopper c(cubic1, cubic2);
        bool result = c.intersect(0, 1, 0, 1);
        if (!result) {
            // FIXME: a failure here probably means that a core routine used by CubicChopper is failing
            continue;
        }
        double delta1 = fabs(c.t1 - i2.fT[0][0]);
        double delta2 = fabs(c.t2 - i2.fT[1][0]);
        double calc1 = calcPrecision(cubic1);
        double calc2 = calcPrecision(cubic2);
        double factor1 = calc1 / delta1;
        double factor2 = calc2 / delta2;
        SkDebugf("%s %d calc1=%1.9g delta1=%1.9g factor1=%1.9g calc2=%1.9g delta2=%1.9g"
                " factor2=%1.9g\n", __FUNCTION__, test,
                calc1, delta1, factor1, calc2, delta2, factor2);
        if (factor1 < largestFactor) {
            SkDebugf("WE HAVE A WINNER! %1.9g\n", factor1);
            SkDebugf("%s\n", str);
            oneOff(cubic1, cubic2);
            largestFactor = factor1;
        }
        if (factor2 < largestFactor) {
            SkDebugf("WE HAVE A WINNER! %1.9g\n", factor2);
            SkDebugf("%s\n", str);
            oneOff(cubic1, cubic2);
            largestFactor = factor2;
        }
    }
}
static void coinOneOff(skiatest::Reporter* reporter, int index) {
    const CubicPts& cubic1 = coinSet[index];
    const CubicPts& cubic2 = coinSet[index + 1];
    oneOff(reporter, cubic1, cubic2, true);
}
static void testsOneOff(skiatest::Reporter* reporter, int index) {
    const CubicPts& cubic1 = tests[index][0];
    const CubicPts& cubic2 = tests[index][1];
    oneOff(reporter, cubic1, cubic2, false);
}
static void newOneOff(skiatest::Reporter* reporter, int outer, int inner) {
    const CubicPts& cubic1 = newTestSet[outer];
    const CubicPts& cubic2 = newTestSet[inner];
    oneOff(reporter, cubic1, cubic2, false);
}
static void oneOff(skiatest::Reporter* reporter, int outer, int inner) {
    const SkDCubic& cubic1 = testSet[outer];
    const SkDCubic& cubic2 = testSet[inner];
    oneOff(reporter, cubic1, cubic2, false);
}
DEF_TEST(PathOpsConicIntersectionOneOff, reporter) {
    oneOff(reporter, 0, 1);
}
Example #10
0
static void CubicsToQuadratics_OneOffTest(skiatest::Reporter* reporter) {
    oneOff(reporter, 0);
}
Example #11
0
static void CubicsToQuadratics_OneOffTests(skiatest::Reporter* reporter) {
    for (size_t x = 0; x < localsCount; ++x) {
        oneOff(reporter, x);
    }
}