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

KFbxLayerElementTemplate< 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 KFbxLayerElementTemplate< Type >

This class complements the KFbxLayerElement class.

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

Definition at line 1052 of file kfbxlayer.h.

#include <kfbxlayer.h>

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

List of all members.

Public Types

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

Public Member Functions

KFbxLayerElementArrayTemplate
< Type > & 
GetDirectArray () const
  Returns the direct array of Layer Elements.
KFbxLayerElementArrayTemplate
< Type > & 
GetDirectArray ()
  Returns the direct array of Layer Elements.
KFbxLayerElementArrayTemplate
< int > & 
GetIndexArray () const
  Returns the index array of Layer Elements.
KFbxLayerElementArrayTemplate
< int > & 
GetIndexArray ()
  Returns the index array of Layer Elements.
bool  Clear ()
  Removes all elements from the direct and the index arrays.
bool  operator== (const KFbxLayerElementTemplate &pOther) const
  Equivalence operator.
KFbxLayerElementTemplate operator= (KFbxLayerElementTemplate const &pOther)
  Assignment operator.
int  RemapIndexTo (KFbxLayerElement::EMappingMode pNewMapping)
  Changes the Mapping mode to the new one and re-computes the index array.
virtual int  MemorySize () const
  Queries the amount of memory used by this object AND its content (does not consider the content pointed)

Public Attributes

KFbxLayerElementArrayTemplate
< Type > * 
mDirectArray
KFbxLayerElementArrayTemplate
< int > * 
mIndexArray

Protected Member Functions

  KFbxLayerElementTemplate ()
  ~KFbxLayerElementTemplate ()
virtual void  AllocateArrays ()

Serialization section

virtual bool  ContentWriteTo (KFbxStream &pStream) const
  Writes the content of this layer element to the given stream.
virtual bool  ContentReadFrom (const KFbxStream &pStream)
  Reads the content of this layer element from the given stream.

Member Typedef Documentation

typedef Type ArrayElementType

Definition at line 1321 of file kfbxlayer.h.

Definition at line 1322 of file kfbxlayer.h.

Definition at line 1323 of file kfbxlayer.h.


Constructor & Destructor Documentation

KFbxLayerElementTemplate ( ) [inline, protected]

Definition at line 1216 of file kfbxlayer.h.

~KFbxLayerElementTemplate ( ) [inline, protected]

Definition at line 1222 of file kfbxlayer.h.


Member Function Documentation

KFbxLayerElementArrayTemplate<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 mapping mode is set to eINDEX.

Definition at line 1060 of file kfbxlayer.h.

KFbxLayerElementArrayTemplate<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 mapping mode is set to eINDEX.

Definition at line 1070 of file kfbxlayer.h.

KFbxLayerElementArrayTemplate<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 1080 of file kfbxlayer.h.

KFbxLayerElementArrayTemplate<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 1090 of file kfbxlayer.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 KFbxLayerElement.

Reimplemented in KFbxLayerElementUserData.

Definition at line 1100 of file kfbxlayer.h.

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

Equivalence operator.

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

Definition at line 1118 of file kfbxlayer.h.

    {
        bool ret = true;

        if (pOther.GetReferenceMode() == KFbxLayerElement::eDIRECT || 
            pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
        {
            const KFbxLayerElementArrayTemplate<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() == KFbxLayerElement::eINDEX || 
                pOther.GetReferenceMode()  == KFbxLayerElement::eINDEX_TO_DIRECT)
            {
                const KFbxLayerElementArrayTemplate<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 KFbxLayerElement::operator==(pOther);
    }
KFbxLayerElementTemplate& operator= ( KFbxLayerElementTemplate< Type > const &  pOther ) [inline]

Assignment operator.

Parameters:
pOther Another element assigned to this one

Definition at line 1168 of file kfbxlayer.h.

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

        if (pOther.GetReferenceMode() == KFbxLayerElement::eDIRECT || 
            pOther.GetReferenceMode() == KFbxLayerElement::eINDEX_TO_DIRECT)
        {
            const KFbxLayerElementArrayTemplate<Type>& directArray = pOther.GetDirectArray();
            *mDirectArray = directArray;
        }

        if (pOther.GetReferenceMode() == KFbxLayerElement::eINDEX || 
            pOther.GetReferenceMode()  == KFbxLayerElement::eINDEX_TO_DIRECT)
        {
            const KFbxLayerElementArrayTemplate<int>& indexArray = pOther.GetIndexArray();
            *mIndexArray = indexArray;
        }
        
        KFbxLayerElement* myself = (KFbxLayerElement*)this;
        KFbxLayerElement* myOther = (KFbxLayerElement*)&pOther;
        *myself = *myOther;
        return *this; 
    }
int RemapIndexTo ( KFbxLayerElement::EMappingMode  pNewMapping ) [inline]

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

Parameters:
pNewMapping New 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 1200 of file kfbxlayer.h.

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

Reimplemented in KFbxLayerElementMaterial, and KFbxLayerElementUserData.

Definition at line 1228 of file kfbxlayer.h.

    {
        mDirectArray = FbxSdkNew< KFbxLayerElementArrayTemplate<Type> >(mType->GetType());
        mIndexArray = FbxSdkNew< KFbxLayerElementArrayTemplate<int> >(DTInteger.GetType());
    }
virtual int MemorySize ( ) const [inline, virtual]

Queries the amount of memory used by this object AND its content (does not consider the content pointed)

Returns:
The amount of memory used.

Reimplemented from KFbxLayerElement.

Reimplemented in KFbxLayerElementUserData.

Definition at line 1235 of file kfbxlayer.h.

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

Writes the content of this layer element to the given stream.

Parameters:
pStream The destination stream.
Returns:
True if the content is successfully processed by the receiving stream, false otherwise.

Reimplemented from KFbxLayerElement.

Definition at line 1247 of file kfbxlayer.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();
            K_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();
            K_ASSERT(a != NULL);
            v = count*sizeof(int);
            s = pStream.Write(a, v);
            mIndexArray->Release(&a);
            if (s != v) return false;
        }

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

Reads the content of this layer element from the given stream.

Parameters:
pStream The source stream.
Returns:
True if the object fills itself with the received data from the stream successfully, false otherwise.

Reimplemented from KFbxLayerElement.

Definition at line 1284 of file kfbxlayer.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();
            K_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();
            K_ASSERT(a != NULL);
            v = count*sizeof(int);
            s = pStream.Read(a, v);
            mIndexArray->Release(&a);
            if (s != v) return false;
        }
        return KFbxLayerElement::ContentReadFrom(pStream);
    }

Member Data Documentation

Definition at line 1325 of file kfbxlayer.h.

Definition at line 1326 of file kfbxlayer.h.


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