3 #include "CesiumGltf/ExtensionModelExtStructuralMetadata.h"
4 #include "CesiumGltf/Model.h"
5 #include "CesiumGltf/PropertyTablePropertyView.h"
6 #include "CesiumGltf/PropertyType.h"
8 #include <glm/common.hpp>
78 const std::optional<std::string>&
name() const noexcept {
79 return _pPropertyTable->
name;
88 int64_t
size() const noexcept {
136 template <
typename T,
bool Normalized = false>
139 if (this->
size() <= 0) {
145 if (!pClassProperty) {
150 return getPropertyViewImpl<T, Normalized>(propertyId, *pClassProperty);
174 template <
typename Callback>
177 if (this->
size() <= 0) {
186 if (!pClassProperty) {
194 PropertyType type = convertStringToPropertyType(pClassProperty->
type);
195 PropertyComponentType componentType = PropertyComponentType::None;
198 convertStringToPropertyComponentType(*pClassProperty->
componentType);
202 if (normalized && !isPropertyComponentTypeInteger(componentType)) {
211 if (pClassProperty->
array) {
213 getArrayPropertyViewImpl<Callback, true>(
218 std::forward<Callback>(callback));
220 getArrayPropertyViewImpl<Callback, false>(
225 std::forward<Callback>(callback));
230 if (type == PropertyType::Scalar) {
232 getScalarPropertyViewImpl<Callback, true>(
236 std::forward<Callback>(callback));
238 getScalarPropertyViewImpl<Callback, false>(
242 std::forward<Callback>(callback));
247 if (isPropertyTypeVecN(type)) {
249 getVecNPropertyViewImpl<Callback, true>(
254 std::forward<Callback>(callback));
256 getVecNPropertyViewImpl<Callback, false>(
261 std::forward<Callback>(callback));
266 if (isPropertyTypeMatN(type)) {
268 getMatNPropertyViewImpl<Callback, true>(
273 std::forward<Callback>(callback));
275 getMatNPropertyViewImpl<Callback, false>(
280 std::forward<Callback>(callback));
285 if (type == PropertyType::String) {
288 getPropertyViewImpl<std::string_view, false>(
294 if (type == PropertyType::Boolean) {
297 getPropertyViewImpl<bool, false>(propertyId, *pClassProperty));
329 for (
const auto& property : this->_pClass->
properties) {
335 template <
typename Callback,
bool Normalized>
336 void getScalarArrayPropertyViewImpl(
337 const std::string& propertyId,
339 PropertyComponentType componentType,
340 Callback&& callback)
const {
341 switch (componentType) {
342 case PropertyComponentType::Int8:
349 case PropertyComponentType::Uint8:
356 case PropertyComponentType::Int16:
363 case PropertyComponentType::Uint16:
370 case PropertyComponentType::Int32:
377 case PropertyComponentType::Uint32:
384 case PropertyComponentType::Int64:
391 case PropertyComponentType::Uint64:
398 case PropertyComponentType::Float32:
405 case PropertyComponentType::Float64:
421 template <
typename Callback, glm::length_t N,
bool Normalized>
422 void getVecNArrayPropertyViewImpl(
423 const std::string& propertyId,
424 const ClassProperty& classProperty,
425 PropertyComponentType componentType,
426 Callback&& callback)
const {
427 switch (componentType) {
428 case PropertyComponentType::Int8:
432 PropertyArrayView<glm::vec<N, int8_t>>,
433 Normalized>(propertyId, classProperty));
435 case PropertyComponentType::Uint8:
439 PropertyArrayView<glm::vec<N, uint8_t>>,
440 Normalized>(propertyId, classProperty));
442 case PropertyComponentType::Int16:
446 PropertyArrayView<glm::vec<N, int16_t>>,
447 Normalized>(propertyId, classProperty));
449 case PropertyComponentType::Uint16:
453 PropertyArrayView<glm::vec<N, uint16_t>>,
454 Normalized>(propertyId, classProperty));
456 case PropertyComponentType::Int32:
460 PropertyArrayView<glm::vec<N, int32_t>>,
461 Normalized>(propertyId, classProperty));
463 case PropertyComponentType::Uint32:
467 PropertyArrayView<glm::vec<N, uint32_t>>,
468 Normalized>(propertyId, classProperty));
470 case PropertyComponentType::Int64:
474 PropertyArrayView<glm::vec<N, int64_t>>,
475 Normalized>(propertyId, classProperty));
477 case PropertyComponentType::Uint64:
481 PropertyArrayView<glm::vec<N, uint64_t>>,
482 Normalized>(propertyId, classProperty));
484 case PropertyComponentType::Float32:
487 getPropertyViewImpl<PropertyArrayView<glm::vec<N, float>>,
false>(
491 case PropertyComponentType::Float64:
494 getPropertyViewImpl<PropertyArrayView<glm::vec<N, double>>,
false>(
501 PropertyTablePropertyView<uint8_t>(
507 template <
typename Callback,
bool Normalized>
508 void getVecNArrayPropertyViewImpl(
509 const std::string& propertyId,
510 const ClassProperty& classProperty,
512 PropertyComponentType componentType,
513 Callback&& callback)
const {
514 glm::length_t N = getDimensionsFromPropertyType(type);
517 getVecNArrayPropertyViewImpl<Callback, 2, Normalized>(
521 std::forward<Callback>(callback));
524 getVecNArrayPropertyViewImpl<Callback, 3, Normalized>(
528 std::forward<Callback>(callback));
531 getVecNArrayPropertyViewImpl<Callback, 4, Normalized>(
535 std::forward<Callback>(callback));
540 PropertyTablePropertyView<uint8_t>(
546 template <
typename Callback, glm::length_t N,
bool Normalized>
547 void getMatNArrayPropertyViewImpl(
548 const std::string& propertyId,
549 const ClassProperty& classProperty,
550 PropertyComponentType componentType,
551 Callback&& callback)
const {
552 switch (componentType) {
553 case PropertyComponentType::Int8:
557 PropertyArrayView<glm::mat<N, N, int8_t>>,
558 Normalized>(propertyId, classProperty));
560 case PropertyComponentType::Uint8:
564 PropertyArrayView<glm::mat<N, N, uint8_t>>,
565 Normalized>(propertyId, classProperty));
567 case PropertyComponentType::Int16:
571 PropertyArrayView<glm::mat<N, N, int16_t>>,
572 Normalized>(propertyId, classProperty));
574 case PropertyComponentType::Uint16:
578 PropertyArrayView<glm::mat<N, N, uint16_t>>,
579 Normalized>(propertyId, classProperty));
581 case PropertyComponentType::Int32:
585 PropertyArrayView<glm::mat<N, N, int32_t>>,
586 Normalized>(propertyId, classProperty));
588 case PropertyComponentType::Uint32:
592 PropertyArrayView<glm::mat<N, N, uint32_t>>,
593 Normalized>(propertyId, classProperty));
595 case PropertyComponentType::Int64:
599 PropertyArrayView<glm::mat<N, N, int64_t>>,
600 Normalized>(propertyId, classProperty));
602 case PropertyComponentType::Uint64:
606 PropertyArrayView<glm::mat<N, N, uint64_t>>,
607 Normalized>(propertyId, classProperty));
609 case PropertyComponentType::Float32:
612 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, float>>,
false>(
616 case PropertyComponentType::Float64:
619 getPropertyViewImpl<PropertyArrayView<glm::mat<N, N, double>>,
false>(
626 PropertyTablePropertyView<uint8_t>(
632 template <
typename Callback,
bool Normalized>
633 void getMatNArrayPropertyViewImpl(
634 const std::string& propertyId,
635 const ClassProperty& classProperty,
637 PropertyComponentType componentType,
638 Callback&& callback)
const {
639 const glm::length_t N = getDimensionsFromPropertyType(type);
642 getMatNArrayPropertyViewImpl<Callback, 2, Normalized>(
646 std::forward<Callback>(callback));
649 getMatNArrayPropertyViewImpl<Callback, 3, Normalized>(
653 std::forward<Callback>(callback));
656 getMatNArrayPropertyViewImpl<Callback, 4, Normalized>(
660 std::forward<Callback>(callback));
665 PropertyTablePropertyView<uint8_t>(
671 template <
typename Callback,
bool Normalized>
672 void getArrayPropertyViewImpl(
673 const std::string& propertyId,
674 const ClassProperty& classProperty,
676 PropertyComponentType componentType,
677 Callback&& callback)
const {
678 if (type == PropertyType::Scalar) {
679 getScalarArrayPropertyViewImpl<Callback, Normalized>(
683 std::forward<Callback>(callback));
684 }
else if (isPropertyTypeVecN(type)) {
685 getVecNArrayPropertyViewImpl<Callback, Normalized>(
690 std::forward<Callback>(callback));
691 }
else if (isPropertyTypeMatN(type)) {
692 getMatNArrayPropertyViewImpl<Callback, Normalized>(
697 std::forward<Callback>(callback));
698 }
else if (type == PropertyType::Boolean) {
701 getPropertyViewImpl<PropertyArrayView<bool>,
false>(
705 }
else if (type == PropertyType::String) {
708 getPropertyViewImpl<PropertyArrayView<std::string_view>,
false>(
714 PropertyTablePropertyView<uint8_t>(
719 template <
typename Callback, glm::length_t N,
bool Normalized>
720 void getVecNPropertyViewImpl(
721 const std::string& propertyId,
722 const ClassProperty& classProperty,
723 PropertyComponentType componentType,
724 Callback&& callback)
const {
726 switch (componentType) {
727 case PropertyComponentType::Int8:
730 getPropertyViewImpl<glm::vec<N, int8_t>, Normalized>(
734 case PropertyComponentType::Uint8:
737 getPropertyViewImpl<glm::vec<N, uint8_t>, Normalized>(
741 case PropertyComponentType::Int16:
744 getPropertyViewImpl<glm::vec<N, int16_t>, Normalized>(
748 case PropertyComponentType::Uint16:
751 getPropertyViewImpl<glm::vec<N, uint16_t>, Normalized>(
755 case PropertyComponentType::Int32:
758 getPropertyViewImpl<glm::vec<N, int32_t>, Normalized>(
762 case PropertyComponentType::Uint32:
765 getPropertyViewImpl<glm::vec<N, uint32_t>, Normalized>(
769 case PropertyComponentType::Int64:
772 getPropertyViewImpl<glm::vec<N, int64_t>, Normalized>(
776 case PropertyComponentType::Uint64:
779 getPropertyViewImpl<glm::vec<N, uint64_t>, Normalized>(
783 case PropertyComponentType::Float32:
786 getPropertyViewImpl<glm::vec<N, float>,
false>(
790 case PropertyComponentType::Float64:
793 getPropertyViewImpl<glm::vec<N, double>,
false>(
800 PropertyTablePropertyView<uint8_t>(
806 template <
typename Callback,
bool Normalized>
807 void getVecNPropertyViewImpl(
808 const std::string& propertyId,
809 const ClassProperty& classProperty,
811 PropertyComponentType componentType,
812 Callback&& callback)
const {
813 const glm::length_t N = getDimensionsFromPropertyType(type);
816 getVecNPropertyViewImpl<Callback, 2, Normalized>(
820 std::forward<Callback>(callback));
823 getVecNPropertyViewImpl<Callback, 3, Normalized>(
827 std::forward<Callback>(callback));
830 getVecNPropertyViewImpl<Callback, 4, Normalized>(
834 std::forward<Callback>(callback));
839 PropertyTablePropertyView<uint8_t>(
845 template <
typename Callback, glm::length_t N,
bool Normalized>
846 void getMatNPropertyViewImpl(
847 const std::string& propertyId,
848 const ClassProperty& classProperty,
849 PropertyComponentType componentType,
850 Callback&& callback)
const {
851 switch (componentType) {
852 case PropertyComponentType::Int8:
855 getPropertyViewImpl<glm::mat<N, N, int8_t>, Normalized>(
859 case PropertyComponentType::Uint8:
862 getPropertyViewImpl<glm::mat<N, N, uint8_t>, Normalized>(
866 case PropertyComponentType::Int16:
869 getPropertyViewImpl<glm::mat<N, N, int16_t>, Normalized>(
873 case PropertyComponentType::Uint16:
876 getPropertyViewImpl<glm::mat<N, N, uint16_t>, Normalized>(
880 case PropertyComponentType::Int32:
883 getPropertyViewImpl<glm::mat<N, N, int32_t>, Normalized>(
887 case PropertyComponentType::Uint32:
890 getPropertyViewImpl<glm::mat<N, N, uint32_t>, Normalized>(
894 case PropertyComponentType::Int64:
897 getPropertyViewImpl<glm::mat<N, N, int64_t>, Normalized>(
901 case PropertyComponentType::Uint64:
904 getPropertyViewImpl<glm::mat<N, N, uint64_t>, Normalized>(
908 case PropertyComponentType::Float32:
911 getPropertyViewImpl<glm::mat<N, N, float>,
false>(
915 case PropertyComponentType::Float64:
918 getPropertyViewImpl<glm::mat<N, N, double>,
false>(
925 PropertyTablePropertyView<uint8_t>(
931 template <
typename Callback,
bool Normalized>
932 void getMatNPropertyViewImpl(
933 const std::string& propertyId,
934 const ClassProperty& classProperty,
936 PropertyComponentType componentType,
937 Callback&& callback)
const {
938 glm::length_t N = getDimensionsFromPropertyType(type);
941 getMatNPropertyViewImpl<Callback, 2, Normalized>(
945 std::forward<Callback>(callback));
948 getMatNPropertyViewImpl<Callback, 3, Normalized>(
952 std::forward<Callback>(callback));
955 getMatNPropertyViewImpl<Callback, 4, Normalized>(
959 std::forward<Callback>(callback));
964 PropertyTablePropertyView<uint8_t>(
970 template <
typename Callback,
bool Normalized>
971 void getScalarPropertyViewImpl(
972 const std::string& propertyId,
973 const ClassProperty& classProperty,
974 PropertyComponentType componentType,
975 Callback&& callback)
const {
976 switch (componentType) {
977 case PropertyComponentType::Int8:
980 getPropertyViewImpl<int8_t, Normalized>(propertyId, classProperty));
982 case PropertyComponentType::Uint8:
985 getPropertyViewImpl<uint8_t, Normalized>(propertyId, classProperty));
987 case PropertyComponentType::Int16:
990 getPropertyViewImpl<int16_t, Normalized>(propertyId, classProperty));
992 case PropertyComponentType::Uint16:
995 getPropertyViewImpl<uint16_t, Normalized>(propertyId, classProperty));
997 case PropertyComponentType::Int32:
1000 getPropertyViewImpl<int32_t, Normalized>(propertyId, classProperty));
1002 case PropertyComponentType::Uint32:
1005 getPropertyViewImpl<uint32_t, Normalized>(propertyId, classProperty));
1007 case PropertyComponentType::Int64:
1010 getPropertyViewImpl<int64_t, Normalized>(propertyId, classProperty));
1012 case PropertyComponentType::Uint64:
1015 getPropertyViewImpl<uint64_t, Normalized>(propertyId, classProperty));
1017 case PropertyComponentType::Float32:
1020 getPropertyViewImpl<float, false>(propertyId, classProperty));
1022 case PropertyComponentType::Float64:
1025 getPropertyViewImpl<double, false>(propertyId, classProperty));
1030 PropertyTablePropertyView<uint8_t>(
1036 template <
typename T,
bool Normalized>
1037 PropertyTablePropertyView<T, Normalized> getPropertyViewImpl(
1038 const std::string& propertyId,
1039 const ClassProperty& classProperty)
const {
1040 auto propertyTablePropertyIter =
1041 _pPropertyTable->
properties.find(propertyId);
1042 if (propertyTablePropertyIter == _pPropertyTable->
properties.end()) {
1043 if (!classProperty.required && classProperty.defaultProperty) {
1047 return PropertyTablePropertyView<T, Normalized>(
1049 _pPropertyTable->
count);
1053 return PropertyTablePropertyView<T, Normalized>(
1057 const PropertyTableProperty& propertyTableProperty =
1058 propertyTablePropertyIter->second;
1060 if constexpr (IsMetadataNumeric<T>::value || IsMetadataBoolean<T>::value) {
1061 return getNumericOrBooleanPropertyValues<T, Normalized>(
1063 propertyTableProperty);
1066 if constexpr (IsMetadataString<T>::value) {
1067 return getStringPropertyValues(classProperty, propertyTableProperty);
1070 if constexpr (IsMetadataBooleanArray<T>::value) {
1071 return getBooleanArrayPropertyValues(
1073 propertyTableProperty);
1076 if constexpr (IsMetadataNumericArray<T>::value) {
1077 return getNumericArrayPropertyValues<
1078 typename MetadataArrayType<T>::type,
1079 Normalized>(classProperty, propertyTableProperty);
1082 if constexpr (IsMetadataStringArray<T>::value) {
1083 return getStringArrayPropertyValues(classProperty, propertyTableProperty);
1087 template <
typename T,
bool Normalized>
1088 PropertyTablePropertyView<T, Normalized> getNumericOrBooleanPropertyValues(
1089 const ClassProperty& classProperty,
1090 const PropertyTableProperty& propertyTableProperty)
const {
1091 if (classProperty.array) {
1092 return PropertyTablePropertyView<T, Normalized>(
1096 const PropertyType type = convertStringToPropertyType(classProperty.type);
1097 if (TypeToPropertyType<T>::value != type) {
1098 return PropertyTablePropertyView<T, Normalized>(
1101 const PropertyComponentType componentType =
1102 convertStringToPropertyComponentType(
1103 classProperty.componentType.value_or(
""));
1104 if (TypeToPropertyType<T>::component != componentType) {
1105 return PropertyTablePropertyView<T, Normalized>(
1109 if (classProperty.normalized != Normalized) {
1110 return PropertyTablePropertyView<T, Normalized>(
1114 gsl::span<const std::byte> values;
1115 const auto status = getBufferSafe(propertyTableProperty.values, values);
1117 return PropertyTablePropertyView<T, Normalized>(
status);
1120 if (values.size() %
sizeof(T) != 0) {
1121 return PropertyTablePropertyView<T, Normalized>(
1122 PropertyTablePropertyViewStatus::
1123 ErrorBufferViewSizeNotDivisibleByTypeSize);
1126 size_t maxRequiredBytes = 0;
1127 if (IsMetadataBoolean<T>::value) {
1128 maxRequiredBytes =
static_cast<size_t>(
1129 glm::ceil(
static_cast<double>(_pPropertyTable->
count) / 8.0));
1131 maxRequiredBytes = _pPropertyTable->
count *
sizeof(T);
1134 if (values.size() < maxRequiredBytes) {
1135 return PropertyTablePropertyView<T, Normalized>(
1136 PropertyTablePropertyViewStatus::
1137 ErrorBufferViewSizeDoesNotMatchPropertyTableCount);
1140 return PropertyTablePropertyView<T, Normalized>(
1141 propertyTableProperty,
1143 _pPropertyTable->
count,
1147 PropertyTablePropertyView<std::string_view> getStringPropertyValues(
1148 const ClassProperty& classProperty,
1149 const PropertyTableProperty& propertyTableProperty)
const;
1151 PropertyTablePropertyView<PropertyArrayView<bool>>
1152 getBooleanArrayPropertyValues(
1153 const ClassProperty& classProperty,
1154 const PropertyTableProperty& propertyTableProperty)
const;
1156 template <
typename T,
bool Normalized>
1157 PropertyTablePropertyView<PropertyArrayView<T>, Normalized>
1158 getNumericArrayPropertyValues(
1159 const ClassProperty& classProperty,
1160 const PropertyTableProperty& propertyTableProperty)
const {
1161 if (!classProperty.array) {
1162 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1166 const PropertyType type = convertStringToPropertyType(classProperty.type);
1167 if (TypeToPropertyType<T>::value != type) {
1168 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1172 const PropertyComponentType componentType =
1173 convertStringToPropertyComponentType(
1174 classProperty.componentType.value_or(
""));
1175 if (TypeToPropertyType<T>::component != componentType) {
1176 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1180 if (classProperty.normalized != Normalized) {
1181 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1185 gsl::span<const std::byte> values;
1186 auto status = getBufferSafe(propertyTableProperty.values, values);
1188 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1192 if (values.size() %
sizeof(T) != 0) {
1193 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1198 const int64_t fixedLengthArrayCount = classProperty.count.value_or(0);
1199 if (fixedLengthArrayCount > 0 && propertyTableProperty.arrayOffsets >= 0) {
1200 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1205 if (fixedLengthArrayCount <= 0 && propertyTableProperty.arrayOffsets < 0) {
1206 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1212 if (fixedLengthArrayCount > 0) {
1213 size_t maxRequiredBytes = maxRequiredBytes =
static_cast<size_t>(
1214 _pPropertyTable->
count * fixedLengthArrayCount *
sizeof(T));
1216 if (values.size() < maxRequiredBytes) {
1217 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1222 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1223 propertyTableProperty,
1225 _pPropertyTable->
count,
1230 const PropertyComponentType arrayOffsetType =
1231 convertArrayOffsetTypeStringToPropertyComponentType(
1232 propertyTableProperty.arrayOffsetType);
1233 if (arrayOffsetType == PropertyComponentType::None) {
1234 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1238 constexpr
bool checkBitsSize =
false;
1239 gsl::span<const std::byte> arrayOffsets;
1240 status = getArrayOffsetsBufferSafe(
1241 propertyTableProperty.arrayOffsets,
1244 static_cast<size_t>(_pPropertyTable->
count),
1248 return PropertyTablePropertyView<PropertyArrayView<T>, Normalized>(
1252 if constexpr (Normalized) {
1253 return PropertyTablePropertyView<PropertyArrayView<T>,
true>(
1254 propertyTableProperty,
1256 _pPropertyTable->
count,
1261 return PropertyTablePropertyView<PropertyArrayView<T>,
false>(
1262 propertyTableProperty,
1264 _pPropertyTable->
count,
1267 gsl::span<const std::byte>(),
1269 PropertyComponentType::None);
1273 PropertyTablePropertyView<PropertyArrayView<std::string_view>>
1274 getStringArrayPropertyValues(
1275 const ClassProperty& classProperty,
1276 const PropertyTableProperty& propertyTableProperty)
const;
1278 PropertyViewStatusType getBufferSafe(
1280 gsl::span<const std::byte>& buffer)
const noexcept;
1282 PropertyViewStatusType getArrayOffsetsBufferSafe(
1283 int32_t arrayOffsetsBufferView,
1284 PropertyComponentType arrayOffsetType,
1285 size_t valuesBufferSize,
1286 size_t propertyTableCount,
1288 gsl::span<const std::byte>& arrayOffsetsBuffer)
const noexcept;
1290 PropertyViewStatusType getStringOffsetsBufferSafe(
1291 int32_t stringOffsetsBufferView,
1292 PropertyComponentType stringOffsetType,
1293 size_t valuesBufferSize,
1294 size_t propertyTableCount,
1295 gsl::span<const std::byte>& stringOffsetsBuffer)
const noexcept;
1297 const Model* _pModel;
1298 const PropertyTable* _pPropertyTable;
1299 const Class* _pClass;
A view on an array element of a PropertyTableProperty or PropertyTextureProperty.
static const PropertyViewStatusType ErrorBufferViewSizeDoesNotMatchPropertyTableCount
This property view has an invalid buffer view; its length does not match the size of the property tab...
static const PropertyViewStatusType ErrorArrayCountAndOffsetBufferCoexist
This array property view has both a fixed length and an offset buffer view defined.
static const PropertyViewStatusType ErrorArrayCountAndOffsetBufferDontExist
This array property view has neither a fixed length nor an offset buffer view defined.
static const PropertyViewStatusType ErrorInvalidPropertyTable
This property view was initialized from an invalid PropertyTable.
static const PropertyViewStatusType ErrorInvalidArrayOffsetType
This property view has an unknown array offset type.
static const PropertyViewStatusType ErrorBufferViewSizeNotDivisibleByTypeSize
This property view has an invalid buffer view; its length is not a multiple of the size of its type /...
A view on the data of the PropertyTableProperty that is created by a PropertyTableView.
Utility to retrieve the data of PropertyTable.
PropertyTableViewStatus status() const noexcept
Gets the status of this property table view.
void getPropertyView(const std::string &propertyId, Callback &&callback) const
Gets a PropertyTablePropertyView through a callback that accepts a property id and a PropertyTablePro...
int64_t size() const noexcept
Get the number of elements in this PropertyTableView. If the view is valid, this returns PropertyTabl...
const ClassProperty * getClassProperty(const std::string &propertyId) const
Finds the ClassProperty that describes the type information of the property with the specified id.
void forEachProperty(Callback &&callback) const
Iterates over each property in the PropertyTable with a callback that accepts a property id and a Pro...
const std::optional< std::string > & name() const noexcept
Gets the name of the property table being viewed. Returns std::nullopt if no name was specified.
PropertyTableView(const Model &model, const PropertyTable &propertyTable)
Creates an instance of PropertyTableView.
PropertyTablePropertyView< T, Normalized > getPropertyView(const std::string &propertyId) const
Gets a PropertyTablePropertyView that views the data of a property stored in the PropertyTable.
const Class * getClass() const noexcept
Gets the Class that this property table conforms to.
static const PropertyViewStatusType ErrorTypeMismatch
This property view's type does not match what is specified in ClassProperty::type.
static const PropertyViewStatusType Valid
This property view is valid and ready to use.
static const PropertyViewStatusType ErrorNonexistentProperty
This property view is trying to view a property that does not exist.
static const PropertyViewStatusType ErrorInvalidNormalization
This property says it is normalized, but it does not have an integer component type.
static const PropertyViewStatusType ErrorArrayTypeMismatch
This property view differs from what is specified in ClassProperty::array.
static const PropertyViewStatusType ErrorNormalizationMismatch
This property view's normalization differs from what is specified in ClassProperty::normalized.
static const PropertyViewStatusType ErrorComponentTypeMismatch
This property view's component type does not match what is specified in ClassProperty::componentType.
Classes for working with glTF models.
PropertyTableViewStatus
Indicates the status of a property table view.
@ Valid
This property table view is valid and ready to use.
@ ErrorClassNotFound
The property table's specified class could not be found in the extension.
@ ErrorMissingMetadataExtension
The property table view's model does not contain an EXT_structural_metadata extension.
@ ErrorMissingSchema
The property table view's model does not have a schema in its EXT_structural_metadata extension.
bool normalized
Specifies whether integer values are normalized. Only applicable to SCALAR, VECN, and MATN types with...
std::optional< std::string > componentType
The datatype of the element's components. Only applicable to SCALAR, VECN, and MATN types.
bool array
Whether the property is an array. When count is defined the property is a fixed-length array....
std::string type
The element type.
A class containing a set of properties.
std::unordered_map< std::string, CesiumGltf::ClassProperty > properties
A dictionary, where each key is a property ID and each value is an object defining the property....
The root object for a glTF asset.
Properties conforming to a class, organized as property values stored in binary columnar arrays.
std::unordered_map< std::string, CesiumGltf::PropertyTableProperty > properties
A dictionary, where each key corresponds to a property ID in the class' properties dictionary and eac...
std::optional< std::string > name
The name of the property table, e.g. for display purposes.
int64_t count
The number of elements in each property array.