cesium-native 0.64.0
Loading...
Searching...
No Matches
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
162template <typename ElementType>
163class PropertyTablePropertyView<ElementType, false>
164 : public PropertyView<ElementType, false> {
165public:
170 : PropertyView<ElementType, false>(),
171 _values{},
172 _size{0},
173 _arrayOffsets{},
174 _arrayOffsetType{PropertyComponentType::None},
175 _arrayOffsetTypeSize{0},
176 _stringOffsets{},
177 _stringOffsetType{PropertyComponentType::None},
178 _stringOffsetTypeSize{0} {}
179
187 : PropertyView<ElementType, false>(status),
188 _values{},
189 _size{0},
190 _arrayOffsets{},
191 _arrayOffsetType{PropertyComponentType::None},
192 _arrayOffsetTypeSize{0},
193 _stringOffsets{},
194 _stringOffsetType{PropertyComponentType::None},
195 _stringOffsetTypeSize{0} {
196 CESIUM_ASSERT(
198 "An empty property view should not be constructed with a valid status");
199 }
200
212 PropertyTablePropertyView(const ClassProperty& classProperty, int64_t size)
213 : PropertyView<ElementType, false>(classProperty),
214 _values{},
215 _size{0},
216 _arrayOffsets{},
217 _arrayOffsetType{PropertyComponentType::None},
218 _arrayOffsetTypeSize{0},
219 _stringOffsets{},
220 _stringOffsetType{PropertyComponentType::None},
221 _stringOffsetTypeSize{0} {
223 // Don't override the status / size if something is wrong with the class
224 // property's definition.
225 return;
226 }
227
228 if (!classProperty.defaultProperty) {
229 // This constructor should only be called if the class property *has* a
230 // default value. But in the case that it does not, this property view
231 // becomes invalid.
232 this->_status = PropertyTablePropertyViewStatus::ErrorNonexistentProperty;
233 return;
234 }
235
237 this->_size = size;
238 }
239
252 const PropertyTableProperty& property,
253 const ClassProperty& classProperty,
254 int64_t size,
255 std::span<const std::byte> values) noexcept
257 property,
258 classProperty,
259 nullptr,
260 size,
261 values) {}
262
278 const PropertyTableProperty& property,
279 const ClassProperty& classProperty,
280 const CesiumGltf::Enum* pEnumDefinition,
281 int64_t size,
282 std::span<const std::byte> values) noexcept
283 : PropertyView<ElementType>(classProperty, property, pEnumDefinition),
284 _values{values},
285 _size{
286 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
287 _arrayOffsets{},
288 _arrayOffsetType{PropertyComponentType::None},
289 _arrayOffsetTypeSize{0},
290 _stringOffsets{},
291 _stringOffsetType{PropertyComponentType::None},
292 _stringOffsetTypeSize{0} {}
293
314 const PropertyTableProperty& property,
315 const ClassProperty& classProperty,
316 int64_t size,
317 std::span<const std::byte> values,
318 std::span<const std::byte> arrayOffsets,
319 std::span<const std::byte> stringOffsets,
320 PropertyComponentType arrayOffsetType,
321 PropertyComponentType stringOffsetType) noexcept
323 property,
324 classProperty,
325 nullptr,
326 size,
327 values,
328 arrayOffsets,
329 stringOffsets,
330 arrayOffsetType,
331 stringOffsetType) {}
332
355 const PropertyTableProperty& property,
356 const ClassProperty& classProperty,
357 const CesiumGltf::Enum* pEnumDefinition,
358 int64_t size,
359 std::span<const std::byte> values,
360 std::span<const std::byte> arrayOffsets,
361 std::span<const std::byte> stringOffsets,
362 PropertyComponentType arrayOffsetType,
363 PropertyComponentType stringOffsetType) noexcept
364 : PropertyView<ElementType>(classProperty, property, pEnumDefinition),
365 _values{values},
366 _size{
367 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
368 _arrayOffsets{arrayOffsets},
369 _arrayOffsetType{arrayOffsetType},
370 _arrayOffsetTypeSize{getOffsetTypeSize(arrayOffsetType)},
371 _stringOffsets{stringOffsets},
372 _stringOffsetType{stringOffsetType},
373 _stringOffsetTypeSize{getOffsetTypeSize(stringOffsetType)} {}
374
390 std::optional<PropertyValueViewToCopy<ElementType>>
391 get(int64_t index) const noexcept {
392 if (this->_status ==
394 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
395 CESIUM_ASSERT(index < size() && "index must be less than size");
396
397 return propertyValueViewToCopy(this->defaultValue());
398 }
399
400 ElementType value = getRaw(index);
401
402 if (value == this->noData()) {
403 return propertyValueViewToCopy(this->defaultValue());
404 } else if constexpr (IsMetadataNumeric<ElementType>::value) {
405 return transformValue(value, this->offset(), this->scale());
406 } else if constexpr (IsMetadataNumericArray<ElementType>::value) {
407 return transformArray(value, this->offset(), this->scale());
408 } else {
409 return value;
410 }
411 }
412
423 ElementType getRaw(int64_t index) const noexcept {
424 CESIUM_ASSERT(
426 "Check the status() first to make sure view is valid");
427 CESIUM_ASSERT(
428 size() > 0 &&
429 "Check the size() of the view to make sure it's not empty");
430 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
431 CESIUM_ASSERT(index < size() && "index must be less than size");
432
434 return getNumericValue(index);
435 }
436
438 return getBooleanValue(index);
439 }
440
442 return getStringValue(index);
443 }
444
446 return getNumericArrayValues<
448 }
449
451 return getBooleanArrayValues(index);
452 }
453
455 return getStringArrayValues(index);
456 }
457 }
458
466 int64_t size() const noexcept { return _size; }
467
468private:
469 ElementType getNumericValue(int64_t index) const noexcept {
470 return reinterpret_cast<const ElementType*>(_values.data())[index];
471 }
472
473 bool getBooleanValue(int64_t index) const noexcept {
474 const int64_t byteIndex = index / 8;
475 const int64_t bitIndex = index % 8;
476 const int bitValue =
477 static_cast<int>(_values[static_cast<size_t>(byteIndex)] >> bitIndex) &
478 1;
479 return bitValue == 1;
480 }
481
482 std::string_view getStringValue(int64_t index) const noexcept {
483 const size_t currentOffset = getOffsetFromOffsetsBuffer(
484 static_cast<size_t>(index),
485 _stringOffsets,
486 _stringOffsetType);
487 const size_t nextOffset = getOffsetFromOffsetsBuffer(
488 static_cast<size_t>(index + 1),
489 _stringOffsets,
490 _stringOffsetType);
491 return std::string_view(
492 reinterpret_cast<const char*>(_values.data() + currentOffset),
493 nextOffset - currentOffset);
494 }
495
496 template <typename T>
497 PropertyArrayView<T> getNumericArrayValues(int64_t index) const noexcept {
498 size_t count = static_cast<size_t>(this->arrayCount());
499 // Handle fixed-length arrays
500 if (count > 0) {
501 size_t arraySize = count * sizeof(T);
502 const std::span<const std::byte> values(
503 _values.data() + static_cast<size_t>(index) * arraySize,
504 arraySize);
505 return PropertyArrayView<T>{values};
506 }
507
508 // Handle variable-length arrays. The offsets are interpreted as array
509 // indices, not byte offsets, so they must be multiplied by sizeof(T)
510 const size_t currentOffset = getOffsetFromOffsetsBuffer(
511 static_cast<size_t>(index),
512 _arrayOffsets,
513 _arrayOffsetType) *
514 sizeof(T);
515 const size_t nextOffset = getOffsetFromOffsetsBuffer(
516 static_cast<size_t>(index + 1),
517 _arrayOffsets,
518 _arrayOffsetType) *
519 sizeof(T);
520 const std::span<const std::byte> values(
521 _values.data() + currentOffset,
522 nextOffset - currentOffset);
523 return PropertyArrayView<T>{values};
524 }
525
526 PropertyArrayView<std::string_view>
527 getStringArrayValues(int64_t index) const noexcept {
528 size_t count = static_cast<size_t>(this->arrayCount());
529 // Handle fixed-length arrays
530 if (count > 0) {
531 // Copy the corresponding string offsets to pass to the PropertyArrayView.
532 const size_t arraySize =
533 count * static_cast<size_t>(_stringOffsetTypeSize);
534 const std::span<const std::byte> stringOffsetValues(
535 _stringOffsets.data() + static_cast<size_t>(index) * arraySize,
536 arraySize + static_cast<size_t>(_stringOffsetTypeSize));
537 return PropertyArrayView<std::string_view>(
538 _values,
539 stringOffsetValues,
540 _stringOffsetType,
541 static_cast<int64_t>(count));
542 }
543
544 // Handle variable-length arrays
545 const size_t currentArrayOffset =
546 getOffsetFromOffsetsBuffer(
547 static_cast<size_t>(index),
548 _arrayOffsets,
549 _arrayOffsetType) *
550 static_cast<size_t>(_stringOffsetTypeSize);
551 const size_t nextArrayOffset = getOffsetFromOffsetsBuffer(
552 static_cast<size_t>(index + 1),
553 _arrayOffsets,
554 _arrayOffsetType) *
555 static_cast<size_t>(_stringOffsetTypeSize);
556 const size_t arraySize = nextArrayOffset - currentArrayOffset;
557 const std::span<const std::byte> stringOffsetValues(
558 _stringOffsets.data() + currentArrayOffset,
559 arraySize + static_cast<size_t>(_stringOffsetTypeSize));
560 return PropertyArrayView<std::string_view>(
561 _values,
562 stringOffsetValues,
563 _stringOffsetType,
564 static_cast<int64_t>(arraySize) / _stringOffsetTypeSize);
565 }
566
567 PropertyArrayView<bool> getBooleanArrayValues(int64_t index) const noexcept {
568 size_t count = static_cast<size_t>(this->arrayCount());
569 // Handle fixed-length arrays
570 if (count > 0) {
571 const size_t offsetBits = count * static_cast<size_t>(index);
572 const size_t nextOffsetBits = count * static_cast<size_t>(index + 1);
573 const std::span<const std::byte> buffer(
574 _values.data() + offsetBits / 8,
575 (nextOffsetBits / 8 - offsetBits / 8 + 1));
576 return PropertyArrayView<bool>(
577 buffer,
578 offsetBits % 8,
579 static_cast<int64_t>(count));
580 }
581
582 // Handle variable-length arrays
583 const size_t currentOffset = getOffsetFromOffsetsBuffer(
584 static_cast<size_t>(index),
585 _arrayOffsets,
586 _arrayOffsetType);
587 const size_t nextOffset = getOffsetFromOffsetsBuffer(
588 static_cast<size_t>(index + 1),
589 _arrayOffsets,
590 _arrayOffsetType);
591 const size_t totalBits = nextOffset - currentOffset;
592 const std::span<const std::byte> buffer(
593 _values.data() + currentOffset / 8,
594 (nextOffset / 8 - currentOffset / 8 + 1));
595 return PropertyArrayView<bool>(
596 buffer,
597 currentOffset % 8,
598 static_cast<int64_t>(totalBits));
599 }
600
601 std::span<const std::byte> _values;
602 int64_t _size;
603
604 std::span<const std::byte> _arrayOffsets;
605 PropertyComponentType _arrayOffsetType;
606 int64_t _arrayOffsetTypeSize;
607
608 std::span<const std::byte> _stringOffsets;
609 PropertyComponentType _stringOffsetType;
610 int64_t _stringOffsetTypeSize;
611};
612
627template <typename ElementType>
628class PropertyTablePropertyView<ElementType, true>
629 : public PropertyView<ElementType, true> {
630private:
631 using NormalizedType = typename TypeToNormalizedType<ElementType>::type;
632
633public:
638 : PropertyView<ElementType, true>(),
639 _values{},
640 _size{0},
641 _arrayOffsets{},
642 _arrayOffsetType{PropertyComponentType::None},
643 _arrayOffsetTypeSize{0} {}
644
652 : PropertyView<ElementType, true>(status),
653 _values{},
654 _size{0},
655 _arrayOffsets{},
656 _arrayOffsetType{PropertyComponentType::None},
657 _arrayOffsetTypeSize{0} {
658 CESIUM_ASSERT(
660 "An empty property view should not be constructed with a valid status");
661 }
662
674 PropertyTablePropertyView(const ClassProperty& classProperty, int64_t size)
675 : PropertyView<ElementType, true>(classProperty),
676 _values{},
677 _size{0},
678 _arrayOffsets{},
679 _arrayOffsetType{PropertyComponentType::None},
680 _arrayOffsetTypeSize{0} {
682 // Don't override the status / size if something is wrong with the class
683 // property's definition.
684 return;
685 }
686
687 if (!classProperty.defaultProperty) {
688 // This constructor should only be called if the class property *has* a
689 // default value. But in the case that it does not, this property view
690 // becomes invalid.
691 this->_status = PropertyTablePropertyViewStatus::ErrorNonexistentProperty;
692 return;
693 }
694
696 this->_size = size;
697 }
698
711 const PropertyTableProperty& property,
712 const ClassProperty& classProperty,
713 int64_t size,
714 std::span<const std::byte> values) noexcept
715 : PropertyView<ElementType, true>(classProperty, property),
716 _values{values},
717 _size{
718 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
719 _arrayOffsets{},
720 _arrayOffsetType{PropertyComponentType::None},
721 _arrayOffsetTypeSize{0} {}
722
740 const PropertyTableProperty& property,
741 const ClassProperty& classProperty,
742 int64_t size,
743 std::span<const std::byte> values,
744 std::span<const std::byte> arrayOffsets,
745 PropertyComponentType arrayOffsetType) noexcept
746 : PropertyView<ElementType, true>(classProperty, property),
747 _values{values},
748 _size{
749 this->_status == PropertyTablePropertyViewStatus::Valid ? size : 0},
750 _arrayOffsets{arrayOffsets},
751 _arrayOffsetType{arrayOffsetType},
752 _arrayOffsetTypeSize{getOffsetTypeSize(arrayOffsetType)} {}
753
769 std::optional<PropertyValueViewToCopy<NormalizedType>>
770 get(int64_t index) const noexcept {
771 if (this->_status ==
773 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
774 CESIUM_ASSERT(index < size() && "index must be less than size");
775
776 return propertyValueViewToCopy(this->defaultValue());
777 }
778
779 ElementType value = getRaw(index);
780 if (this->noData() && value == *(this->noData())) {
781 return propertyValueViewToCopy(this->defaultValue());
782 } else if constexpr (IsMetadataScalar<ElementType>::value) {
785 this->offset(),
786 this->scale());
787 } else if constexpr (IsMetadataVecN<ElementType>::value) {
788 constexpr glm::length_t N = ElementType::length();
789 using T = typename ElementType::value_type;
790 using NormalizedT = typename NormalizedType::value_type;
792 normalize<N, T>(value),
793 this->offset(),
794 this->scale());
795 } else if constexpr (IsMetadataMatN<ElementType>::value) {
796 constexpr glm::length_t N = ElementType::length();
797 using T = typename ElementType::value_type;
798 using NormalizedT = typename NormalizedType::value_type;
800 normalize<N, T>(value),
801 this->offset(),
802 this->scale());
803 } else if constexpr (IsMetadataArray<ElementType>::value) {
804 using ArrayElementType = typename MetadataArrayType<ElementType>::type;
807 value,
808 this->offset(),
809 this->scale());
810 } else if constexpr (IsMetadataVecN<ArrayElementType>::value) {
811 constexpr glm::length_t N = ArrayElementType::length();
812 using T = typename ArrayElementType::value_type;
814 value,
815 this->offset(),
816 this->scale());
817 } else if constexpr (IsMetadataMatN<ArrayElementType>::value) {
818 constexpr glm::length_t N = ArrayElementType::length();
819 using T = typename ArrayElementType::value_type;
821 value,
822 this->offset(),
823 this->scale());
824 }
825 }
826 }
827
838 ElementType getRaw(int64_t index) const noexcept {
839 CESIUM_ASSERT(
841 "Check the status() first to make sure view is valid");
842 CESIUM_ASSERT(
843 size() > 0 &&
844 "Check the size() of the view to make sure it's not empty");
845 CESIUM_ASSERT(index >= 0 && "index must be non-negative");
846 CESIUM_ASSERT(index < size() && "index must be less than size");
847
849 return getValue(index);
850 }
851
853 return getArrayValues<typename MetadataArrayType<ElementType>::type>(
854 index);
855 }
856 }
857
865 int64_t size() const noexcept {
866 return this->_status == PropertyTablePropertyViewStatus::Valid ? _size : 0;
867 }
868
869private:
870 ElementType getValue(int64_t index) const noexcept {
871 return reinterpret_cast<const ElementType*>(_values.data())[index];
872 }
873
874 template <typename T>
875 PropertyArrayView<T> getArrayValues(int64_t index) const noexcept {
876 size_t count = static_cast<size_t>(this->arrayCount());
877 // Handle fixed-length arrays
878 if (count > 0) {
879 size_t arraySize = count * sizeof(T);
880 const std::span<const std::byte> values(
881 _values.data() + static_cast<size_t>(index) * arraySize,
882 arraySize);
883 return PropertyArrayView<T>{values};
884 }
885
886 // Handle variable-length arrays. The offsets are interpreted as array
887 // indices, not byte offsets, so they must be multiplied by sizeof(T)
888 const size_t currentOffset = getOffsetFromOffsetsBuffer(
889 static_cast<size_t>(index),
890 _arrayOffsets,
891 _arrayOffsetType) *
892 sizeof(T);
893 const size_t nextOffset = getOffsetFromOffsetsBuffer(
894 static_cast<size_t>(index + 1),
895 _arrayOffsets,
896 _arrayOffsetType) *
897 sizeof(T);
898 const std::span<const std::byte> values(
899 _values.data() + currentOffset,
900 nextOffset - currentOffset);
901 return PropertyArrayView<T>{values};
902 }
903
904 std::span<const std::byte> _values;
905 int64_t _size;
906
907 std::span<const std::byte> _arrayOffsets;
908 PropertyComponentType _arrayOffsetType;
909 int64_t _arrayOffsetTypeSize;
910};
911
912} // 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...
std::optional< ElementType > offset() const noexcept
Gets the offset to apply to property values. Only applicable to SCALAR, VECN, and MATN types when the...
std::optional< ElementType > scale() const noexcept
Gets the scale to apply to property values. Only applicable to SCALAR, VECN, and MATN types when the ...
std::optional< ElementType > defaultValue() const noexcept
Gets the default value to use when encountering a "no data" value or an omitted property....
PropertyViewStatusType _status
Indicates the status of a property view.
PropertyViewStatusType status() const noexcept
Gets the status of this property view, indicating whether an error occurred.
std::optional< ElementType > noData() const noexcept
Gets the "no data" value, i.e., the value representing missing data in the property wherever it appea...
PropertyView()
Constructs an empty property instance.
std::optional< ElementType > noData() const noexcept
Constructs an empty property instance. false>noData
PropertyViewStatusType _status
Indicates the status of a property view.
std::optional< NormalizedType > scale() const noexcept
Constructs an empty property instance. false>scale
PropertyView()
Constructs an empty property instance.
std::optional< NormalizedType > defaultValue() const noexcept
Constructs an empty property instance. false>defaultValue
PropertyViewStatusType status() const noexcept
Constructs an empty property instance. false>status
std::optional< NormalizedType > offset() const noexcept
Constructs an empty property instance. false>offset
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....