mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-13 00:07:24 +00:00
better management of io warnings
This commit is contained in:
parent
8cc03faac8
commit
992a2cfe42
@ -39,8 +39,10 @@ void IOPlugin::open(
|
||||
|
||||
void IOPlugin::reportWarning(const QString& warningMessage) const
|
||||
{
|
||||
MeshLabPluginLogger::log(GLLogStream::WARNING, warningMessage.toStdString());
|
||||
warnString += "\n" + warningMessage;
|
||||
if (!warningMessage.isEmpty()){
|
||||
MeshLabPluginLogger::log(GLLogStream::WARNING, warningMessage.toStdString());
|
||||
warnString += "\n" + warningMessage;
|
||||
}
|
||||
}
|
||||
|
||||
void IOPlugin::wrongOpenFormat(const QString& format)
|
||||
|
||||
@ -53,19 +53,12 @@ void loadMesh(const QString& fileName, IOPlugin* ioPlugin, const RichParameterLi
|
||||
throw e;
|
||||
}
|
||||
|
||||
QString warningError = ioPlugin->warningMessageString();
|
||||
|
||||
//saveRecentFileList(fileName);
|
||||
|
||||
auto itmesh = meshList.begin();
|
||||
auto itmask = maskList.begin();
|
||||
for (unsigned int i = 0; i < meshList.size(); ++i){
|
||||
MeshModel* mm = *itmesh;
|
||||
int mask = *itmask;
|
||||
|
||||
//if (!(mm->cm.textures.empty()))
|
||||
// updateTexture(mm->id());
|
||||
|
||||
// In case of polygonal meshes the normal should be updated accordingly
|
||||
if( mask & vcg::tri::io::Mask::IOM_BITPOLYGONAL) {
|
||||
mm->updateDataMask(MeshModel::MM_POLYGONAL); // just to be sure. Hopefully it should be done in the plugin...
|
||||
@ -98,21 +91,12 @@ void loadMesh(const QString& fileName, IOPlugin* ioPlugin, const RichParameterLi
|
||||
int delFaceNum = vcg::tri::Clean<CMeshO>::RemoveDegenerateFace(mm->cm);
|
||||
vcg::tri::Allocator<CMeshO>::CompactEveryVector(mm->cm);
|
||||
if(delVertNum>0 || delFaceNum>0 )
|
||||
ioPlugin->reportWarning(warningError + "\n" + QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum));
|
||||
//QMessageBox::warning(this, "MeshLab Warning", QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum) );
|
||||
|
||||
//mm->cm.Tr = mtr;
|
||||
ioPlugin->reportWarning(QString("Warning mesh contains %1 vertices with NAN coords and %2 degenerated faces.\nCorrected.").arg(delVertNum).arg(delFaceNum));
|
||||
|
||||
//computeRenderingDataOnLoading(mm,isareload, rendOpt);
|
||||
++itmesh;
|
||||
++itmask;
|
||||
}
|
||||
|
||||
//updateLayerDialog();
|
||||
|
||||
|
||||
//meshDoc()->setBusy(false);
|
||||
|
||||
QDir::setCurrent(origDir); // undo the change of directory before leaving
|
||||
}
|
||||
|
||||
|
||||
@ -1751,6 +1751,8 @@ bool MainWindow::openProject(QString fileName)
|
||||
meshlab::loadMeshWithStandardParameters(relativeToProj, *meshDoc(), QCallBack);
|
||||
meshDoc()->mm()->cm.Tr.Import(rm.transformation);
|
||||
computeRenderingDataOnLoading(meshDoc()->mm(), false, nullptr);
|
||||
if (!(meshDoc()->mm()->cm.textures.empty()))
|
||||
updateTexture(meshDoc()->mm()->id());
|
||||
}
|
||||
catch (const MLException& e){
|
||||
QMessageBox::critical(this, "Meshlab Opening Error", e.what());
|
||||
@ -1894,6 +1896,8 @@ bool MainWindow::appendProject(QString fileName)
|
||||
meshlab::loadMeshWithStandardParameters(relativeToProj, *meshDoc(), QCallBack);
|
||||
meshDoc()->mm()->cm.Tr.Import(rm.transformation);
|
||||
computeRenderingDataOnLoading(meshDoc()->mm(), false, nullptr);
|
||||
if (!(meshDoc()->mm()->cm.textures.empty()))
|
||||
updateTexture(meshDoc()->mm()->id());
|
||||
}
|
||||
catch (const MLException& e){
|
||||
QMessageBox::critical(this, "Meshlab Opening Error", e.what());
|
||||
@ -2438,8 +2442,11 @@ bool MainWindow::importMesh(QString fileName)
|
||||
meshlab::loadMesh(fileName, pCurrentIOPlugin, prePar, meshList, masks, QCallBack);
|
||||
saveRecentFileList(fileName);
|
||||
updateLayerDialog();
|
||||
for (MeshModel* mm : meshList)
|
||||
for (MeshModel* mm : meshList) {
|
||||
computeRenderingDataOnLoading(mm, false, nullptr);
|
||||
if (! (mm->cm.textures.empty()))
|
||||
updateTexture(mm->id());
|
||||
}
|
||||
QString warningString = pCurrentIOPlugin->warningMessageString();
|
||||
if (!warningString.isEmpty()){
|
||||
QMessageBox::warning(this, "Meshlab Opening Warning", warningString);
|
||||
@ -2942,17 +2949,19 @@ void MainWindow::updateTexture(int meshid)
|
||||
{
|
||||
QImage img;
|
||||
QFileInfo fi(mymesh->cm.textures[i].c_str());
|
||||
QFileInfo mfi(mymesh->fullName());
|
||||
QString filename = fi.absoluteFilePath();
|
||||
bool res = img.load(filename);
|
||||
sometextfailed = sometextfailed || !res;
|
||||
if(!res)
|
||||
{
|
||||
res = img.load(filename);
|
||||
QString fn2 = mfi.absolutePath() + "/" + fi.fileName();
|
||||
res = img.load(fn2);
|
||||
if(!res)
|
||||
{
|
||||
QString errmsg = QString("Failure of loading texture %1").arg(fi.fileName());
|
||||
meshDoc()->Log.log(GLLogStream::WARNING,qUtf8Printable(errmsg));
|
||||
unexistingtext += "<font color=red>" + filename + "</font><br>";
|
||||
unexistingtext += "<font color=red>" + fi.fileName() + "</font><br>";
|
||||
sometextfailed = sometextfailed || !res;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2966,12 +2975,9 @@ void MainWindow::updateTexture(int meshid)
|
||||
/*PLEASE EXPLAIN ME!*********************************************************************************************************************************************************************************/
|
||||
|
||||
if (!res)
|
||||
res = img.load(":/images/dummy.png");
|
||||
img.load(":/images/dummy.png");
|
||||
GLuint textid = shared->allocateTexturePerMesh(meshid,img,singleMaxTextureSizeMpx);
|
||||
|
||||
if (sometextfailed)
|
||||
QMessageBox::warning(this,"Texture file has not been correctly loaded",unexistingtext);
|
||||
|
||||
for(int tt = 0;tt < mvc->viewerCounter();++tt)
|
||||
{
|
||||
GLArea* ar = mvc->getViewer(tt);
|
||||
|
||||
@ -174,12 +174,14 @@ void ExtraMeshIOPlugin::open(
|
||||
for ( unsigned textureIdx = 0; textureIdx < mm.cm.textures.size(); ++textureIdx)
|
||||
{
|
||||
FILE* pFile = fopen (mm.cm.textures[textureIdx].c_str(), "r");
|
||||
if (pFile == NULL) {
|
||||
if (pFile == nullptr) {
|
||||
missingTextureFilesMsg.append("\n");
|
||||
missingTextureFilesMsg.append(mm.cm.textures[textureIdx].c_str());
|
||||
someTextureNotFound = true;
|
||||
}
|
||||
fclose (pFile);
|
||||
else {
|
||||
fclose (pFile);
|
||||
}
|
||||
}
|
||||
if (someTextureNotFound){
|
||||
reportWarning("Missing texture files: " + missingTextureFilesMsg);
|
||||
@ -216,13 +218,15 @@ void ExtraMeshIOPlugin::open(
|
||||
for ( unsigned textureIdx = 0; textureIdx < m.cm.textures.size(); ++textureIdx)
|
||||
{
|
||||
FILE* pFile = fopen (m.cm.textures[textureIdx].c_str(), "r");
|
||||
if (pFile == NULL)
|
||||
if (pFile == nullptr)
|
||||
{
|
||||
missingTextureFilesMsg.append("\n");
|
||||
missingTextureFilesMsg.append(m.cm.textures[textureIdx].c_str());
|
||||
someTextureNotFound = true;
|
||||
}
|
||||
fclose (pFile);
|
||||
else {
|
||||
fclose (pFile);
|
||||
}
|
||||
}
|
||||
if (someTextureNotFound){
|
||||
reportWarning("Missing texture files: " + missingTextureFilesMsg);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user