/**
 * @file testPolygonClass.cpp
 * @brief test function of polygon class
 * @author Sven Sickert
 * @date 07/10/2015

*/

#include "vislearning/cbaselib/Polygon.h"

using namespace OBJREC;

int main ( int argc, char **argv )
{
    Polygon * poly1 = new Polygon ();
    Polygon * poly2 = new Polygon(*poly1);

    delete poly2;

    NICE::CoordT<int> coord( 10, 10);

    poly1->push( coord );
    poly1->push( 20, 20 );
    poly1->push( 10, 20 );
    poly1->setID( 42 );
    const PointsList* ptsList = poly1->points();

    poly1->pop();
    poly1->push ( 20, 10 );

    for ( PointsList::const_iterator it = ptsList->begin();
          it != ptsList->end(); ++it )
        std::cout << it->x << " " << it->y << std::endl;

    NICE::CoordT<int> test1( 18, 15 );
    std::cout << "Point (" << test1.x << "," << test1.y << ") in polygon?"
              << std::endl;
    if ( poly1->insidePolygon( test1) )
        std::cout << "true" << std::endl;
    else
        std::cout << "false" << std::endl;

    NICE::CoordT<int> test2( 5, 5 );
    std::cout << "Point (" << test2.x << "," << test2.y << ") in polygon?"
              << std::endl;
    if ( poly1->insidePolygon( test2) )
        std::cout << "true" << std::endl;
    else
        std::cout << "false" << std::endl;

    NICE::CoordT<int> test3( 10, 10 );
    std::cout << "Point (" << test3.x << "," << test3.y << ") in polygon?"
              << std::endl;
    if ( poly1->insidePolygon( test3) )
        std::cout << "true" << std::endl;
    else
        std::cout << "false" << std::endl;


    delete poly1;
}