Public Member Functions | Static Public Member Functions | Protected Member Functions

KFbxLayerElementUserData Class Reference

This reference page is linked to from the following overview topics: Customizing the FBX SDK.


Search for all occurrences

Detailed Description

Layer element for mapping custom user data to a geometry.

This layer element is different from the other types of layer elements in that it has multiple direct arrays. There is one array for each user data attribute. Each array is indexed by the index array.

Examples:

ExportScene03/main.cxx.

Definition at line 1553 of file kfbxlayer.h.

#include <kfbxlayer.h>

Inheritance diagram for KFbxLayerElementUserData:
Inheritance graph
[legend]

List of all members.

Public Member Functions

KFbxLayerElementArrayTemplate
< void * > * 
GetDirectArrayVoid (int pIndex, bool *pStatus=NULL)
  Returns the direct array with the specified attribute index.
KFbxLayerElementArrayTemplate
< void * > const * 
GetDirectArrayVoid (int pIndex, bool *pStatus=NULL) const
  Returns the direct array with the specified attribute index.
KFbxLayerElementArrayTemplate
< void * > * 
GetDirectArrayVoid (const char *pName, bool *pStatus=NULL)
  Returns the direct array with the specified attribute name.
KFbxLayerElementArrayTemplate
< void * > const * 
GetDirectArrayVoid (const char *pName, bool *pStatus=NULL) const
  Returns the direct array with the specified attribute name.
KFbxDataType  GetDataType (int pIndex) const
  Returns the data type for the specified index.
KFbxDataType  GetDataType (const char *pName) const
  Returns the specified attribute data type.
const char *  GetDataName (int pIndex) const
  Returns the attribute name at the specified index.
void  ResizeAllDirectArrays (int pSize)
  Resizes all direct arrays to the specified size.
void  RemoveFromAllDirectArrays (int pIndex)
  Removes a single element at pIndex from every direct array.
int  GetArrayCount (int pIndex) const
  Returns the direct array count for the attribute at pIndex.
int  GetId () const
  Queries the this layer element's ID.
int  GetDirectArrayCount () const
  Returns this layer element's direct array count.
KFbxLayerElementUserData operator= (KFbxLayerElementUserData const &pOther)
  Assignment operator which performs a deep copy.
bool  Clear ()
  Removes all data from this layer element.
virtual int  MemorySize () const
  Queries the amount of memory used by this object as well as its content.

Static Public Member Functions

static KFBXNEW_DECLARE_FRIEND
KFbxLayerElementUserData
Create (KFbxLayerContainer *pOwner, char const *pName, int pId, KArrayTemplate< KFbxDataType > &pDataTypes, KArrayTemplate< const char * > &pDataNames)
  Allocation method.
static KFbxLayerElementUserData Create (KFbxLayerContainer *pOwner, KFbxLayerElementUserData const &pOther)
  Allocation method.

Protected Member Functions

virtual void  AllocateArrays ()

Constructor and Destructor.

  KFbxLayerElementUserData (int pId, KArrayTemplate< KFbxDataType > &pDataTypes, KArrayTemplate< const char * > &pDataNames)
  Constructs a user data layer element.
  KFbxLayerElementUserData (KFbxLayerElementUserData const &pOther)
  Copy constructor.
  ~KFbxLayerElementUserData ()
  Destructor.

Constructor & Destructor Documentation

KFbxLayerElementUserData ( int  pId,
KArrayTemplate< KFbxDataType > &  pDataTypes,
KArrayTemplate< const char * > &  pDataNames 
) [inline, protected]

Constructs a user data layer element.

Parameters:
pId An identifier for this UserData layer element
pDataTypes Attribute data types for this layer element
pDataNames Attribute names for this layer element

Definition at line 1895 of file kfbxlayer.h.

        :
        mId( pId ),
        mDataTypes( pDataTypes )
    {
        K_ASSERT( pDataTypes.GetCount() == pDataNames.GetCount() );
        for( int i = 0; i < pDataNames.GetCount(); ++i )
        {
            mDataNames.Add( FbxSdkNew< KString >( pDataNames[i] ) );
        }
    }
KFbxLayerElementUserData ( KFbxLayerElementUserData const &  pOther ) [inline, protected]

Copy constructor.

A deep copy is made.

Parameters:
pOther Another KFbxLayerElementUserData object to be copied.

