diff --git a/src/common/ml_document/mesh_model.cpp b/src/common/ml_document/mesh_model.cpp index f82e106ec..c10d46e73 100644 --- a/src/common/ml_document/mesh_model.cpp +++ b/src/common/ml_document/mesh_model.cpp @@ -98,18 +98,18 @@ std::list MeshModel::loadTextures( { std::list unloadedTextures; for (std::string& textName : cm.textures){ - if (textName.front() != ':'){ + if (textures.find(textName) == textures.end()){ QImage img(":/img/dummy.png"); QFileInfo finfo(QString::fromStdString(textName)); try { img = meshlab::loadImage(finfo.absoluteFilePath(), log, cb); - textName = ":" + finfo.fileName().toStdString(); + textName = finfo.fileName().toStdString(); } catch (const MLException& e) { try { //could be relative to the meshmodel QFileInfo mfi(fullName()); QString fn2 = mfi.absolutePath() + "/" + finfo.fileName(); img = meshlab::loadImage(fn2, log, cb); - textName = ":" + finfo.fileName().toStdString(); + textName = finfo.fileName().toStdString(); } catch (const MLException& e) { if (log){ log->log( @@ -121,7 +121,7 @@ std::list MeshModel::loadTextures( "Failed loading " + textName + "; using a dummy texture\n"; } unloadedTextures.push_back(textName); - textName = ":dummy.png"; + textName = "dummy.png"; } } textures[textName] = img; @@ -137,7 +137,7 @@ void MeshModel::saveTextures( { for (const std::string& tname : cm.textures){ meshlab::saveImage( - basePath + "/" + QString::fromStdString(tname.substr(1)), + basePath + "/" + QString::fromStdString(tname), textures.at(tname), log, cb); } } @@ -159,8 +159,6 @@ void MeshModel::clearTextures() void MeshModel::addTexture(std::string name, const QImage& txt) { - if (name.front() != ':') - name = ":" + name; cm.textures.push_back(name); textures[name]=txt; } @@ -179,8 +177,6 @@ void MeshModel::changeTextureName( auto mit = textures.find(oldName); auto tit = std::find(cm.textures.begin(), cm.textures.end(), oldName); if (mit != textures.end() && tit != cm.textures.end()){ - if (newName.front() != ':') - newName = ":" + newName; *tit = newName; textures[newName] = mit->second; diff --git a/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp index e6724f3e7..58463b25a 100644 --- a/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp +++ b/src/meshlab/dialogs/save_mesh_attributes_dialog.cpp @@ -71,8 +71,8 @@ SaveMeshAttributesDialog::SaveMeshAttributesDialog( textureNames.reserve(m->cm.textures.size()); for(const std::string& tname : m->cm.textures) { - textureNames.push_back(tname.substr(1)); - QString item(tname.substr(1).c_str()); + textureNames.push_back(tname); + QString item(tname.c_str()); ui->listTextureName->addItem(item); } setMaskCapability(); diff --git a/src/meshlab/mainwindow_RunTime.cpp b/src/meshlab/mainwindow_RunTime.cpp index 347073c79..392ede03f 100644 --- a/src/meshlab/mainwindow_RunTime.cpp +++ b/src/meshlab/mainwindow_RunTime.cpp @@ -2718,6 +2718,9 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo savePar = maskDialog.getNewAdditionalSaveParameters(); std::vector textureNames = maskDialog.getTextureNames(); for (unsigned int i = 0; i < mod->cm.textures.size(); ++i){ + if (textureNames[i].find('.') == std::string::npos){ + textureNames[i] += ".png"; + } mod->changeTextureName(mod->cm.textures[i], textureNames[i]); } if (!saveAllPossibleAttributes) diff --git a/src/meshlabplugins/filter_texture/filter_texture.cpp b/src/meshlabplugins/filter_texture/filter_texture.cpp index ff0a56a46..3e246676a 100644 --- a/src/meshlabplugins/filter_texture/filter_texture.cpp +++ b/src/meshlabplugins/filter_texture/filter_texture.cpp @@ -665,7 +665,7 @@ std::map FilterTexturePlugin::applyFilter( QFileInfo finfo(textName); //Assign texture m.clearTextures(); - m.addTexture(":" + finfo.fileName().toStdString(), textFile); + m.addTexture(finfo.fileName().toStdString(), textFile); } break; @@ -727,9 +727,9 @@ std::map FilterTexturePlugin::applyFilter( else { if (texNum==1) - texFileNames[texInd] = ":" + baseName + ".png"; + texFileNames[texInd] = baseName + ".png"; else - texFileNames[texInd] = ":" + baseName + "_" + QString::number(texInd) + ".png"; + texFileNames[texInd] = baseName + "_" + QString::number(texInd) + ".png"; } trgImgs.push_back(QImage(QSize(textW, textH), QImage::Format_ARGB32)); @@ -960,9 +960,9 @@ void FilterTexturePlugin::transferToTexture( else { if (numTrgTex == 1) - trgTextureFileNames[trgTexInd] = ":" + baseName + ".png"; + trgTextureFileNames[trgTexInd] = baseName + ".png"; else - trgTextureFileNames[trgTexInd] = ":" + baseName + "_" + QString::number(trgTexInd) + ".png"; + trgTextureFileNames[trgTexInd] = baseName + "_" + QString::number(trgTexInd) + ".png"; } trgImgs.push_back(QImage(QSize(textW, textH), QImage::Format_ARGB32));