From 7eea8bdf6907982ea1750740991d56cd2b588961 Mon Sep 17 00:00:00 2001 From: Tim Moore Date: Tue, 31 Dec 2024 20:16:21 +0100 Subject: [PATCH] Unit test for I3dm batchtable conversion --- .../test/TestI3dmToGltfConverter.cpp | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp b/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp index 8fa372a3d..2ef4c2eec 100644 --- a/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp +++ b/Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp @@ -2,7 +2,9 @@ #include #include +#include #include +#include #include #include @@ -81,4 +83,42 @@ TEST_CASE("I3dmToGltfConverter") { REQUIRE(!result.model); CHECK(result.errors.hasErrors()); } + + SECTION("loads an i3dm with metadata") { + std::filesystem::path testFilePath = Cesium3DTilesSelection_TEST_DATA_DIR; + testFilePath = testFilePath / "i3dm" / "InstancedWithBatchTable" / + "instancedWithBatchTable.i3dm"; + + GltfConverterResult result = ConvertTileToGltf::fromI3dm(testFilePath); + + REQUIRE(result.model); + CHECK(result.model->isExtensionUsed( + ExtensionExtMeshGpuInstancing::ExtensionName)); + CHECK(result.model->isExtensionRequired( + ExtensionExtMeshGpuInstancing::ExtensionName)); + REQUIRE(result.model->nodes.size() == 1); + CHECK(result.model->isExtensionUsed( + ExtensionExtInstanceFeatures::ExtensionName)); + for (Node& node : result.model->nodes) { + if (node.getExtension()) { + auto* pInstanceExt = node.getExtension(); + REQUIRE(pInstanceExt); + REQUIRE(pInstanceExt->featureIds.size() == 1); + CHECK(pInstanceExt->featureIds[0].featureCount == 25); + CHECK(!pInstanceExt->featureIds[0].attribute.has_value()); + REQUIRE(pInstanceExt->featureIds[0].propertyTable.has_value()); + CHECK(*pInstanceExt->featureIds[0].propertyTable == 0); + CHECK(!pInstanceExt->featureIds[0].nullFeatureId.has_value()); + CHECK(!pInstanceExt->featureIds[0].label.has_value()); + } + } + auto* pStructuralMetadataExt = + result.model->getExtension(); + REQUIRE(pStructuralMetadataExt); + REQUIRE(pStructuralMetadataExt->propertyTables.size() == 1); + PropertyTable& propertyTable = pStructuralMetadataExt->propertyTables[0]; + CHECK(propertyTable.classProperty == "default"); + auto heightIt = propertyTable.properties.find("Height"); + REQUIRE(heightIt != propertyTable.properties.end()); + } }