cesium-native 0.46.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
PropertyTablePropertyView.h
1#pragma once
2
3#include <CesiumGltf/Enum.h>
4#include <CesiumGltf/PropertyArrayView.h>
5#include <CesiumGltf/PropertyTransformations.h>
6#include <CesiumGltf/PropertyTypeTraits.h>
7#include <CesiumGltf/PropertyView.h>
8#include <CesiumUtility/Assert.h>
9
10#include <cstddef>
11#include <cstdint>
12#include <span>
13#include <string_view>
14
15namespace CesiumGltf {
25public:
31
36
42
48
54
60
66
72
77 static const PropertyViewStatusType
79
84 static const PropertyViewStatusType
86
92 24;
93
99 25;
100
105
110
116
122
127
132};
133
138int64_t getOffsetTypeSize(PropertyComponentType offsetType) noexcept;
139
144template <typename ElementType, bool Normalized = false>
146
161template <typename ElementType>
162class PropertyTablePropertyView<ElementType, false>
163 : public PropertyView<ElementType, false> {
164public:
169 : PropertyView<ElementType, false>(),
170 _values{},
171 _size{0},
172 _arrayOffsets{},
173 _arrayOffsetType{PropertyComponentType::None},
174 _arrayOffsetTypeSize{0},
175 _stringOffsets{},
176 _stringOffsetType{PropertyComponentType::None},
177 _stringOffsetTypeSize{0} {}
178
185 : PropertyView<ElementType, false>(status),
186 _values{},
187 _size{0},
188 _arrayOffsets{},
189 _arrayOffsetType{PropertyComponentType::None},
190 _arrayOffsetTypeSize{0},
191 _stringOffsets{},
192 _stringOffsetType{PropertyComponentType::None},
193 _stringOffsetTypeSize{0} {
194 CESIUM_ASSERT(
196 "An empty property view should not be constructed with a valid status");
197 }
198
208 PropertyTablePropertyView(const ClassProperty& classProperty, int64_t size)
209 : PropertyView<ElementType, false>(classProperty),
210 _values{},
211 _size{0},
212 _arrayOffsets{},
213 _arrayOffsetType{PropertyComponentType::None},
214 _arrayOffsetTypeSize{0},
215 _stringOffsets{},
216 _stringOffsetType{PropertyComponentType::None},
217 _stringOffsetTypeSize{0} {
218 if (this->_status != PropertyTablePropertyViewStatus::Valid) {
219 // Don't override the status / size if something is wrong with the class
220 // property's definition.
221 return;
222 }
223
224 if (!classProperty.defaultProperty) {
225 // This constructor should only be called if the class property *has* a
226 // default value. But in the case that it does not, this property view
227 // becomes invalid.
228 this->_status = PropertyTablePropertyViewStatus::ErrorNonexistentProperty;
229 return;
230 }
231
233 this->_size = size;
234 }
235
246 const PropertyTableProperty& property,
247 const ClassProperty& classProperty,
248 int64_t size,
249 std::span<const std::byte> values) noexcept
251 property,
252 classProperty,
253 nullptr,
254 size,
255 values) {}
256
269 const PropertyTableProperty& property,
270 const ClassProperty& classProperty,
271 const CesiumGltf::Enum* pEnumDefinition,
272 int64_t size,
273 std::span<const std::byte> values) noexcept
274 : PropertyView<ElementType>(classProperty, property, pEnumDefinition),
275 _values{values},
276 _size{
277 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
278 _arrayOffsets{},
279 _arrayOffsetType{PropertyComponentType::None},
280 _arrayOffsetTypeSize{0},
281 _stringOffsets{},
282 _stringOffsetType{PropertyComponentType::None},
283 _stringOffsetTypeSize{0} {}
284
298 const PropertyTableProperty& property,
299 const ClassProperty& classProperty,
300 int64_t size,
301 std::span<const std::byte> values,
302 std::span<const std::byte> arrayOffsets,
303 std::span<const std::byte> stringOffsets,
304 PropertyComponentType arrayOffsetType,
305 PropertyComponentType stringOffsetType) noexcept
307 property,
308 classProperty,
309 nullptr,
310 size,
311 values,
312 arrayOffsets,
313 stringOffsets,
314 arrayOffsetType,
315 stringOffsetType) {}
316
332 const PropertyTableProperty& property,
333 const ClassProperty& classProperty,
334 const CesiumGltf::Enum* pEnumDefinition,
335 int64_t size,
336 std::span<const std::byte> values,
337 std::span<const std::byte> arrayOffsets,
338 std::span<const std::byte> stringOffsets,
339 PropertyComponentType arrayOffsetType,
340 PropertyComponentType stringOffsetType) noexcept
341 : PropertyView<ElementType>(classProperty, property, pEnumDefinition),
342 _values{values},
343 _size{
344 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
345 _arrayOffsets{arrayOffsets},
346 _arrayOffsetType{arrayOffsetType},
347 _arrayOffsetTypeSize{getOffsetTypeSize(arrayOffsetType)},
348 _stringOffsets{stringOffsets},
349 _stringOffsetType{stringOffsetType},
350 _stringOffsetTypeSize{getOffsetTypeSize(stringOffsetType)} {}
351
367 std::optional<PropertyValueViewToCopy<ElementType>>
368 get(int64_t index) const noexcept {
369 if (this->_status ==
371 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
372 CESIUM_ASSERT(index < size() && "index must be less than size");
373
374 return propertyValueViewToCopy(this->defaultValue());
375 }
376
377 ElementType value = getRaw(index);
378
379 if (value == this->noData()) {
380 return propertyValueViewToCopy(this->defaultValue());
381 } else if constexpr (IsMetadataNumeric<ElementType>::value) {
382 return transformValue(value, this->offset(), this->scale());
383 } else if constexpr (IsMetadataNumericArray<ElementType>::value) {
384 return transformArray(value, this->offset(), this->scale());
385 } else {
386 return value;
387 }
388 }
389
400 ElementType getRaw(int64_t index) const noexcept {
401 CESIUM_ASSERT(
403 "Check the status() first to make sure view is valid");
404 CESIUM_ASSERT(
405 size() > 0 &&
406 "Check the size() of the view to make sure it's not empty");
407 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
408 CESIUM_ASSERT(index < size() && "index must be less than size");
409
411 return getNumericValue(index);
412 }
413
415 return getBooleanValue(index);
416 }
417
419 return getStringValue(index);
420 }
421
423 return getNumericArrayValues<
425 }
426
428 return getBooleanArrayValues(index);
429 }
430
432 return getStringArrayValues(index);
433 }
434 }
435
443 int64_t size() const noexcept { return _size; }
444
445private:
446 ElementType getNumericValue(int64_t index) const noexcept {
447 return reinterpret_cast<const ElementType*>(_values.data())[index];
448 }
449
450 bool getBooleanValue(int64_t index) const noexcept {
451 const int64_t byteIndex = index / 8;
452 const int64_t bitIndex = index % 8;
453 const int bitValue =
454 static_cast<int>(_values[static_cast<size_t>(byteIndex)] >> bitIndex) &
455 1;
456 return bitValue == 1;
457 }
458
459 std::string_view getStringValue(int64_t index) const noexcept {
460 const size_t currentOffset = getOffsetFromOffsetsBuffer(
461 static_cast<size_t>(index),
462 _stringOffsets,
463 _stringOffsetType);
464 const size_t nextOffset = getOffsetFromOffsetsBuffer(
465 static_cast<size_t>(index + 1),
466 _stringOffsets,
467 _stringOffsetType);
468 return std::string_view(
469 reinterpret_cast<const char*>(_values.data() + currentOffset),
470 nextOffset - currentOffset);
471 }
472
473 template <typename T>
474 PropertyArrayView<T> getNumericArrayValues(int64_t index) const noexcept {
475 size_t count = static_cast<size_t>(this->arrayCount());
476 // Handle fixed-length arrays
477 if (count > 0) {
478 size_t arraySize = count * sizeof(T);
479 const std::span<const std::byte> values(
480 _values.data() + static_cast<size_t>(index) * arraySize,
481 arraySize);
482 return PropertyArrayView<T>{values};
483 }
484
485 // Handle variable-length arrays. The offsets are interpreted as array
486 // indices, not byte offsets, so they must be multiplied by sizeof(T)
487 const size_t currentOffset = getOffsetFromOffsetsBuffer(
488 static_cast<size_t>(index),
489 _arrayOffsets,
490 _arrayOffsetType) *
491 sizeof(T);
492 const size_t nextOffset = getOffsetFromOffsetsBuffer(
493 static_cast<size_t>(index + 1),
494 _arrayOffsets,
495 _arrayOffsetType) *
496 sizeof(T);
497 const std::span<const std::byte> values(
498 _values.data() + currentOffset,
499 nextOffset - currentOffset);
500 return PropertyArrayView<T>{values};
501 }
502
503 PropertyArrayView<std::string_view>
504 getStringArrayValues(int64_t index) const noexcept {
505 size_t count = static_cast<size_t>(this->arrayCount());
506 // Handle fixed-length arrays
507 if (count > 0) {
508 // Copy the corresponding string offsets to pass to the PropertyArrayView.
509 const size_t arraySize =
510 count * static_cast<size_t>(_stringOffsetTypeSize);
511 const std::span<const std::byte> stringOffsetValues(
512 _stringOffsets.data() + static_cast<size_t>(index) * arraySize,
513 arraySize + static_cast<size_t>(_stringOffsetTypeSize));
514 return PropertyArrayView<std::string_view>(
515 _values,
516 stringOffsetValues,
517 _stringOffsetType,
518 static_cast<int64_t>(count));
519 }
520
521 // Handle variable-length arrays
522 const size_t currentArrayOffset =
523 getOffsetFromOffsetsBuffer(
524 static_cast<size_t>(index),
525 _arrayOffsets,
526 _arrayOffsetType) *
527 static_cast<size_t>(_stringOffsetTypeSize);
528 const size_t nextArrayOffset = getOffsetFromOffsetsBuffer(
529 static_cast<size_t>(index + 1),
530 _arrayOffsets,
531 _arrayOffsetType) *
532 static_cast<size_t>(_stringOffsetTypeSize);
533 const size_t arraySize = nextArrayOffset - currentArrayOffset;
534 const std::span<const std::byte> stringOffsetValues(
535 _stringOffsets.data() + currentArrayOffset,
536 arraySize + static_cast<size_t>(_stringOffsetTypeSize));
537 return PropertyArrayView<std::string_view>(
538 _values,
539 stringOffsetValues,
540 _stringOffsetType,
541 static_cast<int64_t>(arraySize) / _stringOffsetTypeSize);
542 }
543
544 PropertyArrayView<bool> getBooleanArrayValues(int64_t index) const noexcept {
545 size_t count = static_cast<size_t>(this->arrayCount());
546 // Handle fixed-length arrays
547 if (count > 0) {
548 const size_t offsetBits = count * static_cast<size_t>(index);
549 const size_t nextOffsetBits = count * static_cast<size_t>(index + 1);
550 const std::span<const std::byte> buffer(
551 _values.data() + offsetBits / 8,
552 (nextOffsetBits / 8 - offsetBits / 8 + 1));
553 return PropertyArrayView<bool>(
554 buffer,
555 offsetBits % 8,
556 static_cast<int64_t>(count));
557 }
558
559 // Handle variable-length arrays
560 const size_t currentOffset = getOffsetFromOffsetsBuffer(
561 static_cast<size_t>(index),
562 _arrayOffsets,
563 _arrayOffsetType);
564 const size_t nextOffset = getOffsetFromOffsetsBuffer(
565 static_cast<size_t>(index + 1),
566 _arrayOffsets,
567 _arrayOffsetType);
568 const size_t totalBits = nextOffset - currentOffset;
569 const std::span<const std::byte> buffer(
570 _values.data() + currentOffset / 8,
571 (nextOffset / 8 - currentOffset / 8 + 1));
572 return PropertyArrayView<bool>(
573 buffer,
574 currentOffset % 8,
575 static_cast<int64_t>(totalBits));
576 }
577
578 std::span<const std::byte> _values;
579 int64_t _size;
580
581 std::span<const std::byte> _arrayOffsets;
582 PropertyComponentType _arrayOffsetType;
583 int64_t _arrayOffsetTypeSize;
584
585 std::span<const std::byte> _stringOffsets;
586 PropertyComponentType _stringOffsetType;
587 int64_t _stringOffsetTypeSize;
588};
589
604template <typename ElementType>
605class PropertyTablePropertyView<ElementType, true>
606 : public PropertyView<ElementType, true> {
607private:
608 using NormalizedType = typename TypeToNormalizedType<ElementType>::type;
609
610public:
615 : PropertyView<ElementType, true>(),
616 _values{},
617 _size{0},
618 _arrayOffsets{},
619 _arrayOffsetType{PropertyComponentType::None},
620 _arrayOffsetTypeSize{0} {}
621
628 : PropertyView<ElementType, true>(status),
629 _values{},
630 _size{0},
631 _arrayOffsets{},
632 _arrayOffsetType{PropertyComponentType::None},
633 _arrayOffsetTypeSize{0} {
634 CESIUM_ASSERT(
636 "An empty property view should not be constructed with a valid status");
637 }
638
648 PropertyTablePropertyView(const ClassProperty& classProperty, int64_t size)
649 : PropertyView<ElementType, true>(classProperty),
650 _values{},
651 _size{0},
652 _arrayOffsets{},
653 _arrayOffsetType{PropertyComponentType::None},
654 _arrayOffsetTypeSize{0} {
655 if (this->_status != PropertyTablePropertyViewStatus::Valid) {
656 // Don't override the status / size if something is wrong with the class
657 // property's definition.
658 return;
659 }
660
661 if (!classProperty.defaultProperty) {
662 // This constructor should only be called if the class property *has* a
663 // default value. But in the case that it does not, this property view
664 // becomes invalid.
665 this->_status = PropertyTablePropertyViewStatus::ErrorNonexistentProperty;
666 return;
667 }
668
670 this->_size = size;
671 }
672
683 const PropertyTableProperty& property,
684 const ClassProperty& classProperty,
685 int64_t size,
686 std::span<const std::byte> values) noexcept
687 : PropertyView<ElementType, true>(classProperty, property),
688 _values{values},
689 _size{
690 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
691 _arrayOffsets{},
692 _arrayOffsetType{PropertyComponentType::None},
693 _arrayOffsetTypeSize{0} {}
694
707 const PropertyTableProperty& property,
708 const ClassProperty& classProperty,
709 int64_t size,
710 std::span<const std::byte> values,
711 std::span<const std::byte> arrayOffsets,
712 PropertyComponentType arrayOffsetType) noexcept
713 : PropertyView<ElementType, true>(classProperty, property),
714 _values{values},
715 _size{
716 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
717 _arrayOffsets{arrayOffsets},
718 _arrayOffsetType{arrayOffsetType},
719 _arrayOffsetTypeSize{getOffsetTypeSize(arrayOffsetType)} {}
720
736 std::optional<PropertyValueViewToCopy<NormalizedType>>
737 get(int64_t index) const noexcept {
738 if (this->_status ==
740 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
741 CESIUM_ASSERT(index < size() && "index must be less than size");
742
743 return propertyValueViewToCopy(this->defaultValue());
744 }
745
746 ElementType value = getRaw(index);
747 if (this->noData() && value == *(this->noData())) {
748 return propertyValueViewToCopy(this->defaultValue());
749 } else if constexpr (IsMetadataScalar<ElementType>::value) {
752 this->offset(),
753 this->scale());
754 } else if constexpr (IsMetadataVecN<ElementType>::value) {
755 constexpr glm::length_t N = ElementType::length();
756 using T = typename ElementType::value_type;
757 using NormalizedT = typename NormalizedType::value_type;
759 normalize<N, T>(value),
760 this->offset(),
761 this->scale());
762 } else if constexpr (IsMetadataMatN<ElementType>::value) {
763 constexpr glm::length_t N = ElementType::length();
764 using T = typename ElementType::value_type;
765 using NormalizedT = typename NormalizedType::value_type;
767 normalize<N, T>(value),
768 this->offset(),
769 this->scale());
770 } else if constexpr (IsMetadataArray<ElementType>::value) {
771 using ArrayElementType = typename MetadataArrayType<ElementType>::type;
774 value,
775 this->offset(),
776 this->scale());
777 } else if constexpr (IsMetadataVecN<ArrayElementType>::value) {
778 constexpr glm::length_t N = ArrayElementType::length();
779 using T = typename ArrayElementType::value_type;
781 value,
782 this->offset(),
783 this->scale());
784 } else if constexpr (IsMetadataMatN<ArrayElementType>::value) {
785 constexpr glm::length_t N = ArrayElementType::length();
786 using T = typename ArrayElementType::value_type;
788 value,
789 this->offset(),
790 this->scale());
791 }
792 }
793 }
794
805 ElementType getRaw(int64_t index) const noexcept {
806 CESIUM_ASSERT(
808 "Check the status() first to make sure view is valid");
809 CESIUM_ASSERT(
810 size() > 0 &&
811 "Check the size() of the view to make sure it's not empty");
812 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
813 CESIUM_ASSERT(index < size() && "index must be less than size");
814
816 return getValue(index);
817 }
818
820 return getArrayValues<typename MetadataArrayType<ElementType>::type>(
821 index);
822 }
823 }
824
832 int64_t size() const noexcept {
833 return this->_status == PropertyTablePropertyViewStatus::Valid ? _size : 0;
834 }
835
836private:
837 ElementType getValue(int64_t index) const noexcept {
838 return reinterpret_cast<const ElementType*>(_values.data())[index];
839 }
840
841 template <typename T>
842 PropertyArrayView<T> getArrayValues(int64_t index) const noexcept {
843 size_t count = static_cast<size_t>(this->arrayCount());
844 // Handle fixed-length arrays
845 if (count > 0) {
846 size_t arraySize = count * sizeof(T);
847 const std::span<const std::byte> values(
848 _values.data() + static_cast<size_t>(index) * arraySize,
849 arraySize);
850 return PropertyArrayView<T>{values};
851 }
852
853 // Handle variable-length arrays. The offsets are interpreted as array
854 // indices, not byte offsets, so they must be multiplied by sizeof(T)
855 const size_t currentOffset = getOffsetFromOffsetsBuffer(
856 static_cast<size_t>(index),
857 _arrayOffsets,
858 _arrayOffsetType) *
859 sizeof(T);
860 const size_t nextOffset = getOffsetFromOffsetsBuffer(
861 static_cast<size_t>(index + 1),
862 _arrayOffsets,
863 _arrayOffsetType) *
864 sizeof(T);
865 const std::span<const std::byte> values(
866 _values.data() + currentOffset,
867 nextOffset - currentOffset);
868 return PropertyArrayView<T>{values};
869 }
870
871 std::span<const std::byte> _values;
872 int64_t _size;
873
874 std::span<const std::byte> _arrayOffsets;
875 PropertyComponentType _arrayOffsetType;
876 int64_t _arrayOffsetTypeSize;
877};
878
879} // namespace CesiumGltf
Indicates the status of a property table property view.
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 ErrorInvalidArrayOffsetBufferView
This array property view does not have a valid array offset buffer view index.
static const PropertyViewStatusType ErrorBufferViewOutOfBounds
This property view has a buffer view that points outside the bounds of its target buffer.
static const PropertyViewStatusType ErrorArrayCountAndOffsetBufferCoexist
This array property view has both a fixed length and an offset buffer view defined.
static const PropertyViewStatusType ErrorInvalidValueBufferView
This property view does not have a valid value buffer view index.
static const PropertyViewStatusType ErrorInvalidStringOffsetBuffer
This property view has a valid string offset buffer view, but the buffer view specifies an invalid bu...
static const PropertyViewStatusType ErrorInvalidStringOffsetType
This property view has an unknown string offset type.
static const PropertyViewStatusType ErrorArrayCountAndOffsetBufferDontExist
This array property view has neither a fixed length nor an offset buffer view defined.
static const PropertyViewStatusType ErrorArrayOffsetsNotSorted
This property view's array offset values are not sorted in ascending order.
static const PropertyViewStatusType ErrorInvalidArrayOffsetBuffer
This property view has a valid array string buffer view, but the buffer view specifies an invalid buf...
static const PropertyViewStatusType ErrorArrayOffsetOutOfBounds
This property view has an array offset that is out of bounds.
static const PropertyViewStatusType ErrorInvalidPropertyTable
This property view was initialized from an invalid PropertyTable.
static const PropertyViewStatusType ErrorInvalidValueBuffer
This property view has a valid value buffer view, but the buffer view specifies an invalid buffer ind...
static const PropertyViewStatusType ErrorInvalidStringOffsetBufferView
This string property view does not have a valid string offset buffer view index.
static const PropertyViewStatusType ErrorInvalidArrayOffsetType
This property view has an unknown array offset type.
static const PropertyViewStatusType ErrorStringOffsetsNotSorted
This property view's string offset values are not sorted in ascending order.
static const PropertyViewStatusType ErrorStringOffsetOutOfBounds
This property view has a string offset that is out of bounds.
static const PropertyViewStatusType ErrorBufferViewSizeNotDivisibleByTypeSize
This property view has an invalid buffer view; its length is not a multiple of the size of its type /...
PropertyTablePropertyView(const ClassProperty &classProperty, int64_t size)
Constructs an instance of an empty property that specifies a default value. Although this property ha...
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, int64_t size, std::span< const std::byte > values, std::span< const std::byte > arrayOffsets, std::span< const std::byte > stringOffsets, PropertyComponentType arrayOffsetType, PropertyComponentType stringOffsetType) noexcept
Construct an instance pointing to the data specified by a PropertyTableProperty.
PropertyTablePropertyView()
Constructs an invalid instance for a non-existent property.
std::optional< PropertyValueViewToCopy< ElementType > > get(int64_t index) const noexcept
Get the value of an element in the PropertyTable, with all value transforms applied....
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition, int64_t size, std::span< const std::byte > values, std::span< const std::byte > arrayOffsets, std::span< const std::byte > stringOffsets, PropertyComponentType arrayOffsetType, PropertyComponentType stringOffsetType) noexcept
Construct an instance pointing to the data specified by a PropertyTableProperty, with an enum definit...
ElementType getRaw(int64_t index) const noexcept
Get the raw value of an element of the PropertyTable, without offset or scale applied.
PropertyTablePropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
int64_t size() const noexcept
Get the number of elements in this PropertyTablePropertyView. If the view is valid,...
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, int64_t size, std::span< const std::byte > values) noexcept
Construct an instance pointing to data specified by a PropertyTableProperty. Used for non-array or fi...
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, const CesiumGltf::Enum *pEnumDefinition, int64_t size, std::span< const std::byte > values) noexcept
Construct an instance pointing to data specified by a PropertyTableProperty, with an enum definition ...
PropertyTablePropertyView()
Constructs an invalid instance for a non-existent property.
std::optional< PropertyValueViewToCopy< NormalizedType > > get(int64_t index) const noexcept
Get the value of an element of the PropertyTable, with normalization and other value transforms appli...
ElementType getRaw(int64_t index) const noexcept
Get the raw value of an element of the PropertyTable, without offset, scale, or normalization applied...
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, int64_t size, std::span< const std::byte > values) noexcept
Construct an instance pointing to data specified by a PropertyTableProperty. Used for non-array or fi...
PropertyTablePropertyView(PropertyViewStatusType status)
Constructs an invalid instance for an erroneous property.
PropertyTablePropertyView(const PropertyTableProperty &property, const ClassProperty &classProperty, int64_t size, std::span< const std::byte > values, std::span< const std::byte > arrayOffsets, PropertyComponentType arrayOffsetType) noexcept
Construct an instance pointing to the data specified by a PropertyTableProperty.
int64_t size() const noexcept
Get the number of elements in this PropertyTablePropertyView. If the view is valid,...
PropertyTablePropertyView(const ClassProperty &classProperty, int64_t size)
Constructs an instance of an empty property that specifies a default value. Although this property ha...
A view on the data of the PropertyTableProperty that is created by a PropertyTableView.
Indicates the status of a property view.
static const PropertyViewStatusType Valid
This property view is valid and ready to use.
static const PropertyViewStatusType EmptyPropertyWithDefault
This property view does not contain any data, but specifies a default value. This happens when a clas...
Represents a metadata property in EXT_structural_metadata.
Classes for working with glTF models.
PropertyComponentType
The possible types of a property component.
PropertyArrayCopy< glm::mat< N, N, double > > transformNormalizedMatNArray(const PropertyArrayView< glm::mat< N, N, T > > &value, const std::optional< PropertyArrayView< glm::mat< N, N, double > > > &offset, const std::optional< PropertyArrayView< glm::mat< N, N, double > > > &scale)
Normalizes each element of an array of matrices and transforms them by optional offset and scale fact...
PropertyArrayCopy< glm::vec< N, double > > transformNormalizedVecNArray(const PropertyArrayView< glm::vec< N, T > > &value, const std::optional< PropertyArrayView< glm::vec< N, double > > > &offset, const std::optional< PropertyArrayView< glm::vec< N, double > > > &scale)
Normalizes each element of an array of vectors and transforms them by optional offset and scale facto...
PropertyArrayCopy< NormalizedType > transformNormalizedArray(const PropertyArrayView< T > &value, const std::optional< PropertyArrayView< NormalizedType > > &offset, const std::optional< PropertyArrayView< NormalizedType > > &scale)
Normalizes each element of an array of values and transforms them by optional offset and scale factor...
T transformValue(const T &value, const std::optional< T > &offset, const std::optional< T > &scale)
Transforms the value by optional offset and scale factors.
double normalize(T value)
Normalizes the given value between [0, 1] if unsigned or [-1, 1] if signed, based on the type's maxim...
int64_t getOffsetTypeSize(PropertyComponentType offsetType) noexcept
Returns the size in bytes of a PropertyComponentType used as the arrayOffsetType in the constructor o...
PropertyArrayCopy< T > transformArray(const PropertyArrayView< T > &value, const std::optional< PropertyArrayView< T > > &offset, const std::optional< PropertyArrayView< T > > &scale)
Transforms each element of an array of values by optional offset and scale factors....
int32_t PropertyViewStatusType
The type used for fields of PropertyViewStatus.
std::optional< CesiumUtility::JsonValue > defaultProperty
A default value to use when encountering a noData value or an omitted property. The value is given in...
This class is not meant to be instantiated directly. Use Enum instead.
Definition Enum.h:12
Check if a C++ type can be represented as an array.
Check if a C++ type can be represented as an array of booleans property type.
Check if a C++ type can be represented as a boolean property type.
Check if a C++ type can be represented as a matN type.
Check if a C++ type can be represented as an array of numeric elements property type.
Check if a C++ type can be represented as a numeric property, i.e. a scalar / vecN / matN type.
Check if a C++ type can be represented as a scalar property type.
Check if a C++ type can be represented as an array of strings property type.
Check if a C++ type can be represented as a string property type.
Check if a C++ type can be represented as a vecN type.
void type
The component type of this metadata array.
An array of binary property values.
Convert an integer numeric type to the corresponding representation as a double type....