vcglib/wrap/io_trimesh/export_u3d.h

84 lines
2.1 KiB
C
Raw Normal View History

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>
#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:
#ifdef WIN32
static void InvokeConverter(const QString& converter_path,const QString& input_idtf,const QString& output_u3d)
2007-10-17 09:57:04 +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
}
#else
#ifdef LINUX
static void InvokeConverter(const char* converter_path,const QString& input_idtf,const QString& output_u3d)
2007-10-17 12:03:14 +02:00
{
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 12:03:14 +02:00
}
2007-10-17 09:57:04 +02:00
#endif
#endif
static void SaveLatex(SaveMeshType& m,const QString& file)
{
Output_File latex(file.toStdString() + ".tex");
QString u3df = file + ".u3d";
latex.write(0,"\\\begin{document}");
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:
static void Save(SaveMeshType& m,const char* outputfile,const int mask,const char* converter_path)
2007-10-17 09:57:04 +02:00
{
QString curr = QDir::currentPath();
QString tmp(QDir::tempPath());
tmp = tmp + "/" + outputfile + ".idtf";
vcg::tri::io::ExporterIDTF<SaveMeshType>::Save(m,qPrintable(tmp),mask);
InvokeConverter(converter_path,qPrintable(tmp),qPrintable(curr + "/" + outputfile));
QDir::setCurrent(curr);
QString lat (outputfile);
QStringList l = lat.split(".");
SaveLatex(m,l[0]);
QDir dir(QDir::tempPath());
dir.remove(tmp);
2007-10-17 09:57:04 +02:00
}
};
}
}
}
#endif