/******************************************************************************************
> [KAZOE]                                                                                 <
> Initial Sofware by [Yannick Verdie, Florent Lafarge], Copyright (C) Inria (GEOMETRICA)  <
> All Rights Reserved, 2012, [Version 1.0].                                               <
******************************************************************************************/
#ifndef _SIM_H_
#define _SIM_H_

#include <stdexcept>
#include <vector>

#include "Stat.h"
#include "GPU_common_header.h"
#include "ParameterFile.h"

#include <CImg.h>


using namespace cimg_library;

class Simulation_GPU
{
public:
	/// Constructor with non homogeneous poisson reference measure
	Simulation_GPU(const CImg<int>  pictureInput , const ParameterFile parameterInput);
	~Simulation_GPU();

	void geometricalDecrease (int verbose = 0, bool saveLastState = false);

	double tryCasualMove ( double temperature);
	void init(METHOD_DATATERM method = METHOD_DATATERM::BAYESIAN);
	int getNbShapes();
	const double getToTalEnergy() const;
	const double getToTalTime();
	const void save( const char* name, char* nameImageResult = NULL, bool verbose = false);
	void startTimer();
	void waitUntilDone();
	float getTime();
	void setStat(GPU_Stat* stat);

	Const_Parameter *my_param ;
	double m_time;

private:
	double tryBirthDeath ( double temperature);
	double tryTranslation ( double temperature);
	double tryRotation	  ( double temperature);
	double tryEnlargeShrink ( double temperature);
	double tryBijection ( double temperature);
	double tryChangeHeight ( double temperature);
    
protected :
	int sizeBorder;
	int half_size_cell;
	const CImg<int> * ptrPictureInput;
	const vector<int> * ptrVectorInput;
	ParameterFile* ptrParamsInput;
    double currentTemperature;
    double currentDecreaseFactor;
    double currentEnergy;

	GPU_Stat* m_stat;

	double m_ratio_birth_death;
	METHOD_DATATERM m_method;
};

#endif