Merge pull request #4936 from TinyTinni/issue-4871
Fixes PLY reader when the header ends with \r\npull/4935/head^2
commit
e6877cf20f
|
@ -420,7 +420,7 @@ bool PLY::DOM::ParseHeader(IOStreamBuffer<char> &streamBuffer, std::vector<char>
|
||||||
if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
|
if (PLY::Element::ParseElement(streamBuffer, buffer, &out)) {
|
||||||
// add the element to the list of elements
|
// add the element to the list of elements
|
||||||
alElements.push_back(out);
|
alElements.push_back(out);
|
||||||
} else if (TokenMatch(buffer, "end_header", 10)) { //checks for /n ending, if it doesn't end with /r/n
|
} else if (TokenMatch(buffer, "end_header", 10)) {
|
||||||
// we have reached the end of the header
|
// we have reached the end of the header
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -323,7 +323,9 @@ AI_FORCE_INLINE bool IOStreamBuffer<T>::getNextLine(std::vector<T> &buffer) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer[i] = '\n';
|
buffer[i] = '\n';
|
||||||
++m_cachePos;
|
while (m_cachePos < m_cacheSize && (m_cache[m_cachePos] == '\r' || m_cache[m_cachePos] == '\n')) {
|
||||||
|
++m_cachePos;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -125,6 +125,22 @@ TEST_F(utPLYImportExport, importBinaryPLY) {
|
||||||
EXPECT_EQ(12u, scene->mMeshes[0]->mNumFaces);
|
EXPECT_EQ(12u, scene->mMeshes[0]->mNumFaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Tests of a PLY file gets read with \r\n as newlines instead of just \n (i.e. solidwork exported ply files)
|
||||||
|
TEST_F(utPLYImportExport, importBinaryPLYWithRNNewline) {
|
||||||
|
Assimp::Importer importer;
|
||||||
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/cube_binary_header_with_RN_newline.ply", aiProcess_ValidateDataStructure);
|
||||||
|
|
||||||
|
ASSERT_NE(nullptr, scene);
|
||||||
|
ASSERT_NE(nullptr, scene->mMeshes[0]);
|
||||||
|
// This test model is double sided, so 12 faces instead of 6
|
||||||
|
ASSERT_EQ(12u, scene->mMeshes[0]->mNumFaces);
|
||||||
|
// Also check if the indices were parsed correctly
|
||||||
|
ASSERT_EQ(3u, 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) {
|
TEST_F(utPLYImportExport, vertexColorTest) {
|
||||||
Assimp::Importer importer;
|
Assimp::Importer importer;
|
||||||
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);
|
const aiScene *scene = importer.ReadFile(ASSIMP_TEST_MODELS_DIR "/PLY/float-color.ply", aiProcess_ValidateDataStructure);
|
||||||
|
|
Loading…
Reference in New Issue