Skip to content

Commit

Permalink
Unit test for I3dm batchtable conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
timoore committed Jan 1, 2025
1 parent e643bd3 commit 7eea8bd
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions Cesium3DTilesContent/test/TestI3dmToGltfConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

#include <CesiumGltf/AccessorView.h>
#include <CesiumGltf/ExtensionCesiumRTC.h>
#include <CesiumGltf/ExtensionExtInstanceFeatures.h>
#include <CesiumGltf/ExtensionExtMeshGpuInstancing.h>
#include <CesiumGltf/ExtensionModelExtStructuralMetadata.h>

#include <catch2/catch.hpp>
#include <catch2/catch_test_macros.hpp>
Expand Down Expand Up @@ -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<ExtensionExtMeshGpuInstancing>()) {
auto* pInstanceExt = node.getExtension<ExtensionExtInstanceFeatures>();
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<ExtensionModelExtStructuralMetadata>();
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());
}
}

0 comments on commit 7eea8bd

Please sign in to comment.