- Main Page
- Classes
- Files
- Directories
- Examples

- Class List
- Class Hierarchy
- Class Members

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 1029 of file fbxlayer.h.

`#include <fbxlayer.h>`

Inheritance diagram for FbxLayerElementTemplate< Type >:
[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.
FbxLayerElementTemplate & | operator= (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
| Queries the amount of memory used by this object AND its content (does not consider the content pointed)
## Public Attributes
FbxLayerElementArrayTemplate < Type > * | mDirectArray
FbxLayerElementArrayTemplate < int > * | mIndexArray
## Protected Member Functions
| FbxLayerElementTemplate ()
| ~FbxLayerElementTemplate ()
virtual void | AllocateArrays ()
## Serialization section
virtual bool | ContentWriteTo (FbxStream &pStream) const
| Writes the content of this layer element to the given stream.
virtual bool | ContentReadFrom (const FbxStream &pStream)
| Reads the content of this layer element from the given stream.

## Member Typedef Documentation

typedef Type ArrayElementType

Search for all occurrences

Definition at line 1298 of file fbxlayer.h.

typedef FbxLayerElementArrayTemplate<Type> DirectArrayType

Search for all occurrences

Definition at line 1299 of file fbxlayer.h.

typedef FbxLayerElementArrayTemplate<int> IndexArrayType

Search for all occurrences

Definition at line 1300 of file fbxlayer.h.

## Constructor & Destructor Documentation

FbxLayerElementTemplate | ( |  | ) | `[inline, protected]`

Definition at line 1193 of file fbxlayer.h.

        {
            mDirectArray = NULL;
            mIndexArray = NULL;
        }

~FbxLayerElementTemplate | ( |  | ) | `[inline, protected]`

Definition at line 1199 of file fbxlayer.h.

        {
            FbxDelete(mDirectArray);
            FbxDelete(mIndexArray);
        }

## Member Function Documentation

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

Search for all occurrences

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 1037 of file fbxlayer.h.

        {
            FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
            return *mDirectArray;
        }

FbxLayerElementArrayTemplate<Type>& GetDirectArray | ( |  | ) | `[inline]`

Search for all occurrences

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 1047 of file fbxlayer.h.

        {
            FBX_ASSERT(mReferenceMode == FbxLayerElement::eDirect || mReferenceMode == FbxLayerElement::eIndexToDirect);
            return *mDirectArray;
        }

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

Search for all occurrences

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 1057 of file fbxlayer.h.

        {
            FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
            return *mIndexArray;
        }

FbxLayerElementArrayTemplate<int>& GetIndexArray | ( |  | ) | `[inline]`

Search for all occurrences

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 1067 of file fbxlayer.h.

        {
            FBX_ASSERT(mReferenceMode == FbxLayerElement::eIndex || mReferenceMode == FbxLayerElement::eIndexToDirect);
            return *mIndexArray;
        }

bool Clear | ( |  | ) | `[inline, virtual]`

Search for all occurrences

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 1077 of file fbxlayer.h.

        {
            bool ret = true;
            mDirectArray->Clear();
            ret = (mDirectArray->GetStatus() == LockAccessStatus::eSuccess);

            mIndexArray->Clear();
            ret |= (mIndexArray->GetStatus() == LockAccessStatus::eSuccess);

            return ret;
        }

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

Equivalence operator.

Parameters:

  pOther | Another element compared to this object

Returns:
  `True` if equal, `false` if unequal.

Definition at line 1095 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:

  pOther | Another element assigned to this one

Definition at line 1145 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]`

Search for all occurrences

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 1177 of file fbxlayer.h.

        {
            return RemapIndexArrayTo(this, pNewMapping, mIndexArray);
        }

virtual void AllocateArrays | ( |  | ) | `[inline, protected, virtual]`

Search for all occurrences

Reimplemented in FbxLayerElementMaterial, and FbxLayerElementUserData.

Definition at line 1205 of file fbxlayer.h.

        {
            mDirectArray = FbxNew< FbxLayerElementArrayTemplate<Type> >(mType->GetType());
            mIndexArray = FbxNew< FbxLayerElementArrayTemplate<int> >(FbxIntDT.GetType());
        }

virtual int MemorySize | ( |  | ) | const `[inline, virtual]`

Search for all occurrences

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 FbxLayerElement.

Reimplemented in FbxLayerElementUserData.

Definition at line 1212 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]`

Search for all occurrences

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 FbxLayerElement.

Definition at line 1224 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]`

Search for all occurrences

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 FbxLayerElement.

Definition at line 1261 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

FbxLayerElementArrayTemplate<Type>* mDirectArray

Search for all occurrences

Definition at line 1302 of file fbxlayer.h.

FbxLayerElementArrayTemplate<int>* mIndexArray

Search for all occurrences

Definition at line 1303 of file fbxlayer.h.

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

- fbxsdk/scene/geometry/fbxlayer.h