FnUsdAbstractionLib 0.6.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
usg::Attribute Class Reference

#include <Attribute.h>

Public Member Functions

 Attribute ()
 Abstraction handle for casting to UsdAttribute.
 
 Attribute (const Attribute &)
 Copy constructors.
 
Attributeoperator= (const Attribute &)
 
bool isValid () const
 True if Attribute::Impl is valid (has a valid object binding.)
 
 operator bool () const
 
bool isSdfAttributeSpec () const
 Is this Attribute bound to an SdfAttributeSpec?
 
bool isUsdAttribute () const
 Is this Attribute bound to a UsdAttribute?
 
Attribute::AttrSpecHandle * getSdfAttributeSpecHandle (int usd_version)
 
const Attribute::AttrSpecHandle * getSdfAttributeSpecHandle (int usd_version) const
 
Attribute::UsdAttrHandle * getUsdAttribute (int usd_version)
 
const Attribute::UsdAttrHandle * getUsdAttribute (int usd_version) const
 
const std::string & getName () const
 Returns the name of the attribute.
 
Token getNameToken () const
 Returns the name of the attribute as a token.
 
const std::string & getBaseName () const
 Returns the base name of the attribute.
 
Token getBaseNameToken () const
 Returns the base name of the attribute as a token.
 
Path getPath () const
 Returns the full path including the Prim parent.
 
Value::Type getType () const
 Returns the attribute's Value type.
 
const std::string & getTypeName () const
 Returns the attribute's type name.
 
size_t getNumDataElements () const
 Returns the number of data elements for each value. For example, 3 for a Vector3 or 16 for a Matrix4.
 
size_t getBytesPerDataElement () const
 Returns the number of bytes for a data element. For example, 4 for a float or 8 for a double.
 
TimeVariability getVariability () const
 Returns the variability of this attribute.
 
std::string getDisplayName () const
 Returns the display name of the attribute.
 
bool setDisplayName (const std::string &displayName)
 Sets the display name of the attribute.
 
std::string getDisplayGroup () const
 Returns the display group of the attribute.
 
bool setDisplayGroup (const std::string &displayGroup)
 Sets the display group of the attribute.
 
std::string getDocumentation () const
 Returns the documentation for the attribute.
 
bool isDefined () const
 Returns true if the attribute is defined.
 
bool hasValue () const
 
bool isAuthored () const
 Returns true if the attribute has any authored values in any layer.
 
bool hasAuthoredValue () const
 
bool hasFallbackValue () const
 Returns true if the attribute has a fallback value provided by a schema.
 
bool isBlocked () const
 Is the attribute currently blocked? Same as calling !hasAuthoredValue().
 
bool hasAllowedTokens () const
 Returns true if this Attribute has a set of allowed Tokens.
 
TokenArray getAllowedTokens () const
 Returns an array of the allowed Tokens for this Attribute.
 
template<typename T >
bool setValue (const T &src, const fdk::TimeValue &time=fdk::defaultTimeValue())
 Sets a value on the attribute, returning true on success.
 
bool setValue (const Value &srcValue, const fdk::TimeValue &time=fdk::defaultTimeValue())
 Sets a value on the attribute, returning true on success.
 
template<typename T >
size_t getValue (T &dst, const fdk::TimeValue &time=fdk::earliestTimeValue()) const
 
size_t getValue (Value &dstValue, const fdk::TimeValue &time=fdk::earliestTimeValue()) const
 
size_t getNumTimeSamples () const
 Returns the number of time samples set on the attribute.
 
size_t getTimeSamples (fdk::TimeValueList &times) const
 Fills the array with all time samples set on the attribute, in ascending order. Returns the size of the array.
 
fdk::TimeValueList getTimeSamples () const
 Returns an array with all time samples set on the attribute, in ascending order.
 
bool copyTimeSample (const Attribute &other, fdk::TimeValue otherTime, fdk::TimeValue time)
 Copies the time sample from the other attribute at the other time into this attribute at given time.
 
bool isAnimating () const
 Returns true if the attribute has authored time samples.
 
void clear ()
 Removes all authored values, including the default one.
 
void clearDefault ()
 Removes the default value, leaving time samples unaffected.
 
void clearAllTimeSamples ()
 Removes all time samples from the attribute, leaving the default value unaffected.
 
void clearAtTime (const fdk::TimeValue &time)
 Removes a specific time sample, ignoring default value.
 
void block ()
 Removes all authored values, leaving the attribute as if unauthored.
 
size_t getSize (const fdk::TimeValue &time=fdk::earliestTimeValue()) const
 
size_t getArraySize (const fdk::TimeValue &time=fdk::earliestTimeValue()) const
 If the Attribute is an array type returns its length(size), otherwise 0, possibly at a specific time.
 
void getFieldNames (fdk::StringList &field_names) const
 Gets a list of field names as strings defined on the Attribute.
 
usg::TokenArray getFieldNames () const
 Gets a list of field names as tokens defined on the Attribute.
 
usg::TokenArray getAuthoredFieldNames () const
 Gets a list of authored field names.
 
bool hasField (const Token &field_name) const
 Returns true if Attribute has the named field and it has a value.
 