Definition at line 1910 of file kfbxlayer.h.

                                                                       : mId(pOther.mId), mDataTypes(pOther.mDataTypes)
    {
        for (int lIndex = 0; lIndex < pOther.mDataNames.GetCount(); ++lIndex)
        {
            mDataNames.Add(FbxSdkNew<KString>(*(pOther.mDataNames[lIndex])));
        }

        SetType(&DTLayerElementUserData);
        AllocateArrays();

        for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
        {
            switch (mDataTypes[i].GetType())
            {
            case eBOOL1:
                KFbxGetDirectArray<bool>(this, i) = KFbxGetDirectArray<bool>(&pOther, i);
                break;

            case eINTEGER1:
                KFbxGetDirectArray<int>(this, i) = KFbxGetDirectArray<int>(&pOther, i);
                break;

            case eFLOAT1:
                KFbxGetDirectArray<float>(this, i) = KFbxGetDirectArray<float>(&pOther, i);
                break;

            case eDOUBLE1:
                KFbxGetDirectArray<double>(this, i) = KFbxGetDirectArray<double>(&pOther, i);
                break;

            default:
                K_ASSERT_MSG_NOW("Unknown type" );
                break;
            }
        }

        if ( ( mReferenceMode == KFbxLayerElement::eINDEX || 
            mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT) &&
            ( pOther.GetReferenceMode() == KFbxLayerElement::eINDEX || 
            pOther.GetReferenceMode()  == KFbxLayerElement::eINDEX_TO_DIRECT))
        {
            GetIndexArray() = pOther.GetIndexArray();
        }
    }
~KFbxLayerElementUserData ( ) [inline, protected]

Destructor.

Definition at line 1956 of file kfbxlayer.h.

    {
        Clear();
    }

Member Function Documentation

static KFBXNEW_DECLARE_FRIEND KFbxLayerElementUserData* Create ( KFbxLayerContainer pOwner,
char const *  pName,
int  pId,
KArrayTemplate< KFbxDataType > &  pDataTypes,
KArrayTemplate< const char * > &  pDataNames 
) [static]

Allocation method.

Parameters:
pOwner The owner of this layer element.
pName The layer element name.
pId The layer element ID.
pDataTypes Attribute data types of this layer element, one direct array is allocated for each Attribute data type.
pDataNames Attribute names of this layer element.
Returns:
A pointer to the layer element or NULL if creation fails.
Remarks:
Only "bool", "int", "float" and "double" are supported.
Examples:
ExportScene03/main.cxx.
static KFbxLayerElementUserData* Create ( KFbxLayerContainer pOwner,
KFbxLayerElementUserData const &  pOther 
) [static]

Allocation method.

Parameters:
pOwner The owner of this layer element.
pOther Other layer element from which to copy.
Returns:
A pointer to the layer element or NULL if creation fails.
KFbxLayerElementArrayTemplate<void*>* GetDirectArrayVoid ( int  pIndex,
bool *  pStatus = NULL 
) [inline]

Returns the direct array with the specified attribute index.

Parameters:
pIndex Specified attribute index.
pStatus A flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.
Examples:
ExportScene03/main.cxx.

Definition at line 1581 of file kfbxlayer.h.

    {       
        if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
        {
            if (pStatus) *pStatus = true;
            return (KFbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
        }
        else
        {
            if( pStatus ) *pStatus = false;
            K_ASSERT_MSG_NOW("Index out of bounds");
            return (KFbxLayerElementArrayTemplate<void*>*)NULL;
        }
    }
KFbxLayerElementArrayTemplate<void*> const* GetDirectArrayVoid ( int  pIndex,
bool *  pStatus = NULL 
) const [inline]

Returns the direct array with the specified attribute index.

Parameters:
pIndex Specified attribute index.
pStatus A flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1601 of file kfbxlayer.h.

    {
        if( pIndex >= 0 || pIndex < GetDirectArray().GetCount() )
        {
            if (pStatus) *pStatus = true;
            return (KFbxLayerElementArrayTemplate<void*>*)GetDirectArray().AsReference(pIndex);
        }
        else
        {
            if( pStatus ) *pStatus = false;
            K_ASSERT_MSG_NOW("Index out of bounds");
            return (KFbxLayerElementArrayTemplate<void*> const*)NULL;
        }
    }
KFbxLayerElementArrayTemplate<void *>* GetDirectArrayVoid ( const char *  pName,
bool *  pStatus = NULL 
) [inline]

Returns the direct array with the specified attribute name.

Parameters:
pName Specified attribute name.
pStatus A flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1622 of file kfbxlayer.h.

    {
        KString lName( pName );
        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return GetDirectArrayVoid(i, pStatus);
        }

        if (pStatus) *pStatus = false;
        return (KFbxLayerElementArrayTemplate<void *>*)NULL;
    }
KFbxLayerElementArrayTemplate<void *> const* GetDirectArrayVoid ( const char *  pName,
bool *  pStatus = NULL 
) const [inline]

Returns the direct array with the specified attribute name.

Parameters:
pName Specified attribute name.
pStatus A flag to indicate whether the direct array is returned successfully or not.
Returns:
The specified attribute's direct array.

