cesium-native  0.41.0
CesiumGltf::PropertyAttributeView Class Reference

A view on a PropertyAttribute. More...

#include <CesiumGltf/PropertyAttributeView.h>

Public Member Functions

 PropertyAttributeView (const Model &model, const PropertyAttribute &propertyAttribute) noexcept
 Construct a PropertyAttributeView. More...
 
PropertyAttributeViewStatus status () const noexcept
 Gets the status of this property attribute view. More...
 
const std::optional< std::string > & name () const noexcept
 Gets the name of the property attribute being viewed. Returns std::nullopt if no name was specified.
 
const ClassgetClass () const noexcept
 Gets the Class that this property attribute conforms to. More...
 
const ClassPropertygetClassProperty (const std::string &propertyId) const
 Finds the ClassProperty that describes the type information of the property with the specified id. More...
 
template<typename T , bool Normalized = false>
PropertyAttributePropertyView< T, Normalized > getPropertyView (const MeshPrimitive &primitive, const std::string &propertyId) const
 Gets a PropertyAttributePropertyView that views the data of a property stored in the PropertyAttribute. More...
 
template<typename Callback >
void getPropertyView (const MeshPrimitive &primitive, const std::string &propertyId, Callback &&callback) const
 Gets a PropertyAttributePropertyView through a callback that accepts a property id and a PropertyAttributePropertyView<T> that views the data of the property with the specified id. More...
 
template<typename Callback >
void forEachProperty (const MeshPrimitive &primitive, Callback &&callback) const
 Iterates over each property in the PropertyAttribute with a callback that accepts a property id and a PropertyAttributePropertyView<T> to view the data stored in the PropertyAttributeProperty. More...
 

Detailed Description

A view on a PropertyAttribute.

This should be used to get a PropertyAttributePropertyView of a property in the property attribute. It will validate the EXT_structural_metadata format and ensure PropertyAttributePropertyView does not access data out of bounds.

Definition at line 54 of file PropertyAttributeView.h.

Constructor & Destructor Documentation

◆ PropertyAttributeView()

CesiumGltf::PropertyAttributeView::PropertyAttributeView ( const Model model,
const PropertyAttribute propertyAttribute 
)
noexcept

Construct a PropertyAttributeView.

Parameters
modelThe glTF that contains the property attribute's data.
propertyAttributeThe PropertyAttribute from which the view will retrieve data.

Member Function Documentation

◆ forEachProperty()

template<typename Callback >
void CesiumGltf::PropertyAttributeView::forEachProperty ( const MeshPrimitive primitive,
Callback &&  callback 
) const
inline

Iterates over each property in the PropertyAttribute with a callback that accepts a property id and a PropertyAttributePropertyView<T> to view the data stored in the PropertyAttributeProperty.

This method will validate the EXT_structural_metadata format to ensure PropertyAttributePropertyView retrieves the correct data. T must be a scalar with a supported component type (int8_t, uint8_t, int16_t, uint16_t, float), a glm vecN composed of one of the scalar types, or a PropertyArrayView containing one of the scalar types.

If the property is invalid, an empty PropertyAttributePropertyView with an error status will be passed to the callback. Otherwise, a valid property view will be passed to the callback.

Parameters
propertyIdThe id of the property to retrieve data from
Template Parameters
callbackA callback function that accepts property id and PropertyAttributePropertyView<T>

Definition at line 308 of file PropertyAttributeView.h.

◆ getClass()

const Class* CesiumGltf::PropertyAttributeView::getClass ( ) const
inlinenoexcept

Gets the Class that this property attribute conforms to.

Returns
A pointer to the Class. Returns nullptr if the PropertyAttribute did not specify a valid class.

Definition at line 89 of file PropertyAttributeView.h.

◆ getClassProperty()

const ClassProperty* CesiumGltf::PropertyAttributeView::getClassProperty ( const std::string &  propertyId) const

Finds the ClassProperty that describes the type information of the property with the specified id.

Parameters
propertyIdThe id of the property to retrieve the class for.
Returns
A pointer to the ClassProperty. Return nullptr if the PropertyAttributeView is invalid or if no class property was found.

◆ getPropertyView() [1/2]

template<typename T , bool Normalized = false>
PropertyAttributePropertyView<T, Normalized> CesiumGltf::PropertyAttributeView::getPropertyView ( const MeshPrimitive primitive,
const std::string &  propertyId 
) const
inline

Gets a PropertyAttributePropertyView that views the data of a property stored in the PropertyAttribute.

This method will validate the EXT_structural_metadata format to ensure PropertyAttributePropertyView retrieves the correct data. T must be a scalar with a supported component type (int8_t, uint8_t, int16_t, uint16_t, float), a glm vecN composed of one of the scalar types, or a glm matN containing one of the scalar types.

If T does not match the type specified by the class property, this returns an invalid PropertyAttributePropertyView. Likewise, if the value of Normalized does not match the value of {@ClassProperty::normalized} for that class property, this returns an invalid property view. Only types with integer components may be normalized.

Template Parameters
TThe C++ type corresponding to the type of the data retrieved.
NormalizedWhether the property is normalized. Only applicable to types with integer components.
Parameters
primitiveThe target primitive
propertyIdThe id of the property to retrieve data from
Returns
A PropertyAttributePropertyView of the property. If no valid property is found, the property view will be invalid.

Definition at line 126 of file PropertyAttributeView.h.

◆ getPropertyView() [2/2]

template<typename Callback >
void CesiumGltf::PropertyAttributeView::getPropertyView ( const MeshPrimitive primitive,
const std::string &  propertyId,
Callback &&  callback 
) const
inline

Gets a PropertyAttributePropertyView through a callback that accepts a property id and a PropertyAttributePropertyView<T> that views the data of the property with the specified id.

This method will validate the EXT_structural_metadata format to ensure PropertyAttributePropertyView retrieves the correct data. T must be a scalar with a supported component type (int8_t, uint8_t, int16_t, uint16_t, float), a glm vecN composed of one of the scalar types, or a glm matN containing one of the scalar types.

If the property is somehow invalid, an empty PropertyAttributePropertyView with an error status will be passed to the callback. Otherwise, a valid property view will be passed to the callback.

Parameters
primitiveThe target primitive
propertyIdThe id of the property to retrieve data from
Template Parameters
callbackA callback function that accepts a property id and a PropertyAttributePropertyView<T>

Definition at line 173 of file PropertyAttributeView.h.

◆ status()

PropertyAttributeViewStatus CesiumGltf::PropertyAttributeView::status ( ) const
inlinenoexcept

Gets the status of this property attribute view.

Indicates whether the view accurately reflects the property attribute's data, or whether an error occurred.

Definition at line 73 of file PropertyAttributeView.h.


The documentation for this class was generated from the following file: