Public Types | Public Member Functions | Public Attributes | Protected Member Functions

FbxLayerElementTemplate< Type > Class Template Reference

This reference page is linked to from the following overview topics: Meshes, List of Python Fbx classes.


Search for all occurrences

Detailed Description

template<class Type>
class FbxLayerElementTemplate< Type >

This class complements the FbxLayerElement class.

It provides interfaces to access the direct array and index array of different layer elements.

Definition at line 987 of file fbxlayer.h.

#include <fbxlayer.h>

Inheritance diagram for FbxLayerElementTemplate< Type >:
Inheritance graph
[legend]

List of all members.

Public Types

typedef Type ArrayElementType
typedef
FbxLayerElementArrayTemplate
< Type > 
DirectArrayType
typedef
FbxLayerElementArrayTemplate
< int > 
IndexArrayType

Public Member Functions

FbxLayerElementArrayTemplate
< Type > & 
GetDirectArray () const
 Returns the direct array of Layer Elements.
FbxLayerElementArrayTemplate
< Type > & 
GetDirectArray ()
 Returns the direct array of Layer Elements.
FbxLayerElementArrayTemplate
< int > & 
GetIndexArray () const
 Returns the index array of Layer Elements.
FbxLayerElementArrayTemplate
< int > & 
GetIndexArray ()
 Returns the index array of Layer Elements.
bool Clear ()
 Removes all elements from the direct and the index arrays.
bool operator== (const FbxLayerElementTemplate &pOther) const
 Equivalence operator.
FbxLayerElementTemplateoperator= (FbxLayerElementTemplate const &pOther)
 Assignment operator.
int RemapIndexTo (FbxLayerElement::EMappingMode pNewMapping)
 Changes the Mapping mode to the new one and re-computes the index array.
virtual int MemorySize () const

Public Attributes

FbxLayerElementArrayTemplate
< Type > * 
mDirectArray
FbxLayerElementArrayTemplate
< int > * 
mIndexArray

Protected Member Functions

 FbxLayerElementTemplate ()
 ~FbxLayerElementTemplate ()
virtual void AllocateArrays ()

Serialization section

virtual bool ContentWriteTo (FbxStream &pStream) const
virtual bool ContentReadFrom (const FbxStream &pStream)

Member Typedef Documentation

typedef Type ArrayElementType

Definition at line 1250 of file fbxlayer.h.

Definition at line 1251 of file fbxlayer.h.

Definition at line 1252 of file fbxlayer.h.


Constructor & Destructor Documentation

FbxLayerElementTemplate ( ) [inline, protected]

Definition at line 1145 of file fbxlayer.h.

~FbxLayerElementTemplate ( ) [inline, protected]

Definition at line 1151 of file fbxlayer.h.


Member Function Documentation

FbxLayerElementArrayTemplate<Type>& GetDirectArray ( ) const [inline]

Returns the direct array of Layer Elements.

Returns:
A reference to the Layer Elements direct array.
Remarks:
You cannot put elements in the direct array when the reference mode is set to eIndex.

Definition at line 995 of file fbxlayer.h.

FbxLayerElementArrayTemplate<Type>& GetDirectArray ( ) [inline]

Returns the direct array of Layer Elements.

Returns:
A reference to the Layer Elements direct array.
Remarks:
You cannot put elements in the direct array when the reference mode is set to eIndex.

Definition at line 1005 of file fbxlayer.h.

FbxLayerElementArrayTemplate<int>& GetIndexArray ( ) const [inline]

Returns the index array of Layer Elements.

Returns:
A reference to the index array.
Remarks:
You cannot put elements in the index array when the mapping mode is set to eDirect.

Definition at line 1015 of file fbxlayer.h.

FbxLayerElementArrayTemplate<int>& GetIndexArray ( ) [inline]

Returns the index array of Layer Elements.

Returns:
A reference to the index array.
Remarks:
You cannot put elements in the index array when the mapping mode is set to eDirect.

Definition at line 1025 of file fbxlayer.h.

bool Clear ( ) [inline, virtual]

Removes all elements from the direct and the index arrays.

Remarks:
This function fails if there is a lock on the arrays.
Returns:
True if successful, false if a lock is present.

Reimplemented from FbxLayerElement.

Reimplemented in FbxLayerElementUserData.

Definition at line 1035 of file fbxlayer.h.

bool operator== ( const FbxLayerElementTemplate< Type > &  pOther) const [inline]

Equivalence operator.

Parameters:
pOtherAnother element compared to this object
Returns:
True if equal, false if unequal.