Definition at line 1640 of file kfbxlayer.h.

    {
        KString lName( pName );
        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return GetDirectArrayVoid(i, pStatus);
        }

        if (pStatus) *pStatus = false;
        return (KFbxLayerElementArrayTemplate<void *> const*)NULL;
    }
KFbxDataType GetDataType ( int  pIndex ) const [inline]

Returns the data type for the specified index.

Parameters:
pIndex The index of the attribute being queried
Returns:
The data type, or DTNone if pIndex is out of range

Definition at line 1657 of file kfbxlayer.h.

    {
        if( pIndex < 0 || pIndex >= mDataTypes.GetCount() )
            return DTNone;

        return mDataTypes[pIndex];
    }
KFbxDataType GetDataType ( const char *  pName ) const [inline]

Returns the specified attribute data type.

Parameters:
pName The name of the attribute being queried
Returns:
The data type, or DTNone if no attribute has the given name

Definition at line 1669 of file kfbxlayer.h.

    {
        KString lName( pName );

        for( int i = 0; i < mDataNames.GetCount(); ++i )
        {
            if( *mDataNames[i] == lName )
                return mDataTypes[i];
        }

        return DTNone;
    }
const char* GetDataName ( int  pIndex ) const [inline]

Returns the attribute name at the specified index.

Parameters:
pIndex Attribute index
Returns:
The name, or NULL if pIndex is out of range.

Definition at line 1686 of file kfbxlayer.h.

    {
        if( pIndex >= 0 && pIndex < mDataNames.GetCount() )
            return mDataNames[pIndex]->Buffer();

        return NULL;
    }
void ResizeAllDirectArrays ( int  pSize ) [inline]

Resizes all direct arrays to the specified size.

Parameters:
pSize The new size of the direct arrays.
Examples:
ExportScene03/main.cxx.

Definition at line 1697 of file kfbxlayer.h.

    {
        for( int i = 0; i < GetDirectArray().GetCount(); ++i )
        {
            switch( mDataTypes[i].GetType() )
            {
                case eBOOL1:    KFbxGetDirectArray<bool>(this,i).Resize( pSize )  ; break;
                case eINTEGER1: KFbxGetDirectArray<int>(this,i).Resize( pSize )   ; break;
                case eFLOAT1:   KFbxGetDirectArray<float>(this,i).Resize( pSize ) ; break;
                case eDOUBLE1:  KFbxGetDirectArray<double>(this,i).Resize( pSize ); break;
                //case eDOUBLE3:    GetDirectArray< fbxDouble3 >(i).Resize( pSize );    break;
                //case eDOUBLE4:    GetDirectArray< fbxDouble4 >(i).Resize( pSize );    break;
                //case eDOUBLE44:   GetDirectArray< fbxDouble44>(i).Resize( pSize );    break;  
                default:
                    K_ASSERT_MSG_NOW("unknown type" ); break;
            }
        }
    }
void RemoveFromAllDirectArrays ( int  pIndex ) [inline]

Removes a single element at pIndex from every direct array.

Parameters:
pIndex The index of the element to be removed.

Definition at line 1719 of file kfbxlayer.h.

    {
        for( int i = 0; i < GetDirectArray().GetCount(); ++i )
        {
            switch( mDataTypes[i].GetType() )
            {
                case eBOOL1:    KFbxGetDirectArray<bool>(this,i).RemoveAt( pIndex )  ; break;
                case eINTEGER1: KFbxGetDirectArray<int>(this,i).RemoveAt( pIndex )   ; break;
                case eFLOAT1:   KFbxGetDirectArray<float>(this,i).RemoveAt( pIndex ) ; break;
                case eDOUBLE1:  KFbxGetDirectArray<double>(this,i).RemoveAt( pIndex ); break;
                //case eDOUBLE3:    GetDirectArray< fbxDouble3 >(i).RemoveAt( pIndex ); break;
                //case eDOUBLE4:    GetDirectArray< fbxDouble4 >(i).RemoveAt( pIndex ); break;
                //case eDOUBLE44:   GetDirectArray< fbxDouble44>(i).RemoveAt( pIndex ); break;  
                default:
                    K_ASSERT_MSG_NOW("unknown type" ); break;
            }
        }
    }
int GetArrayCount ( int  pIndex ) const [inline]

Returns the direct array count for the attribute at pIndex.

Parameters:
pIndex The attribute index
Returns:
The specified attribute's direct array count.

