Public Member Functions
CICEAttributeDataArrayCustomType Class Reference

Detailed Description

This class is a specialization of CICEAttributeDataArray to give access to the ICEAttribute data as a 1D array of type siICENodeDataCustomType. CICEAttributeDataArrayCustomType objects are read-only and can be filled with the methods supplied with the ICEAttribute class.

Note:
Data of type siICENodeDataCustomType can be created with custom ICENodes.
See also:
ICEAttribute::GetDataArray, ICEAttribute::GetDataArrayChunk, CICEAttributeDataArray2DCustomType, Type Definitions for CICEAttributeDataArray
Since:
8.0 (2010)
Example:
This example demonstrates how to iterate over the siICENodeDataCustomType attributes on a geometry. Check out the SDK InspectICEAttributes sample for a more detailed example.
        using namespace XSI;

        Application app;
        X3DObject x3dObj = app.GetSelection().GetItem(0);
        ICEAttribute attr = x3dObj.GetActivePrimitive().GetGeometry().GetICEAttributeFromName( L"SomeCustomDataTypeAttribute" );

        // Log the data pointer address and size of data.
        CICEAttributeDataArrayCustomType customData;
        attr.GetDataArray( customData );

        for( ULONG i=0; i<customData.GetCount( ); i++ )
        {
            ULONG nSize;
            const CICEAttributeDataArrayCustomType::TData* pBuffer;
            customData.GetData( i, &pBuffer, nSize );

            app.LogMessage( CString( (void*)pBuffer ) + L":" + CString( nSize ) );
        }

#include <xsi_iceattributedataarray.h>

Inheritance diagram for CICEAttributeDataArrayCustomType:
Inheritance graph
[legend]

List of all members.

Public Member Functions

SICPPSDK_INLINE CICEAttributeDataArrayCustomType ()
SICPPSDK_INLINE ~CICEAttributeDataArrayCustomType ()
SICPPSDK_INLINE CStatus GetData (ULONG in_index, const TData **out_ppData, ULONG &out_nSize) const
CStatus SetArray (const TData **in_ppData, ULONG in_count, ULONG in_fixedElemSize)
CStatus SetArray (const TData **in_ppData, ULONG in_count, ULONG *in_pElementSizes)

Constructor & Destructor Documentation

SICPPSDK_INLINE CICEAttributeDataArrayCustomType ( ) [inline]

Default Constructor.

SICPPSDK_INLINE ~CICEAttributeDataArrayCustomType ( ) [inline]

Destructor.


Member Function Documentation

CStatus GetData ( ULONG  in_index,
const TData **  out_ppData,
ULONG &  out_nSize 
) const

Returns a pointer to the user data stored at a specific index. The data is read-only and cannot be modified.

Note:
The memory allocated for the data returned by CICEAttributeDataArrayCustomType::GetData is only available within the scope of this CICEAttributeDataArrayCustomType instance. Make sure to make a copy of the data if you need to access it outside the scope of CICEAttributeDataArrayCustomType.
Parameters:
in_indexArray index of the user data to retrieve. The size is 0 if no data is stored at this index.
Return values:
out_ppDataRead-only pointer to the data.
out_nSizeSize in bytes of the user data.
Returns:
Success/failure
CStatus SetArray ( const TData **  in_ppData,
ULONG  in_count,
ULONG  in_fixedElemSize 
)

Set the values in the custom-typed data array

