Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove old metadata implementation files #658

Merged
merged 5 commits into from
Jun 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@
# Change Log

### ? - ?

##### Breaking Changes :mega:

Many classes have been overhauled to support `EXT_mesh_features` and `EXT_structural_metadata`. This includes the following changes:

- Replaced `FeatureIDTextureView` with `FeatureIdTextureView`, which views a `ExtensionExtMeshFeaturesFeatureIdTexture`.
- Replaced `FeatureIDTextureViewStatus` with `FeatureIdTextureViewStatus`.
- Replaced `getChannel` with `getChannels`. This retrieves the channels as a vector of integers, instead of a single integer.
- Renamed `getTextureCoordinateAttributeId` to `getTexCoordSetIndex`.
- Replaced `MetadataFeatureTableView` with `PropertyTableView`, which views a `ExtensionExtStructuralMetadataPropertyTable`.
- Added `PropertyTableViewStatus` to indicate whether or not `PropertyTableView` is valid.
- Renamed `MetadataArrayView` to `PropertyArrayView`.
- Replaced `FeatureTextureView` with `PropertyTextureView`, which views a `ExtensionExtMeshFeaturesPropertyTexture`.
- Replaced `FeatureTextureViewStatus` with `PropertyTextureViewStatus`.
- Replaced `FeatureTexturePropertyView` with `PropertyTexturePropertyView`, which views a `ExtensionExtMeshFeaturesPropertyTextureProperty`.
- Replaced `FeatureTexturePropertyViewStatus` with `PropertyTexturePropertyViewStatus`.
- Refactored the `PropertyType` enum to reflect the values of `type` in an `ExtensionExtStructuralMetadataClassProperty`.
- Added the `PropertyComponentType` enum to reflect the values of `componentType` in an `ExtensionExtStructuralMetadataClassProperty`.

Additionally, views of the data contained by `EXT_feature_metadata` will no longer supported by Cesium Native. The extension will still be parsed, but it will log a warning. Batch tables will also be converted to `EXT_structural_metadata` instead of `EXT_feature_metadata`.

### v0.25.0 - 2023-06-01

##### Additions :tada:
Expand Down
60 changes: 31 additions & 29 deletions Cesium3DTilesSelection/src/BatchTableToGltfStructuralMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
#include <CesiumGltf/ExtensionExtMeshFeatures.h>
#include <CesiumGltf/ExtensionModelExtStructuralMetadata.h>
#include <CesiumGltf/Model.h>
#include <CesiumGltf/StructuralMetadataPropertyType.h>
#include <CesiumGltf/StructuralMetadataPropertyTypeTraits.h>
#include <CesiumGltf/PropertyType.h>
#include <CesiumGltf/PropertyTypeTraits.h>

#include <glm/glm.hpp>
#include <rapidjson/writer.h>
Expand All @@ -19,7 +19,6 @@
#include <unordered_set>

using namespace CesiumGltf;
using namespace CesiumGltf::StructuralMetadata;
using namespace Cesium3DTilesSelection::CesiumImpl;