Definition at line 1742 of file kfbxlayer.h.

    {
        if( pIndex >= 0 && pIndex < GetDirectArray().GetCount() )
        {
            switch( mDataTypes[pIndex].GetType() )
            {
                case eBOOL1:    return KFbxGetDirectArray<bool>(this,pIndex).GetCount();
                case eINTEGER1: return KFbxGetDirectArray<int>(this,pIndex).GetCount();
                case eFLOAT1:   return KFbxGetDirectArray<float>(this,pIndex).GetCount();
                case eDOUBLE1:  return KFbxGetDirectArray<double>(this,pIndex).GetCount();
                //case eDOUBLE3:    return GetDirectArray< fbxDouble3 >(pIndex).GetCount();
                //case eDOUBLE4:    return GetDirectArray< fbxDouble4 >(pIndex).GetCount();
                //case eDOUBLE44:   return GetDirectArray< fbxDouble44>(pIndex).GetCount();
                default:
                    K_ASSERT_MSG_NOW("Unknown type" ); break;
            }
        }

        return -1;
    }
int GetId ( ) const [inline]

Queries the this layer element's ID.

Returns:
The ID expressed as an int

Definition at line 1766 of file kfbxlayer.h.

{ return mId; }
int GetDirectArrayCount ( ) const [inline]

Returns this layer element's direct array count.

Returns:
The direct array count expressed as an int.
Remarks:
This count should be equal to the count of user data attributes.

Definition at line 1772 of file kfbxlayer.h.

{ return GetDirectArray().GetCount(); }
KFbxLayerElementUserData& operator= ( KFbxLayerElementUserData const &  pOther ) [inline]

Assignment operator which performs a deep copy.

Parameters:
pOther Other KFbxLayerElementUserData from which to perform a deep copy.
Returns:
This KFbxLayerElementUserData.

Definition at line 1778 of file kfbxlayer.h.

    {
        if (this == &pOther)
            return *this;

        Clear();

        mId = pOther.mId;
        mDataTypes = pOther.mDataTypes;
        mDataNames.Resize(pOther.mDataNames.GetCount());
        for(int i = 0; i < pOther.mDataNames.GetCount(); ++i)
            mDataNames.SetAt(i,  FbxSdkNew< KString >( *pOther.mDataNames[i] ) );

        Init();
        for(int i = 0; i < pOther.GetDirectArrayCount(); ++i)
        {
            switch (mDataTypes[i].GetType())
            {
            case eBOOL1:
                KFbxGetDirectArray<bool>(this, i) = KFbxGetDirectArray<bool>(&pOther, i);
                break;

            case eINTEGER1:
                KFbxGetDirectArray<int>(this, i) = KFbxGetDirectArray<int>(&pOther, i);
                break;

            case eFLOAT1:
                KFbxGetDirectArray<float>(this, i) = KFbxGetDirectArray<float>(&pOther, i);
                break;

            case eDOUBLE1:
                KFbxGetDirectArray<double>(this, i) = KFbxGetDirectArray<double>(&pOther, i);
                break;

            default:
                K_ASSERT_MSG_NOW("Unknown type" );
                break;
            }
        }

        if ( ( mReferenceMode == KFbxLayerElement::eINDEX || 
               mReferenceMode == KFbxLayerElement::eINDEX_TO_DIRECT) &&
             ( pOther.GetReferenceMode() == KFbxLayerElement::eINDEX || 
               pOther.GetReferenceMode()  == KFbxLayerElement::eINDEX_TO_DIRECT))
        {
            GetIndexArray() = pOther.GetIndexArray();
        }

        return *this;
    }
bool Clear ( ) [inline, virtual]

Removes all data from this layer element.

Returns:
True always

Reimplemented from KFbxLayerElementTemplate< void * >.

Definition at line 1832 of file kfbxlayer.h.

    {
        int i;
        const int lCount = GetDirectArray().GetCount();
        KFbxLayerElementArray** directArray = NULL;
        directArray = GetDirectArray().GetLocked(directArray);
        for( i = 0; directArray != NULL && i < lCount; ++i )
        {
            if( directArray[i] )
                FbxSdkDelete(directArray[i]);
        }
        GetDirectArray().Release((void**)&directArray);

        for( i = 0; i < mDataNames.GetCount(); ++i )
        {
            KFBX_SAFE_DELETE_PTR(mDataNames[i]);
        }
        mDataNames.Clear();
        mDataTypes.Clear();

        KFbxLayerElementTemplate<void*>::Clear();

        return true;
    }
virtual int MemorySize ( ) const [inline, virtual]

Queries the amount of memory used by this object as well as its content.

It does not consider the content pointed.

Returns:
The amount of memory used.

Reimplemented from KFbxLayerElementTemplate< void * >.

Definition at line 1861 of file kfbxlayer.h.

    {
        int size = KFbxLayerElementTemplate<void*>::MemorySize();
        size += sizeof(mId);

        for(int i = 0; i < mDataTypes.GetCount(); i++)
        {
            size += sizeof(mDataTypes[i]);
        }
        size += (mDataNames.GetCount() * sizeof(KString*));

        return size;
    }
virtual void AllocateArrays ( ) [inline, protected, virtual]

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

KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData
KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData KFbxLayerElementUserData