Minor bugfix to the PLY loader
git-svn-id: https://assimp.svn.sourceforge.net/svnroot/assimp/trunk@79 67173fc5-114c-0410-ac8e-9d2fd5bffc1fpull/1/head
parent
e009d43e3f
commit
b4c826b904
|
@ -104,7 +104,7 @@ void PLYImporter::InternReadFile(
|
||||||
size_t fileSize = file->FileSize();
|
size_t fileSize = file->FileSize();
|
||||||
if( fileSize < 10)
|
if( fileSize < 10)
|
||||||
{
|
{
|
||||||
throw new ImportErrorException( ".ply File is too small.");
|
throw new ImportErrorException( "PLY File is too small.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate storage and copy the contents of the file to a memory buffer
|
// allocate storage and copy the contents of the file to a memory buffer
|
||||||
|
@ -121,6 +121,7 @@ void PLYImporter::InternReadFile(
|
||||||
this->mBuffer[2] != 'Y' && this->mBuffer[2] != 'y')
|
this->mBuffer[2] != 'Y' && this->mBuffer[2] != 'y')
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Magic number \'ply\' is no there");
|
throw new ImportErrorException( "Invalid .ply file: Magic number \'ply\' is no there");
|
||||||
}
|
}
|
||||||
char* szMe = (char*)&this->mBuffer[3];
|
char* szMe = (char*)&this->mBuffer[3];
|
||||||
|
@ -138,6 +139,7 @@ void PLYImporter::InternReadFile(
|
||||||
if(!PLY::DOM::ParseInstance(szMe,&sPlyDom))
|
if(!PLY::DOM::ParseInstance(szMe,&sPlyDom))
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#1)");
|
throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#1)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,18 +161,21 @@ void PLYImporter::InternReadFile(
|
||||||
if(!PLY::DOM::ParseInstanceBinary(szMe,&sPlyDom,bIsBE))
|
if(!PLY::DOM::ParseInstanceBinary(szMe,&sPlyDom,bIsBE))
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#2)");
|
throw new ImportErrorException( "Invalid .ply file: Unable to build DOM (#2)");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Unknown file format");
|
throw new ImportErrorException( "Invalid .ply file: Unknown file format");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Missing format specification");
|
throw new ImportErrorException( "Invalid .ply file: Missing format specification");
|
||||||
}
|
}
|
||||||
this->pcDOM = &sPlyDom;
|
this->pcDOM = &sPlyDom;
|
||||||
|
@ -181,7 +186,10 @@ void PLYImporter::InternReadFile(
|
||||||
|
|
||||||
if (avPositions.empty())
|
if (avPositions.empty())
|
||||||
{
|
{
|
||||||
throw new ImportErrorException( "Invalid .ply file: No vertices found");
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
|
throw new ImportErrorException( "Invalid .ply file: No vertices found. "
|
||||||
|
"Unable to interpret the data format of the PLY file");
|
||||||
}
|
}
|
||||||
|
|
||||||
// now load a list of normals.
|
// now load a list of normals.
|
||||||
|
@ -199,6 +207,7 @@ void PLYImporter::InternReadFile(
|
||||||
if (avPositions.size() < 3)
|
if (avPositions.size() < 3)
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Not enough vertices to build "
|
throw new ImportErrorException( "Invalid .ply file: Not enough vertices to build "
|
||||||
"a face list. ");
|
"a face list. ");
|
||||||
}
|
}
|
||||||
|
@ -237,6 +246,7 @@ void PLYImporter::InternReadFile(
|
||||||
if (avMeshes.empty())
|
if (avMeshes.empty())
|
||||||
{
|
{
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;
|
||||||
|
AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
throw new ImportErrorException( "Invalid .ply file: Unable to extract mesh data ");
|
throw new ImportErrorException( "Invalid .ply file: Unable to extract mesh data ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,7 +271,7 @@ void PLYImporter::InternReadFile(
|
||||||
pScene->mRootNode->mMeshes[i] = i;
|
pScene->mRootNode->mMeshes[i] = i;
|
||||||
|
|
||||||
// delete the file buffer
|
// delete the file buffer
|
||||||
delete[] this->mBuffer;
|
delete[] this->mBuffer;AI_DEBUG_INVALIDATE_PTR(this->mBuffer);
|
||||||
|
|
||||||
// DOM is lying on the stack, will be deconstructed automatically
|
// DOM is lying on the stack, will be deconstructed automatically
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue