#ifndef PPM_H
#define PPM_H

#include <string>
using namespace std;

namespace math144_ppm
{

class image
{
public:
	/*
	 * Constructor
	 * Creates a new empty image variable.
	 * Usage:
	 * 	image foo;
	 */
	image();

	/*
	 * Constructor
	 * Creates a new image variable and loads the PPM image with
	 * name "filename" into it.
	 * Usage:
	 * 	image foo("bar.ppm");
	 */
	image(string filename);

	/*
	 * Constructor
	 * Creates a new image variable by copying the "src" image
	 * variable.
	 * Usage:
	 * 	image foo("bar.ppm");
	 * 	image foo_cpy(foo);
	 */
	image(const image &src);

	/* Destructor */
	~image();

	/*
	 * Opens a PPM image with name "filename" into the image
	 * variable.
	 * Usage:
	 * 	image foo;
	 * 	...
	 *	foo.open("bar.ppm");
	 */
	void open(string filename);

	/*
	 * Writes the image variable into a PPM image with name
	 * "filename".
	 * Usage:
	 * 	image foo("in.ppm");
	 * 	...
	 *	foo.save("out.ppm");
	 */
	void save(string filename);

	/*
	 * Writes each pixel to "out.csv" in comma-delimited format.  Readable
	 * by any text editor or a spreadsheet program, like Excel.  Useful for
	 * debugging purposes.
	 */
	void save_csv();

	/*
	 * Copies the "src" image variable into "dst".
	 * Usage:
	 * 	image foo("bar.ppm");
	 * 	image copy = foo;
	 */
	image& operator =(const image &src);

	/*
	 * Edits the image using the equation, level set equation,
	 * steady state level set equation, or shock filter equation,
	 * given either a delta-t or value for alpha, and the number
	 * of iterations (number of times to apply the PDE).
	 * Usage:
	 * 	image foo("bar.ppm");
	 * 	...
	 * 	heat(foo, .0001);
	 */
	friend void heat(image &img, double dt, unsigned int num_iter);
	friend void lvlset(image &img, double dt, unsigned int num_iter);
	friend void stdylvlset(image &img, double dt, double alpha);
	friend void shock(image &img, double dt, unsigned int num_iter);
private:
	/* Dimensions of the image */
	unsigned int width, height;

	/* A pointer to a block of memory containing the image data */
	double **data;
};

} // namespace math144

#endif // PPM_H