Parameters:
in_ppDataThe input custom-typed array. All elements must have the same size.
in_countNumber of elements in the input array
in_fixedElemSizeThe fixed size of all elements
Returns:
CStatus::OK Success.
CStatus::Fail Operation failed.
Since:
12.0 (2014)
Example:
This example demonstrates how to set the whole CustomType array
        // Data structure holding the states for each particule
        struct GridWalkerState
        {
            ULONG m_nRandomSequencePosition;
            ULONG m_nCurrentStep;

            LONG m_nCurrentPositionX, m_nCurrentPositionY;
            LONG m_nDirectionX, m_nDirectionY;

            GridWalkerState()
            {
                m_nRandomSequencePosition = 0;
                m_nCurrentStep = 0;

                m_nCurrentPositionX = 0;
                m_nCurrentPositionY = 0;
                m_nDirectionX = 0;
                m_nDirectionY = 0;
            }

            GridWalkerState(    ULONG in_nRandomSequencePosition,
                                        ULONG in_nCurrentStep,

                                        ULONG in_nCurrentPositionX,
                                        ULONG in_nCurrentPositionY,
                                        ULONG in_nDirectionX,
                                        ULONG in_nDirectionY)
            {
                m_nRandomSequencePosition = in_nRandomSequencePosition;
                m_nCurrentStep =            in_nCurrentStep;

                m_nCurrentPositionX =   in_nCurrentPositionX;
                m_nCurrentPositionY =   in_nCurrentPositionY;
                m_nDirectionX =         in_nDirectionX;
                m_nDirectionY =         in_nDirectionY;
            }

            const GridWalkerState& operator=(const GridWalkerState& other)
            {
                m_nRandomSequencePosition = other.m_nRandomSequencePosition;
                m_nCurrentStep =            other.m_nCurrentStep;

                m_nCurrentPositionX =   other.m_nCurrentPositionX;
                m_nCurrentPositionY =   other.m_nCurrentPositionY;
                m_nDirectionX =         other.m_nDirectionX;
                m_nDirectionY =         other.m_nDirectionY;

                return *this;
            }

            operator CString() const
            {
                CString result;
                result = L"[";
                result += L"Random Sequence Pos:";
                result += CString(m_nRandomSequencePosition) + CString(L", ");
            
                result += L"Step:";
                result += CString(m_nCurrentStep) + L", ";

                result += L"X:";
                result += CString(m_nCurrentPositionX) + L", ";

                result += L"Y:";
                result += CString(m_nCurrentPositionY) + L", ";

                result += L"Dir X:";
                result += CString(m_nDirectionX) + L", ";

                result += L"Dir Y:";
                result += CString(m_nDirectionY);

                result += L"]";
                return result;
            }
        };

        template < class CustomType >
        class CICEAttributeDataLoggerCustomType
        {
        public:
            static void Log( ICEAttribute& attr )
            {
                CICEAttributeDataArrayCustomType data;
                attr.GetDataArray( data );

                Application xsi;
                for( ULONG i=0; i<data.GetCount( ); i++ )
                {
                    CustomType val;
                    const CICEAttributeDataArrayCustomType::TData* addr = NULL;
                    ULONG size=0;
                    data.GetData(i, &addr, size);

                    if (addr != NULL && size>0)
                    {
                        val = *(CustomType*)addr;
                        xsi.LogMessage( CString(val) );
                    }
                }
            }
        };

        Application app;

        // Loads the GridWalker custom node plug-in from the examples workgroup 
        CString strWrkgrp = CUtils::BuildPath( app.GetInstallationPath(siFactoryPath ), "..", "..", "Rayflex", "Sdk", "examples", "workgroup" );
        app.AddWorkgroup( strWrkgrp  );

        // Opens the GridWalker scene containing custom data types 
        CValueArray args(2);
        CValue retval;
        args[0] = CUtils::BuildPath( strWrkgrp, "Addons", "CustomICENodes", "Data", "Project", "Scenes", "GridWalker" ) + ".scn";
        args[1] = false;
        app.ExecuteCommand( "OpenScene", args, retval );

        // Logs custom data type
        CStringArray strNoFamily;
        CString strNoType;
        Geometry geom( app.GetActiveSceneRoot().FindChild("grid", strNoType, strNoFamily).GetActivePrimitive().GetGeometry() );
        ICEAttribute attr = geom.GetICEAttributeFromName( "GridWalkerState" );

        {
            typedef GridWalkerState* CustomTypePtr;

            CICEAttributeDataArrayCustomType data;
            attr.GetDataArray( data );

            CICEAttributeDataLoggerCustomType<GridWalkerState>::Log( attr );

            ULONG l_nbElem = attr.GetElementCount();

            {
                CustomTypePtr* l_Values = new CustomTypePtr[l_nbElem];

                for (ULONG i=0; i<l_nbElem; i++)
                {
                    if (i%2==0)
                        l_Values[i] = new GridWalkerState(0, 0, 0, 0, 0, 0);
                    else
                        l_Values[i] = new GridWalkerState(1, 1, 1, 1, 1, 1);
                }

                data.SetArray((const unsigned char**)l_Values, l_nbElem, sizeof(GridWalkerState));
            
                CICEAttributeDataLoggerCustomType<GridWalkerState>::Log( attr );

                for (ULONG i=0; i<l_nbElem; i++)
                {
                    delete l_Values[i];
                }

                delete[] l_Values;
            }

            {
                const ULONG CHUNK_SIZE = 10;
                CustomTypePtr* l_Values = new CustomTypePtr[CHUNK_SIZE];

                for (ULONG i=0; i<CHUNK_SIZE; i++)
                {
                    l_Values[i] = new GridWalkerState(i + 2, i + 2, i + 2, i + 2, i + 2, i + 2);
                }

                CICEAttributeDataArrayCustomType dataChunk;
                attr.GetDataArrayChunk(2, CHUNK_SIZE, dataChunk);

                data.SetArray((const unsigned char**)l_Values, CHUNK_SIZE, sizeof(GridWalkerState));

                CICEAttributeDataLoggerCustomType<GridWalkerState>::Log( attr );

                for (ULONG i=0; i<CHUNK_SIZE; i++)
                {
                    delete l_Values[i];
                }

                delete[] l_Values;
            }

        }
CStatus SetArray ( const TData **  in_ppData,
ULONG  in_count,
ULONG *  in_pElementSizes 
)

Set the values in the custom-typed data array

Parameters:
in_ppDataInput custom-typed array. The element sizes can vary.
in_countNumber of elements in the input array
in_pElementSizesArray specifying the sizes of the elements.
Returns:
CStatus::OK Success.
CStatus::Fail Operation failed.
Since:
12.0 (2014)

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