#include "mesh2pov.h"

#include <QTextStream>
#include <QDebug>

#include "povmesh.h"


Mesh2POV::Mesh2POV()
{
}

void Mesh2POV::convert(QIODevice& in, QIODevice& out) const
{
	POVMesh2 mesh;

	QTextStream t (&in);

	unsigned int num_in;

	t >> num_in;
	qDebug() << num_in;

	double x,y,z;
	unsigned int count;
	double max=0;

	for (unsigned int i = 0; i < num_in; ++i)
	{
		t >> count >> x >> y >> z;
		
		mesh.addVertice(x,y,z);

		if (x>max)
			max=x;

		qDebug() << x << y << z;
	}

	
	
	t >> num_in;
	for (unsigned int i = 0; i < num_in; ++i)
	{
		t >> count >> x >> y >> z;
		
		mesh.addFace(x,y,z);

		qDebug() << x << y << z;
	}

	QTextStream to (&out);

	to << mesh;

	qDebug() << max;
}
