#include "mesh2pov.h"
#include "povmesh.h"

#include <QTextStream>
#include <QDebug>

Obj2POV::Obj2POV()
{
}

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

	QTextStream t (&in);


	double max=0;

	while (!t.atEnd())
	{
		QString l = t.readLine();
		QStringList parts = l.split(" ");

		//qDebug() << parts;

		if (parts[0]=="v")
			mesh.addVertice(parts[1].toDouble(), parts[2].toDouble(), parts[3].toDouble());

		if (parts[0]=="f")
			mesh.addFace(parts[1].toLong()-1, parts[2].toLong()-1, parts[3].toLong()-1);

	}

	QTextStream to (&out);

	to << mesh;

	qDebug() << max;
}
