/*
	ZOutlineEvaluator.h
	Author: Patrick Baggett <ptbaggett@762studios.com>

	Purpose: TODO

	Changelog
	2011/09/18 - creation (ptbaggett)
*/

#pragma once

#ifndef _ZOUTLINEEVALUATOR_H
#define _ZOUTLINEEVALUATOR_H

#include <ZUtil/ZUtil.hpp>
#include <SST/SST_Vec2.h>

#include <vector>
#include <ft2build.h>
#include FT_FREETYPE_H

class ZOutlineEvaluator
{
private:
	FT_Outline* outline;
	int detail;
	int curContour;
	int* bounds;
	std::vector<SST_Vec2f> pts;

	//Process a curve
	int processCurve(int contour, int curveStart);

	//Evaluate a line segment
	void evalLinear(FT_Vector* p0, FT_Vector* p1);

	//Evaluate a quadric path (called conic)
	void evalQuadratic(FT_Vector* p0, FT_Vector* p1, FT_Vector* p2);

	//Evaluate a cubic path
	void evalCubic(FT_Vector* p0, FT_Vector* p1, FT_Vector* p2, FT_Vector* p3);

	//Adds a point
	void addPoint(const FT_Vector* pt);

public:
	/*
	Constructor.

	@param _outline - 
	@param _detail - 
	*/
	ZOutlineEvaluator(FT_Outline* _outline, int _detail);

	/*
	Destructor.
	*/
	~ZOutlineEvaluator();

	/*
	public ZOutlineEvaluator::evaluate
	
	TODO
	
	@return (void)
	@context (all)
	*/
	void evaluate();

	/*
	public ZOutlineEvaluator::getContourCount
	
	TODO
	
	@return (int)
	@context (all)
	*/
	int getContourCount() const;

	/*
	public ZOutlineEvaluator::getContourStart
	
	TODO
	
	@param contour - 
	@return (int)
	@context (all)
	*/
	int getContourStart(int contour) const;

	/*
	public ZOutlineEvaluator::getContourEnd
	
	TODO
	
	@param contour - 
	@return (int)
	@context (all)
	*/
	int getContourEnd(int contour) const;

	/*
	public ZOutlineEvaluator::getPoint
	
	TODO
	
	@param pt - 
	@return (const SST_Vec2f*)
	@context (all)
	*/
	const SST_Vec2f* getPoint(int pt) const;

	/*
	public ZOutlineEvaluator::printContourPoints
	
	TODO
	
	@param contour - 
	@return (void)
	@context (all)
	*/
	void printContourPoints(int contour);
};

#endif
