2007-10-17 09:57:04 +02:00
|
|
|
#ifndef __VCGLIB_EXPORTERU3D
|
|
|
|
#define __VCGLIB_EXPORTERU3D
|
|
|
|
|
2007-10-17 12:03:14 +02:00
|
|
|
#include <cstdlib>
|
2007-10-17 09:57:04 +02:00
|
|
|
#include <string>
|
2007-10-17 12:03:14 +02:00
|
|
|
#include <QDir.h>
|
|
|
|
#include<QString.h>
|
2007-10-18 17:01:53 +02:00
|
|
|
#include <QProcess.h>
|
2007-10-17 12:03:14 +02:00
|
|
|
|
|
|
|
#include "export_idtf.h"
|
2007-10-17 09:57:04 +02:00
|
|
|
|
|
|
|
namespace vcg {
|
|
|
|
namespace tri {
|
|
|
|
namespace io {
|
|
|
|
|
|
|
|
template<typename SaveMeshType>
|
|
|
|
class ExporterU3D
|
|
|
|
{
|
|
|
|
private:
|
|
|
|
|
2007-10-18 17:01:53 +02:00
|
|
|
static void InvokeConverter(const QString& converter_path,const QString& input_idtf,const QString& output_u3d)
|
2007-10-17 09:57:04 +02:00
|
|
|
{
|
2007-10-18 17:01:53 +02:00
|
|
|
QProcess p;
|
|
|
|
|
|
|
|
p.start(converter_path + "IDTFConverter.exe -input " + input_idtf + " -output " + output_u3d);
|
|
|
|
//wait for two minutes
|
|
|
|
bool t = p.waitForFinished(120000);
|
|
|
|
p.close();
|
2007-10-17 09:57:04 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 17:01:53 +02:00
|
|
|
static void SaveLatex(SaveMeshType& m,const QString& file)
|
|
|
|
{
|
|
|
|
Output_File latex(file.toStdString() + ".tex");
|
|
|
|
QString u3df = file + ".u3d";
|
2007-10-19 12:49:20 +02:00
|
|
|
latex.write(0,"\\begin{document}");
|
2007-10-18 17:01:53 +02:00
|
|
|
latex.write(0,"\\includemovie[");
|
|
|
|
latex.write(1,"poster,");
|
|
|
|
latex.write(1,"toolbar, %same as `controls\'");
|
|
|
|
latex.write(1,"label=" + file.toStdString() + ",");
|
|
|
|
latex.write(1,"text=(" + u3df.toStdString() + "),");
|
|
|
|
latex.write(1,"3Daac=60, 3Dcoo=-3.382026195526123 -63.33322525024414 -3.2237343788146973, 3Droo=1.4597717633624103,");
|
|
|
|
latex.write(1,"3Dlights=File,");
|
|
|
|
latex.write(0,"]{\\linewidth}{\\linewidth}{" + u3df.toStdString() + "}");
|
|
|
|
latex.write(0,"\\end{document}");
|
|
|
|
}
|
2007-10-17 12:03:14 +02:00
|
|
|
|
2007-10-17 09:57:04 +02:00
|
|
|
public:
|
|
|
|
|
2007-10-19 12:49:20 +02:00
|
|
|
static int Save(SaveMeshType& m,const char* outputfile,const int mask,const char* converter_path)
|
2007-10-17 09:57:04 +02:00
|
|
|
{
|
2007-10-18 17:01:53 +02:00
|
|
|
QString curr = QDir::currentPath();
|
|
|
|
QString tmp(QDir::tempPath());
|
2007-10-19 12:49:20 +02:00
|
|
|
QString pathout(outputfile);
|
|
|
|
QStringList pathlist = pathout.split('/');
|
|
|
|
QString filename;
|
|
|
|
QString outputcom;
|
|
|
|
if (pathlist.size() != 0)
|
|
|
|
{
|
|
|
|
filename = pathlist.at(pathlist.size() - 1);
|
|
|
|
if (pathlist.size() > 1)
|
|
|
|
outputcom = pathout;
|
|
|
|
else
|
|
|
|
outputcom = curr + "/" + filename;
|
|
|
|
}
|
|
|
|
else return 1;
|
|
|
|
|
|
|
|
tmp = tmp + "/" + filename + ".idtf";
|
|
|
|
|
2007-10-18 17:01:53 +02:00
|
|
|
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
|
2007-10-19 12:49:20 +02:00
|
|
|
InvokeConverter(converter_path,qPrintable(tmp),qPrintable(outputcom));
|
2007-10-18 17:01:53 +02:00
|
|
|
QDir::setCurrent(curr);
|
|
|
|
QString lat (outputfile);
|
|
|
|
QStringList l = lat.split(".");
|
|
|
|
SaveLatex(m,l[0]);
|
|
|
|
QDir dir(QDir::tempPath());
|
|
|
|
dir.remove(tmp);
|
2007-10-19 12:49:20 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int GetExportMaskCapability()
|
|
|
|
{
|
|
|
|
int capability = 0;
|
|
|
|
|
|
|
|
//camera
|
|
|
|
//capability |= MeshModel::IOM_CAMERA;
|
|
|
|
|
|
|
|
//vert
|
|
|
|
capability |= MeshModel::IOM_VERTNORMAL;
|
|
|
|
capability |= MeshModel::IOM_VERTTEXCOORD;
|
|
|
|
//capability |= MeshModel::
|
|
|
|
////face
|
|
|
|
////capability |= MeshModel::IOM_FACEFLAGS;
|
|
|
|
////capability |= MeshModel::IOM_FACECOLOR;
|
|
|
|
//capability |= MeshModel::IOM_FACENORMAL;
|
|
|
|
|
|
|
|
////wedg
|
|
|
|
capability |= MeshModel::IOM_WEDGTEXCOORD;
|
|
|
|
capability |= MeshModel::IOM_WEDGNORMAL;
|
|
|
|
|
|
|
|
return capability;
|
2007-10-17 09:57:04 +02:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|