namespace Cesium3DTilesSelection {
Expand Down Expand Up @@ -121,82 +120,83 @@ struct CompatibleTypes {
// MaskedType or MaskedArrayType, they are considered incompatible with the
// other type.
private:
std::variant<std::monostate, MaskedType, MaskedArrayType> type;
std::variant<std::monostate, MaskedType, MaskedArrayType> _type;

public:
CompatibleTypes() : type(){};
CompatibleTypes() : _type(){};

CompatibleTypes(const MaskedType& maskedType) : type(maskedType){};
CompatibleTypes(const MaskedType& maskedType) : _type(maskedType){};
CompatibleTypes(const MaskedArrayType& maskedArrayType)
: type(maskedArrayType){};
: _type(maskedArrayType){};

/**
* Whether this is exclusively compatible with array types.
*/
bool isExclusivelyArray() const {
return std::holds_alternative<MaskedArrayType>(type);
return std::holds_alternative<MaskedArrayType>(_type);
}

/**
* Marks as incompatible with every type. Fully-incompatible types will be
* treated as strings.
*/
void makeIncompatible() { type = MaskedType(false); }
void makeIncompatible() { _type = MaskedType(false); }

/**
* Merges a MaskedType into this CompatibleTypes.
*/
void operator&=(const MaskedType& inMaskedType) {
if (std::holds_alternative<MaskedType>(type)) {
MaskedType& maskedType = std::get<MaskedType>(type);
if (std::holds_alternative<MaskedType>(_type)) {
MaskedType& maskedType = std::get<MaskedType>(_type);
maskedType &= inMaskedType;
return;
}

if (std::holds_alternative<MaskedArrayType>(type)) {
if (std::holds_alternative<MaskedArrayType>(_type)) {
makeIncompatible();
return;
}

type = inMaskedType;
_type = inMaskedType;
}

/**
* Merges a MaskedArrayType into this CompatibleTypes.
*/
void operator&=(const MaskedArrayType& inArrayType) {
if (std::holds_alternative<MaskedArrayType>(type)) {
MaskedArrayType& arrayType = std::get<MaskedArrayType>(type);
if (std::holds_alternative<MaskedArrayType>(_type)) {
MaskedArrayType& arrayType = std::get<MaskedArrayType>(_type);
arrayType &= inArrayType;
return;
}

if (std::holds_alternative<MaskedType>(type)) {
if (std::holds_alternative<MaskedType>(_type)) {
makeIncompatible();
return;
}

type = inArrayType;
_type = inArrayType;
}

/**
* Merges another CompatibleTypes into this one.
*/
void operator&=(const CompatibleTypes& inCompatibleTypes) {
if (std::holds_alternative<std::monostate>(inCompatibleTypes.type)) {
if (std::holds_alternative<std::monostate>(inCompatibleTypes._type)) {
// The other CompatibleTypes is compatible with everything, so it does not
// change this one.
return;
}

if (std::holds_alternative<MaskedArrayType>(inCompatibleTypes.type)) {
if (std::holds_alternative<MaskedArrayType>(inCompatibleTypes._type)) {
const MaskedArrayType& arrayType =
std::get<MaskedArrayType>(inCompatibleTypes.type);
std::get<MaskedArrayType>(inCompatibleTypes._type);
operator&=(arrayType);
return;
}

const MaskedType& maskedType = std::get<MaskedType>(inCompatibleTypes.type);
const MaskedType& maskedType =
std::get<MaskedType>(inCompatibleTypes._type);
operator&=(maskedType);
}

Expand All @@ -206,11 +206,11 @@ struct CompatibleTypes {
* MaskedType.
*/
MaskedType toMaskedType() const {
if (std::holds_alternative<MaskedType>(type)) {
return std::get<MaskedType>(type);
if (std::holds_alternative<MaskedType>(_type)) {
return std::get<MaskedType>(_type);
}

bool isArray = std::holds_alternative<MaskedArrayType>(type);
bool isArray = std::holds_alternative<MaskedArrayType>(_type);
return MaskedType(!isArray);
}

Expand All @@ -220,11 +220,11 @@ struct CompatibleTypes {
* incompatible MaskedArrayType.
*/
MaskedArrayType toMaskedArrayType() const {
if (std::holds_alternative<MaskedArrayType>(type)) {
return std::get<MaskedArrayType>(type);
if (std::holds_alternative<MaskedArrayType>(_type)) {
return std::get<MaskedArrayType>(_type);
}

bool isNonArray = std::holds_alternative<MaskedType>(type);
bool isNonArray = std::holds_alternative<MaskedType>(_type);
return MaskedArrayType(!isNonArray);
}
};
Expand Down Expand Up @@ -307,7 +307,7 @@ int64_t roundUp(int64_t num, int64_t multiple) noexcept {
}

template <typename T> bool isInRangeForSignedInteger(int64_t value) noexcept {
// this only work if sizeof(T) is smaller than int64_t
// This only works if sizeof(T) is smaller than int64_t
static_assert(
!std::is_same_v<T, uint64_t> && !std::is_same_v<T, float> &&
!std::is_same_v<T, double>);
Expand Down Expand Up @@ -960,7 +960,8 @@ void updateBooleanArrayProperty(
const TValueGetter& propertyValue) {
assert(propertyValue.size() >= propertyTable.count);

classProperty.type = "BOOLEAN";
classProperty.type =
ExtensionExtStructuralMetadataClassProperty::Type::BOOLEAN;
classProperty.array = true;

// Fixed-length array of booleans
Expand Down Expand Up @@ -1494,6 +1495,7 @@ void convertBatchTableToGltfStructuralMetadataExtension(

ExtensionExtStructuralMetadataPropertyTable& propertyTable =
modelExtension.propertyTables.emplace_back();
propertyTable.name = "default";
propertyTable.count = featureCount;
propertyTable.classProperty = "default";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <CesiumAsync/HttpHeaders.h>
#include <CesiumGltf/ExtensionExtMeshFeatures.h>
#include <CesiumGltf/ExtensionModelExtStructuralMetadata.h>
#include <CesiumGltf/StructuralMetadataPropertyTablePropertyView.h>
#include <CesiumGltf/StructuralMetadataPropertyTableView.h>
#include <CesiumGltf/PropertyTablePropertyView.h>
#include <CesiumGltf/PropertyTableView.h>
#include <CesiumUtility/Math.h>

#include <catch2/catch.hpp>
Expand All @@ -18,7 +18,6 @@
#include <set>

using namespace CesiumGltf;
using namespace CesiumGltf::StructuralMetadata;
using namespace Cesium3DTilesSelection;
using namespace CesiumUtility;

Expand Down Expand Up @@ -88,13 +87,13 @@ static void checkArrayProperty(
REQUIRE(view.status() == PropertyTableViewStatus::Valid);
REQUIRE(view.size() == propertyTable.count);

PropertyTablePropertyView<MetadataArrayView<PropertyViewType>> propertyView =
view.getPropertyView<MetadataArrayView<PropertyViewType>>(propertyName);
PropertyTablePropertyView<PropertyArrayView<PropertyViewType>> propertyView =
view.getPropertyView<PropertyArrayView<PropertyViewType>>(propertyName);
REQUIRE(propertyView.status() == PropertyTablePropertyViewStatus::Valid);
REQUIRE(propertyView.size() == propertyTable.count);
REQUIRE(propertyView.size() == static_cast<int64_t>(expectedTotalInstances));
for (size_t i = 0; i < expectedTotalInstances; ++i) {
MetadataArrayView<PropertyViewType> value =
PropertyArrayView<PropertyViewType> value =
propertyView.get(static_cast<int64_t>(i));
if (expectedCount > 0) {
REQUIRE(value.size() == expectedCount);
Expand Down
141 changes: 0 additions & 141 deletions CesiumGltf/include/CesiumGltf/FeatureIDTextureView.h

This file was deleted.

Loading