Corrected wrong managment of malformed stl files

This commit is contained in:
Paolo Cignoni 2018-02-22 19:19:43 +01:00
parent 7b292f511c
commit 5d3fbca6ba

View File

@ -85,15 +85,20 @@ void BaseMeshIOPlugin::initPreOpenParameter(const QString &formatName, const QSt
bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName, MeshModel &m, int& mask, const RichParameterSet &parlst, CallBackPos *cb, QWidget * /*parent*/)
{
bool normalsUpdated = false;
QString errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: %2";
if(!QFile::exists(fileName))
{
errorMessage = errorMsgFormat.arg(fileName, "File does not exist");
return false;
}
// initializing mask
mask = 0;
// initializing progress bar status
if (cb != NULL) (*cb)(0, "Loading...");
QString errorMsgFormat = "Error encountered while loading file:\n\"%1\"\n\nError details: %2";
//string filename = fileName.toUtf8().data();
string filename = QFile::encodeName(fileName).constData();
@ -119,7 +124,7 @@ bool BaseMeshIOPlugin::open(const QString &formatName, const QString &fileName,
{
if (!tri::io::ImporterSTL<CMeshO>::LoadMask(filename.c_str(), mask))
{
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterSTL<CMeshO>::ErrorMsg(tri::io::ImporterSTL<CMeshO>::E_CANTOPEN));
errorMessage = errorMsgFormat.arg(fileName, tri::io::ImporterSTL<CMeshO>::ErrorMsg(tri::io::ImporterSTL<CMeshO>::E_MALFORMED));
return false;
}
m.Enable(mask);