/********************************************************************
 * File: Model.h
 * Author: Keith Schwarz (htiek@cs.stanford.edu)
 *
 * A class representing a 3D model.  The model is stored as a collection
 * of vertices, along with a collection of triangles made of those vertices.
 */
#ifndef Model_Included
#define Model_Included

#include <vector>
#include "Triangle.h"
#include "Matrix.h"
#include "RefCountedObject.h"

namespace Copper3D
{
	class Model: public RefCountedObject
	{
	public:
		/* Adds a new point to the model. */
		size_t addPoint(const Vector<3>& pt);

		/* Adds a new triangle to the model. */
		size_t addTriangle(const Triangle& tri);

		/* Query the number of points/triangles. */
		size_t numPoints() const;
		size_t numTriangles() const;

		/* Iterator support. */
		typedef std::vector< Vector<3> >::const_iterator point_iterator;
		typedef std::vector< Triangle >::const_iterator triangle_iterator;

		point_iterator point_begin() const;
		point_iterator point_end() const;
		triangle_iterator triangle_begin() const;
		triangle_iterator triangle_end() const;

		/* Element lookup. */
		Vector<3> point(size_t index) const;
		Triangle  triangle(size_t index) const;

		/* Name of the model. */
		std::string name() const;

		/* Factory. */
		static Model* New(const std::string& name);		

	private:
		Model(const std::string& name);
		~Model();

		std::string mName;
		std::vector< Vector<3> > mPoints;
		std::vector< Triangle >  mTriangles;
	};
}

#endif