Definition at line 1053 of file fbxlayer.h.

    {
        bool ret = true;

        if (pOther.GetReferenceMode() == FbxLayerElement::eDirect || 
            pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
        {
            const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
            if( directArray.GetCount() != mDirectArray->GetCount() || 
                !directArray.ReadLock() || !mDirectArray->ReadLock() )
            {
                ret = false;
            }

            if( ret && !mDirectArray->IsEqual(directArray) )
                ret = false;

            directArray.ReadUnlock();
            mDirectArray->ReadUnlock();
        }

        if (ret)
        {
            if (pOther.GetReferenceMode() == FbxLayerElement::eIndex || 
                pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect)
            {
                const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
                if( indexArray.GetCount() != mIndexArray->GetCount() ||
                    !indexArray.ReadLock() || !mIndexArray->ReadLock() )
                {
                    ret = false;
                }

                if( ret && !mIndexArray->IsEqual(indexArray) )
                    ret = false;

                indexArray.ReadUnlock();
                mIndexArray->ReadUnlock();
            }
        }

        if (ret == false)
            return false;

        return FbxLayerElement::operator==(pOther);
    }
FbxLayerElementTemplate& operator= ( FbxLayerElementTemplate< Type > const &  pOther) [inline]

Assignment operator.

Parameters:
pOtherAnother element assigned to this one

Definition at line 1103 of file fbxlayer.h.

    {
        FBX_ASSERT(mDirectArray != NULL);
        FBX_ASSERT(mIndexArray != NULL);

        if (pOther.GetReferenceMode() == FbxLayerElement::eDirect || 
            pOther.GetReferenceMode() == FbxLayerElement::eIndexToDirect)
        {
            const FbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
            *mDirectArray = directArray;
        }

        if (pOther.GetReferenceMode() == FbxLayerElement::eIndex || 
            pOther.GetReferenceMode()  == FbxLayerElement::eIndexToDirect)
        {
            const FbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
            *mIndexArray = indexArray;
        }
        
        FbxLayerElement* myself = (FbxLayerElement*)this;
        FbxLayerElement* myOther = (FbxLayerElement*)&pOther;
        *myself = *myOther;
        return *this; 
    }
int RemapIndexTo ( FbxLayerElement::EMappingMode  pNewMapping) [inline]

Changes the Mapping mode to the new one and re-computes the index array.

Parameters:
pNewMappingNew mapping mode.
Returns:
If the remapping is successful, returns 1. If an error occurs, returns 0. In case the function cannot remap to the desired mode because of incompatible modes or unsupported modes, returns -1.

Definition at line 1135 of file fbxlayer.h.

    {
        return RemapIndexArrayTo(this, pNewMapping, mIndexArray);
    }
virtual void AllocateArrays ( ) [inline, protected, virtual]

Reimplemented in FbxLayerElementMaterial, and FbxLayerElementUserData.

Definition at line 1157 of file fbxlayer.h.

    {
        mDirectArray = FbxNew< FbxLayerElementArrayTemplate<Type> >(mType->GetType());
        mIndexArray = FbxNew< FbxLayerElementArrayTemplate<int> >(FbxIntDT.GetType());
    }
virtual int MemorySize ( ) const [inline, virtual]

Reimplemented from FbxLayerElement.

Reimplemented in FbxLayerElementUserData, and FbxLayerElementTexture.

Definition at line 1164 of file fbxlayer.h.

    {
        int size = FbxLayerElement::MemorySize();
        size += (mDirectArray->GetCount()*sizeof(Type));
        size += (mIndexArray->GetCount()*sizeof(int));
        return size;
    }
virtual bool ContentWriteTo ( FbxStream pStream) const [inline, virtual]

Reimplemented from FbxLayerElement.

Definition at line 1176 of file fbxlayer.h.

    {
        void* a;
        int s,v;
        int count = 0;

        // direct array
        count = mDirectArray->GetCount();
        s = pStream.Write(&count, sizeof(int)); 
        if (s != sizeof(int)) return false;
        if (count > 0)
        {
            a = mDirectArray->GetLocked();
            FBX_ASSERT(a != NULL);
            v = count*sizeof(Type);
            s = pStream.Write(a, v); 
            mDirectArray->Release(&a);
            if (s != v) return false;
        }

        // index array
        count = mIndexArray->GetCount();
        s = pStream.Write(&count, sizeof(int)); 
        if (s != sizeof(int)) return false;
        if (count > 0)
        {
            a = mIndexArray->GetLocked();
            FBX_ASSERT(a != NULL);
            v = count*sizeof(int);
            s = pStream.Write(a, v);
            mIndexArray->Release(&a);
            if (s != v) return false;
        }

        return FbxLayerElement::ContentWriteTo(pStream);
    }
virtual bool ContentReadFrom ( const FbxStream pStream) [inline, virtual]

Reimplemented from FbxLayerElement.

Definition at line 1213 of file fbxlayer.h.

    {
        void* a;
        int s,v;
        int count = 0;

        // direct array
        s = pStream.Read(&count, sizeof(int)); 
        if (s != sizeof(int)) return false;
        mDirectArray->Resize(count);
        if (count > 0)
        {
            a = mDirectArray->GetLocked();
            FBX_ASSERT(a != NULL);
            v = count*sizeof(Type);
            s = pStream.Read(a, v); 
            mDirectArray->Release(&a);
            if (s != v) return false;
        }

        // index array
        s = pStream.Read(&count, sizeof(int)); 
        if (s != sizeof(int)) return false;
        mIndexArray->Resize(count);     
        if (count > 0)
        {
            a = mIndexArray->GetLocked();
            FBX_ASSERT(a != NULL);
            v = count*sizeof(int);
            s = pStream.Read(a, v);
            mIndexArray->Release(&a);
            if (s != v) return false;
        }
        return FbxLayerElement::ContentReadFrom(pStream);
    }

Member Data Documentation

Definition at line 1254 of file fbxlayer.h.

Definition at line 1255 of file fbxlayer.h.


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