/* 
 * File:   Region.h
 * Author: carlos
 *
 * Created on 6 de noviembre de 2012, 14:55
 */

#ifndef REGION_H
#define	REGION_H

#include <string>
#include <vector>
#include <math.h>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include "pt_t.h"
using namespace std;

class ImgRegion {
public:
    friend class boost::serialization::access;
    template<class Archive>
    void serialize(Archive &ar, const unsigned int version){
        ar & m_label;
        ar & m_points;
    }
    
//    struct pt_t{
//        int x;
//        int y;
//    };
    
    ImgRegion();
    ImgRegion(const ImgRegion& orig);
    virtual ~ImgRegion();
    
    ImgRegion(string label);
    int clearPoints();
    int addPoint(int x, int y);
    Pt_t getPoint(int i);
    int setPoint(int i, Pt_t value);
    int getNumPoints();
    int nearestPointIndex(int xCur, int yCur);
    int printPoints();
    int getMinX();
    int getMaxX();
    int getMinY();
    int getMaxY();
    bool pointInPolygon(int u, int v);

    void setLabel(string label) {
        this->m_label = label;
    }

    string getLabel() const {
        return m_label;
    }

    static double euclideanDistance(int x1, int y1, int x2, int y2){
        return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    }
    
    
private:
    
    
    string m_label;
    vector<Pt_t> m_points;
    

    
};

#endif	/* REGION_H */

