mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 11:26:11 +00:00
fixed some bug about mesh directory
refactoring of part of code (removed method getFileNameFromPath)
This commit is contained in:
parent
549fae223d
commit
97166b5621
@ -129,17 +129,13 @@ bool FilterHighQualityRender::applyFilter(QAction *filter, MeshDocument &md, Ric
|
||||
QTime tt; tt.start(); //time for debuging
|
||||
qDebug("Starting apply filter");
|
||||
|
||||
QString templateName = templates.at(par.getEnum("scene"));
|
||||
QString templatePath = templatesDir.absolutePath() + QDir::separator() + templateName + QDir::separator() + templateName + ".rib";
|
||||
QDir templateDir(templatesDir);
|
||||
templateDir.cd(templateName);
|
||||
QString templateDirString = getDirFromPath(&templatePath);
|
||||
QString templateName = templates.at(par.getEnum("scene")); //name of selected template
|
||||
QDir templateDir(templatesDir.absolutePath() + QDir::separator() + templateName); //dir of selected template (in string)
|
||||
QString templatePath = templateDir.absolutePath() + QDir::separator() + templateName + ".rib";
|
||||
|
||||
//directory of current mesh
|
||||
//QString meshDirString = QString(m.fileName.c_str());
|
||||
QString meshDirString = QString(m->fullName());
|
||||
meshDirString = getDirFromPath(&meshDirString);
|
||||
|
||||
QString meshDirString = m->pathName();
|
||||
|
||||
//name and format of final image
|
||||
QString imageName = par.getString("ImageName");
|
||||
int imageFormat = par.getEnum("ImageFormat");
|
||||
@ -181,20 +177,24 @@ bool FilterHighQualityRender::applyFilter(QAction *filter, MeshDocument &md, Ric
|
||||
return false;
|
||||
}
|
||||
|
||||
//destination diretory + main file
|
||||
//destination diretory (+ main file ?)
|
||||
QString destDirString = destDir.absolutePath();
|
||||
|
||||
//TEXTURE: take the list of texture mesh
|
||||
QStringList textureList = QStringList();
|
||||
QStringList textureListPath = QStringList();
|
||||
QStringList textureListName = QStringList();
|
||||
for(int i=0; i<m->cm.textures.size(); i++) {
|
||||
textureList << QString(m->cm.textures[i].c_str());
|
||||
QString path = QString(m->cm.textures[i].c_str());
|
||||
textureListPath << path;
|
||||
QString name = path.right(path.size() - 1 - std::max<int>(path.lastIndexOf('\\'),path.lastIndexOf('/')));
|
||||
textureListName << name;
|
||||
}
|
||||
|
||||
QStringList shaderDirs, textureDirs, proceduralDirs, imagesRendered;
|
||||
|
||||
//read the template files and create the new scenes files
|
||||
qDebug("Starting reading cycle %i",tt.elapsed());
|
||||
if(!makeScene(m, &textureList, par, templatePath, destDirString, &shaderDirs, &textureDirs, &proceduralDirs, &imagesRendered))
|
||||
if(!makeScene(m, &textureListName, par, templatePath, destDirString, &shaderDirs, &textureDirs, &proceduralDirs, &imagesRendered))
|
||||
return false; //message already set
|
||||
qDebug("Cycle ending at %i",tt.elapsed());
|
||||
Log(GLLogStream::FILTER,"Successfully created scene");
|
||||
@ -287,13 +287,13 @@ bool FilterHighQualityRender::applyFilter(QAction *filter, MeshDocument &md, Ric
|
||||
}
|
||||
qDebug("Compiled shaders at %i",tt.elapsed());
|
||||
|
||||
//Copy and convert to tiff format, all mesh textures, in dest dir and convert the to renderman format
|
||||
//multi-texture not supported!Copy and convert only the first texture
|
||||
if(textureList.count() > 0) {
|
||||
//all mesh textures are copied in dest dir and are converted to tiff format, then are converted to renderman format
|
||||
//*******multi-texture not supported!The plugin copies and converts only the first texture***********
|
||||
if(textureListPath.count() > 0) {
|
||||
//foreach(QString textureName, textureList) {
|
||||
QString textureName = textureList.first();
|
||||
|
||||
QFile srcFile(meshDirString + QDir::separator() + textureName);
|
||||
QString texturePath = textureListPath.first(); //it's a texture path...
|
||||
QString textureName = textureListName.first();
|
||||
QFile srcFile(meshDirString + QDir::separator() + texturePath);
|
||||
|
||||
//position in the first readable/writable between textures directories
|
||||
QString newImageDir = ".";
|
||||
@ -305,7 +305,7 @@ bool FilterHighQualityRender::applyFilter(QAction *filter, MeshDocument &md, Ric
|
||||
}
|
||||
}
|
||||
qDebug("source texture directory: %s", qPrintable(srcFile.fileName()));
|
||||
QString newTex = destDirString + QDir::separator() + newImageDir + QDir::separator() + getFileNameFromPath(&textureName,false);
|
||||
QString newTex = destDirString + QDir::separator() + newImageDir + QDir::separator() + textureName;
|
||||
qDebug("destination texture directory: %s", qPrintable(newTex + ".tiff"));
|
||||
if(srcFile.exists())
|
||||
{
|
||||
@ -320,9 +320,9 @@ bool FilterHighQualityRender::applyFilter(QAction *filter, MeshDocument &md, Ric
|
||||
//set working directory the location of texture
|
||||
convertTextureProcess.setWorkingDirectory(destDirString + QDir::separator() + newImageDir);
|
||||
qDebug("convert texture working directory: %s",qPrintable(destDirString + QDir::separator() + newImageDir));
|
||||
QString toRun = aqsisDir + teqserName() + " " + getFileNameFromPath(&textureName,false) +".tiff " + getFileNameFromPath(&textureName,false) + ".tx";
|
||||
QString toRun = aqsisDir + teqserName() + " " + textureName + ".tiff " + textureName + ".tx";
|
||||
qDebug("convert command: %s",qPrintable(toRun));
|
||||
convertTextureProcess.start(toRun);
|
||||
convertTextureProcess.start(toRun);
|
||||
if (!convertTextureProcess.waitForFinished(-1)) { //wait the finish of process
|
||||
QByteArray err = convertTextureProcess.readAllStandardError();
|
||||
this->errorMessage = "Is impossible to convert the texture " + textureName + "\n" + QString(err);
|
||||
|
||||
@ -290,7 +290,7 @@ QString FilterHighQualityRender::parseObject(RibFileStack* files, QString destDi
|
||||
QString deb = "";
|
||||
foreach(QString s,token)
|
||||
deb += "str: " + s + "\n";
|
||||
qDebug(qPrintable(deb));
|
||||
//qDebug(qPrintable(deb));
|
||||
//RISpec3.2 not specify what and how many attributes are there in renderman
|
||||
//"user id" and "displacemetbound" don't be needed (perhaps)
|
||||
if(token[2] == "user" && current->objectId == "")
|
||||
@ -440,7 +440,7 @@ bool FilterHighQualityRender::convertObject(FILE* fout, QString destDir, MeshMod
|
||||
|
||||
//read only the first texture
|
||||
QString textureName = textureList->first();
|
||||
fprintf(fout,"Surface \"paintedplastic\" \"Kd\" 1.0 \"Ks\" 0.0 \"texturename\" [\"%s.tx\"]\n", qPrintable(getFileNameFromPath(&textureName,false)));
|
||||
fprintf(fout,"Surface \"paintedplastic\" \"Kd\" 1.0 \"Ks\" 0.0 \"texturename\" [\"%s.tx\"]\n", qPrintable(textureName));
|
||||
}
|
||||
//geometry
|
||||
QString filename = "geometry.rib";
|
||||
@ -478,8 +478,10 @@ int FilterHighQualityRender::makeAnimation(FILE* fout, int numOfFrame,vcg::Matri
|
||||
if(frame == 1)
|
||||
statement += imageName;
|
||||
else {
|
||||
imageName = getFileNameFromPath(&imageName,false);
|
||||
statement += imageName + QString::number(frame) + ".tiff";
|
||||
//imageName = getFileNameFromPath(&imageName,false);
|
||||
//QString temp = path->right(path->size() - 1 - std::max<int>(path->lastIndexOf('\\'),path->lastIndexOf('/')));
|
||||
//return temp.left(temp.lastIndexOf('.'));
|
||||
statement += imageName + QString::number(frame) + ".tiff";
|
||||
}
|
||||
statement += "\" " + token[2] + " " + token[3];
|
||||
for(int i = 4; i<token.size(); i++) {
|
||||
|
||||
@ -8,15 +8,6 @@ QString UtilitiesHQR::getDirFromPath(const QString* path) {
|
||||
return path->left(std::max<int>(path->lastIndexOf('\\'),path->lastIndexOf('/')));
|
||||
}
|
||||
|
||||
QString UtilitiesHQR::getFileNameFromPath(const QString* path, bool type) {
|
||||
//return path->right(path->size() - 1 - path->lastIndexOf(QDir::separator())); //don't work :/
|
||||
QString temp = path->right(path->size() - 1 - std::max<int>(path->lastIndexOf('\\'),path->lastIndexOf('/')));
|
||||
if(type)
|
||||
return temp;
|
||||
else
|
||||
return temp.left(temp.lastIndexOf('.'));
|
||||
}
|
||||
|
||||
//if path contains a space, is wrapped in quotes (e.g. ..\"Program files"\..)
|
||||
QString UtilitiesHQR::quotesPath(const QString* path) {
|
||||
QStringList dirs = path->split(QDir::separator());
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
namespace UtilitiesHQR {
|
||||
QString getDirFromPath(const QString* path);
|
||||
QString getFileNameFromPath(const QString* path, bool type = true);
|
||||
QString quotesPath(const QString* path);
|
||||
bool checkDir(const QString* destDirString, const QString* path);
|
||||
bool copyFiles(const QDir* templateDir, const QDir* destDir, const QStringList* dirs);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user