TestPolygonCalculus.cpp 1.26 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
#include "TestPolygonCalculus.h"
#include "PolygonCalculus.h"
#include <QPolygonF>
#include <QPointF>

namespace TestPolygonCalculus {
    void test()
    {
        using namespace PolygonCalculus;

        QPolygonF polygon;
        polygon << QPointF(0, 0) << QPointF(1, 0) << QPointF(1, 1) << QPointF(0, 1);

        bool retVal = containsPath(polygon, QPointF(0.1, 0.1), QPointF(0.2, 0.1));
        qDebug("true %i", retVal);
        retVal = containsPath(polygon, QPointF(0.2, 0.1), QPointF(0.2, 0.1));
        qDebug("true %i", retVal);
        retVal = containsPath(polygon, QPointF(1, 0.1), QPointF(0.2, 0.1));
        qDebug("true %i", retVal);
        retVal = containsPath(polygon, QPointF(0.1, 0.1), QPointF(1, 0.1));
        qDebug("true %i", retVal);
        retVal = containsPath(polygon, QPointF(2, 0.1), QPointF(0.2, 0.1));
        qDebug("false %i", retVal);
        retVal = containsPath(polygon, QPointF(-2, 0.1), QPointF(0.2, 0.1));
        qDebug("false %i", retVal);
        polygon << QPointF(0.5, 0.6) << QPointF(0.5, 0.4);
        retVal = containsPath(polygon, QPointF(0.2, 0.1), QPointF(0.2, 0.9));
        qDebug("false %i", retVal);
        retVal = containsPath(polygon, QPointF(0.1, 0.05), QPointF(0.51, 0.6));
        qDebug("false %i", retVal);
    }

}