/*!
 * \file Polygon.cpp
 * \brief
 * \author Gapchich Vladislav
 * \date 23/10/11
 */

#include "vislearning/cbaselib/Polygon.h"

using namespace OBJREC;
using namespace std;
using namespace NICE;

//! A constructor
Polygon::Polygon()
{
	points_.clear();
    id_ = -1;
    unique_id_ = -1;
}

// A copy-constructor
Polygon::Polygon(const Polygon &copy)
{
	points_ = PointsList(*(copy.points()));
	id_ = copy.id();
    unique_id_ = copy.unique_id_;
}

//! A desctructor
Polygon::~Polygon()
{
	
}

//! appends aPoint coordinate to the end of the point list 
void 
Polygon::push(const CoordT< int > &aPoint)
{
	if (aPoint.x < 0 || aPoint.y < 0) {
		return;
		/* NOTREACHED */
	}
	
	points_.push_back(aPoint);
}

//! overloaded
/*!
 * \see push(const CoordT< int > &aPoint)
 */
void
Polygon::push(const int &x, const int &y)
{
	if (x < 0 || y < 0) {
		return;
		/* NOTREACHED */
	}

	CoordT< int > point;
	point.x = x;
	point.y = y;
	points_.push_back(point);
}

//! Sets a category ID(label ID) for the polygon
/*!
 * /param[in] anID should not be less than zero 
 */
void 
Polygon::setID(const int &anID)
{
	if (anID < 0) {
		return;
		/* NOTREACHED */
	}
    this->id_ = anID;
}

//! returns a constant pointer to the list of polygon points(coordinates)
const PointsList * 
Polygon::points() const
{
	return &points_;	
}

//! deletes last added point of the polygon and returns it
CoordT< int > 
Polygon::pop()
{
	CoordT< int > ret = points_.back();
	points_.pop_back();
	return ret;
}

//! returns a category ID of the polygon
int 
Polygon::id() const
{
	return id_;
}
	
/*
 * 
 */
