Bifrost SDK
Bifrost SDK documentation
Bifrost::Geometry::DataGeoPropertyGuard< T > Class Template Reference

This class is a RAII guard for a Data geo property. More...

#include <GeoPropertyGuard.h>

Public Member Functions

 DataGeoPropertyGuard ()=default
 Constructor. More...
 
 operator bool () const noexcept
 Returns true if the guard has acquired a geo property. More...
 
const Amino::Array< T > & data () const noexcept
 Returns the data array of the geo property. More...
 
Amino::Array< T > & data () noexcept
 Returns the data array of the geo property. More...
 
const Amino::Stringtarget () const noexcept
 Returns the target of the geo property. More...
 
Amino::Stringtarget () noexcept
 Returns the target of the geo property. More...
 
const Amino::Array< Amino::String > & dependsOn () const noexcept
 Returns the value of the depends_on field in the geo property. More...
 
Amino::Array< Amino::String > & dependsOn () noexcept
 Returns the value of the depends_on field in the geo property. More...
 
const T & defaultValue () const noexcept
 Returns the default value of the geo property. More...
 
T & defaultValue () noexcept
 Returns the default value of the geo property. More...
 
const Bifrost::Geometry::Common::DataInterpolationModeinterpolationMode () const noexcept
 Returns the interpolation_mode field in the geo property. More...
 
Bifrost::Geometry::Common::DataInterpolationModeinterpolationMode () noexcept
 Returns the interpolation_mode field in the geo property. More...
 

Friends

DataGeoPropertyGuard< T > createDataGeoPropGuard (Bifrost::Object &, Amino::StringView)
 Create a DataGeoPropertyGuard for the specified geo property. More...
 

Detailed Description

template<typename T>
class Bifrost::Geometry::DataGeoPropertyGuard< T >

This class is a RAII guard for a Data geo property.

Template Parameters
TThe data type of the geo property.

This class is used to extract, modify and then set back a Data geo property value within a geometry object. This is the preferred method to modify the geo properties of a geometry since extracting the geo property does not increase its reference count, and thus if there are no other references to the value, it will be modified in-place and no copy-on-write will occur. See Amino::Ptr for more details on reference counting.

Do not construct a DataGeoProperty guard directly. Use Bifrost::Geometry::createDataGeoPropGuard instead.

{
// Extract the point positions from the mesh.
auto pointPositions = Bifrost::Geometry::createDataGeoPropGuard<Bifrost::Math::float3>(
// Translate the points along the y-axis by one unit.
std::transform(pointPositions.data().begin(), pointPositions.data().end(),
[](auto& pos) { return pos.y += 1.0f; });
} // At this point the guard is destroyed and the positions are set back into the mesh.
BIFROST_GEOMETRY_DECL Amino::String const sPointPosition

Definition at line 338 of file GeoPropertyGuard.h.

Constructor & Destructor Documentation

◆ DataGeoPropertyGuard()

template<typename T >
Bifrost::Geometry::DataGeoPropertyGuard< T >::DataGeoPropertyGuard ( )
default

Constructor.

Member Function Documentation

◆ data() [1/2]

template<typename T >
const Amino::Array< T > & Bifrost::Geometry::DataGeoPropertyGuard< T >::data ( ) const
inlinenoexcept

Returns the data array of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 349 of file GeoPropertyGuard.h.

◆ data() [2/2]

template<typename T >
Amino::Array< T > & Bifrost::Geometry::DataGeoPropertyGuard< T >::data ( )
inlinenoexcept

Returns the data array of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 352 of file GeoPropertyGuard.h.

◆ defaultValue() [1/2]

template<typename T >
const T & Bifrost::Geometry::DataGeoPropertyGuard< T >::defaultValue ( ) const
inlinenoexcept

Returns the default value of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 370 of file GeoPropertyGuard.h.

◆ defaultValue() [2/2]

template<typename T >
T & Bifrost::Geometry::DataGeoPropertyGuard< T >::defaultValue ( )
inlinenoexcept

Returns the default value of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 373 of file GeoPropertyGuard.h.

◆ dependsOn() [1/2]

template<typename T >
const Amino::Array< Amino::String > & Bifrost::Geometry::DataGeoPropertyGuard< T >::dependsOn ( ) const
inlinenoexcept

Returns the value of the depends_on field in the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 363 of file GeoPropertyGuard.h.

◆ dependsOn() [2/2]

template<typename T >
Amino::Array< Amino::String > & Bifrost::Geometry::DataGeoPropertyGuard< T >::dependsOn ( )
inlinenoexcept

Returns the value of the depends_on field in the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 366 of file GeoPropertyGuard.h.

◆ interpolationMode() [1/2]

template<typename T >
const Bifrost::Geometry::Common::DataInterpolationMode & Bifrost::Geometry::DataGeoPropertyGuard< T >::interpolationMode ( ) const
inlinenoexcept

Returns the interpolation_mode field in the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 377 of file GeoPropertyGuard.h.

◆ interpolationMode() [2/2]

template<typename T >
Bifrost::Geometry::Common::DataInterpolationMode & Bifrost::Geometry::DataGeoPropertyGuard< T >::interpolationMode ( )
inlinenoexcept

Returns the interpolation_mode field in the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 382 of file GeoPropertyGuard.h.

◆ operator bool()

template<typename T >
Bifrost::Geometry::DataGeoPropertyGuard< T >::operator bool ( ) const
inlineexplicitnoexcept

Returns true if the guard has acquired a geo property.

Definition at line 345 of file GeoPropertyGuard.h.

◆ target() [1/2]

template<typename T >
const Amino::String & Bifrost::Geometry::DataGeoPropertyGuard< T >::target ( ) const
inlinenoexcept

Returns the target of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 356 of file GeoPropertyGuard.h.

◆ target() [2/2]

template<typename T >
Amino::String & Bifrost::Geometry::DataGeoPropertyGuard< T >::target ( )
inlinenoexcept

Returns the target of the geo property.

Precondition
This guard has already acquired a geo property.

Definition at line 359 of file GeoPropertyGuard.h.

Friends And Related Function Documentation

◆ createDataGeoPropGuard

template<typename T >
DataGeoPropertyGuard< T > createDataGeoPropGuard ( Bifrost::Object geometry,
Amino::StringView  propertyName 
)
friend

Create a DataGeoPropertyGuard for the specified geo property.

Parameters
[in,out]geometryThe input Bifrost geometry object.
[in]propertyNameThe name of the property to extract.
Template Parameters
TThe data type of the geo property.
Returns
A DataGeoPropertyGuard RAII class that extracts the geometry property with type T and name propertyName from object and sets the property back when the guard is destructed. If the geo property does not exist in the geometry, the returned guard's boolean cast operator will return false.

Definition at line 409 of file GeoPropertyGuard.h.