diff --git a/Tests/CPP_Bindings/Source/Reader.cpp b/Tests/CPP_Bindings/Source/Reader.cpp index 27f911e31..867f5927e 100644 --- a/Tests/CPP_Bindings/Source/Reader.cpp +++ b/Tests/CPP_Bindings/Source/Reader.cpp @@ -59,6 +59,48 @@ namespace Lib3MF CheckReaderWarnings(Reader::reader3MF, 0); } + TEST_F(Reader, 3MFReadFromFileAndAddMeshObjects) + { + auto reader = model->QueryReader("3mf"); + reader->ReadFromFile(sTestFilesPath + "/Reader/" + "Box.3mf"); + ASSERT_NO_THROW(model->AddMeshObject()); + ASSERT_NO_THROW(model->AddMeshObject()); + ASSERT_NO_THROW(model->AddMeshObject()); + std::vector resourceIDs; + std::vector modelResourceIDs; + std::vector expectedModelResourceIDs({2,3,5,6,7}); + std::vector expectedResourceIDs({2,3,4,5,6}); + auto objectIterator = model->GetObjects(); + while (objectIterator->MoveNext()) { + auto object = objectIterator->GetCurrentObject(); + modelResourceIDs.push_back(object->GetModelResourceID()); + resourceIDs.push_back(object->GetResourceID()); + } + ASSERT_EQ(modelResourceIDs, expectedModelResourceIDs); + ASSERT_EQ(resourceIDs, expectedResourceIDs); + } + + TEST_F(Reader, 3MFReadFromFileAndAddComponents) + { + auto reader = model->QueryReader("3mf"); + reader->ReadFromFile(sTestFilesPath + "/Reader/" + "Globo.3mf"); + ASSERT_NO_THROW(model->AddComponentsObject()); + ASSERT_NO_THROW(model->AddComponentsObject()); + ASSERT_NO_THROW(model->AddComponentsObject()); + std::vector resourceIDs; + std::vector modelResourceIDs; + std::vector expectedModelResourceIDs({2,3,4,5,6,7,8,9}); + std::vector expectedResourceIDs({1,2,3,4,5,6,7,8}); + auto objectIterator = model->GetObjects(); + while (objectIterator->MoveNext()) { + auto object = objectIterator->GetCurrentObject(); + modelResourceIDs.push_back(object->GetModelResourceID()); + resourceIDs.push_back(object->GetResourceID()); + } + ASSERT_EQ(modelResourceIDs, expectedModelResourceIDs); + ASSERT_EQ(resourceIDs, expectedResourceIDs); + } + TEST_F(Reader, STLReadFromFile) { Reader::readerSTL->ReadFromFile(sTestFilesPath + "/Reader/" + "Pyramid.stl"); diff --git a/Tests/TestFiles/Reader/Box.3mf b/Tests/TestFiles/Reader/Box.3mf new file mode 100644 index 000000000..c58861eb9 Binary files /dev/null and b/Tests/TestFiles/Reader/Box.3mf differ diff --git a/Tests/TestFiles/Reader/Globo.3mf b/Tests/TestFiles/Reader/Globo.3mf new file mode 100644 index 000000000..abeda89d2 Binary files /dev/null and b/Tests/TestFiles/Reader/Globo.3mf differ