Value getField (const Token &field_name) const
 Returns the content of the non-empty named field, otherwise an invalid Value.
 
bool setField (const Token &field_name, const Value &value)
 Sets the contents of a field, creating it if required.
 
bool deleteField (const Token &field_name)
 Removes the named field from the Attribute.
 
void setInterpolation (const Token &interpolation)
 Sets the interpolation for this attribute.
 
Token getInterpolation () const
 Gets the interpolation for this attribute.
 
void setCustomData (const std::string &key, const Value &value)
 Sets a value in the custom data for this attribute.
 
bool getCustomData (const std::string &key, Value &value) const
 Returns the value for key in the custom data for this attribute.
 
CustomDataRef getCustomData () const
 Returns the attribute's custom data.
 
void setCustom (bool isCustom)
 Sets if Attribute is custom or not.
 
bool getCustom () const
 Gets if Attribute is custom or not.
 
bool hasAuthoredConnections () const
 Return true if this attribute has any authored connection opinions.
 
bool setConnections (const PathArray &sources)
 Replaces connections with a new list.
 
bool setConnectionTo (const Path &source)
 Clears any existing connections then sets it to this one. Same as clearConnections() followed by addConnection().
 
bool addConnectionTo (const Path &source)
 Appends a connection to the current list.
 
bool prependConnectionTo (const Path &source)
 Prepends a connection to the current list.
 
bool removeConnectionTo (const Path &source)
 Removes connection to source, if it exists.
 
void clearConnections ()
 Removes all connections.
 
size_t numConnections () const
 Returns the number of assigned connections.
 
Path getConnection (int i=0) const
 Returns the connection at index i.
 
 Attribute (const Attribute::Impl &)
 
Attributeoperator= (const Attribute::Impl &)
 
bool setFromImpl (Attribute::Impl &&b)
 Takes ownership of 'b' - returns true if resulting Attribute is valid.
 
Attribute::Impl * impl ()
 Returns the wrapped object.
 
const Attribute::Impl * impl () const
 

Protected Attributes

std::unique_ptr< Attribute::Impl, void(*)(Attribute::Impl *)> _pImpl
 

Friends

USG_API std::ostream & operator<< (std::ostream &o, const Attribute &b)
 Calls through to << operator on the contained data.
 

Detailed Description

Geometry attributes (or properties) contain arbitrary values and are owned by Prims which are stored on either a Layer or Stage depending on the define/edit phase of the geometry system.

Attributes are always attached to Prims so use the Prim interface to create or gain access to them.

To create Attributes use Prim::createIntrinsicAttr() or Prim::createCustomAttr(). To access an existing Attribute use Prim::getAttr().

Constructor & Destructor Documentation

◆ Attribute()

usg::Attribute::Attribute ( )

Abstraction handle for casting to UsdAttribute.

Default ctor builds an empty (invalid) attribute.

Member Function Documentation

◆ getSdfAttributeSpecHandle()

Attribute::AttrSpecHandle * usg::Attribute::getSdfAttributeSpecHandle ( int  usd_version)

If the Attribute is bound to an SdfAttributeSpecHandle return a pointer to the underlying SdfAttributeSpecHandle object, assuming the usd_version passed in matches the Usd version this library was built with, otherwise return null.

The version must match the one returned by usg::usdAPIVersion().

Caller should cast the returned pointer to a SdfAttributeSpecHandle* and possibly double-check its validity since a SdfAttributeSpecHandle can be created without a valid binding. However, if Attribute::isValid() returns true then the underlying binding will also be valid.

◆ getUsdAttribute()

Attribute::UsdAttrHandle * usg::Attribute::getUsdAttribute ( int  usd_version)

If the Attribute is bound to a UsdAttribute return a pointer to the underlying UsdAttribute object, assuming the usd_version passed in matches the Usd version this library was built with, otherwise return null.

The version must match the one returned by usg::usdAPIVersion().

Caller should cast the returned pointer to a UsdAttribute* and possibly double-check its validity since a UsdAttribute can be created without a valid binding. However, if Attribute::isValid() returns true then the underlying binding will also be valid.

◆ hasValue()

bool usg::Attribute::hasValue ( ) const

Returns true if the attribute has any authored values, either a default or time samples, or if there's a fallback value provided by a schema. Returns false if the attribute has been blocked and there is no fallback value.

◆ hasAuthoredValue()

bool usg::Attribute::hasAuthoredValue ( ) const

Returns true if the attribute has any authored values, either a default or time samples. Returns false if the attribute has been blocked.

◆ getValue()

template<typename T >
size_t usg::Attribute::getValue ( T &  dst,
const fdk::TimeValue &  time = fdk::earliestTimeValue() 
) const

Retrieves the value from the attribute, returning 0 on fail, 1 for single-value type, or size of array for an array type.

Referenced by usg::Primvar::computeFlattened().

◆ getSize()

size_t usg::Attribute::getSize ( const fdk::TimeValue &  time = fdk::earliestTimeValue()) const

Returns the number of values in the attribute, possibly at a specific time. 0 is returned if Attribute not valid or assigned. 1 is returned if Attribute is not an array type, otherwise array size is returned.



©2025 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk