not using ":" before texture name

This commit is contained in:
alemuntoni 2021-06-02 18:00:31 +02:00
parent 1a0fc3bb49
commit cba69a936e
4 changed files with 15 additions and 16 deletions

View File

@ -98,18 +98,18 @@ std::list<std::string> MeshModel::loadTextures(
{
std::list<std::string> 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<std::string> 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;

View File

@ -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();

View File

@ -2718,6 +2718,9 @@ bool MainWindow::exportMesh(QString fileName,MeshModel* mod,const bool saveAllPo
savePar = maskDialog.getNewAdditionalSaveParameters();
std::vector<std::string> 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)

View File

@ -665,7 +665,7 @@ std::map<std::string, QVariant> 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<std::string, QVariant> 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));