Fix a bug in importing binary PLY file (#1) (#6060)

* Correct IOStreamBuffer<T>::getNextLine() to prevent skipping too many '\n', which could be part of the BINARY part
* Add a regression test
This commit is contained in:
yurik
2025-05-31 09:05:44 +02:00
committed by GitHub
parent 4ad1d2aa30
commit b97308683b
3 changed files with 25 additions and 1 deletions
+21
View File
@@ -141,6 +141,27 @@ TEST_F(utPLYImportExport, importBinaryPLYWithRNNewline) {
EXPECT_EQ(2u, scene->mMeshes[0]->mFaces[0].mIndices[2]);
}
// Tests of a PLY file gets read with \n as the fist character in the BINARY part
TEST_F(utPLYImportExport, importBinaryPLYWithNewlineInBinary) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_binary_starts_with_nl.ply", aiProcess_ValidateDataStructure);
ASSERT_NE(nullptr, scene);
ASSERT_NE(nullptr, scene->mMeshes[0]);
ASSERT_EQ(8u, scene->mMeshes[0]->mNumVertices);
// Make sure the first binary float was read correctly
ASSERT_FLOAT_EQ(5.967534f, scene->mMeshes[0]->mVertices[0][0]);
ASSERT_FLOAT_EQ(0, scene->mMeshes[0]->mVertices[0][1]);
ASSERT_FLOAT_EQ(0, scene->mMeshes[0]->mVertices[0][2]);
ASSERT_EQ(6u, scene->mMeshes[0]->mNumFaces);
// Also check if the indices were parsed correctly
ASSERT_EQ(4u, scene->mMeshes[0]->mFaces[0].mNumIndices);
EXPECT_EQ(0u, scene->mMeshes[0]->mFaces[0].mIndices[0]);
EXPECT_EQ(1u, scene->mMeshes[0]->mFaces[0].mIndices[1]);
EXPECT_EQ(2u, scene->mMeshes[0]->mFaces[0].mIndices[2]);
}
TEST_F(utPLYImportExport, vertexColorTest) {
Assimp::Importer importer;
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);