Public Member Functions
CICEAttributeDataArray< T > Class Template Reference

## Detailed Description

### template<class T>
class XSI::CICEAttributeDataArray< T >

This template class encapsulates ICEAttribute data as a 1D array. CICEAttributeDataArray objects are read-only and can be filled with the methods supplied with the ICEAttribute class. CICEAttributeDataArray is zero-based and can be one of the following types:

- CICEAttributeDataArrayFloat
- CICEAttributeDataArrayLong
- CICEAttributeDataArrayBool
- CICEAttributeDataArrayVector2f
- CICEAttributeDataArrayVector3f
- CICEAttributeDataArrayVector4f
- CICEAttributeDataArrayQuaternionf
- CICEAttributeDataArrayRotationf
- CICEAttributeDataArrayMatrix3f
- CICEAttributeDataArrayMatrix4f
- CICEAttributeDataArrayColor4f
- CICEAttributeDataArrayShape

All types are associated to specific ICEAttribute types. Therefore, you need to declare the right array object type that matches the ICEAttribute data type you want to access. Otherwise a runtime error will occur and the returned array will be empty.

See also:
  ICEAttribute::GetDataArray, ICEAttribute::GetDataArrayChunk, Type Definitions for CICEAttributeDataArray

Since:
  7.0

Example:
  This example demonstrates how to iterate over the PointPosition attribute data on a grid primitive.

              using namespace XSI;
              CValue CreatePrim( const CString& in_presetobj, const CString& in_geometrytype, const CString& in_name, const CString& in_parent );

              X3DObject grid = CreatePrim( L"Grid", L"MeshSurface", L"", L"");

              ICEAttribute attr = grid.GetActivePrimitive().GetGeometry().GetICEAttributeFromName( L"PointPosition" );

              CICEAttributeDataArrayVector3f points;
              attr.GetDataArray( points );

              Application xsi;
              for( ULONG i=0; i<points.GetCount( ); i++ )
              {
                  xsi.LogMessage( CString( points[ i ] ) );
              }

              // Helper
              CValue CreatePrim( const CString& in_presetobj, const CString& in_geometrytype, const CString& in_name, const CString& in_parent )
              {
                  CValueArray args(4);
                  CValue retval;
                  args[0]= in_presetobj;
                  args[1]= in_geometrytype;
                  args[2]= in_name;
                  args[3]= in_parent;

                  Application app;
                  app.ExecuteCommand( L"CreatePrim", args, retval );
                  return retval;
              }

`#include <xsi_iceattributedataarray.h>`

Inheritance diagram for CICEAttributeDataArray< T >:
[legend]

List of all members.

## Public Member Functions
| CICEAttributeDataArray ()
| ~CICEAttributeDataArray ()
const T & | operator[] (ULONG in_index) const
T & | operator[] (ULONG in_index)
CStatus | SetData (ULONG in_index, const T &in_value)
CStatus | SetArray (const T *in_pArray, ULONG in_count)

## Constructor & Destructor Documentation

CICEAttributeDataArray | ( |  | ) | `[inline]`

Constructor.

~CICEAttributeDataArray | ( |  | ) | `[inline]`

Destructor.

## Member Function Documentation

const T& operator[] | ( | ULONG | in_index | ) | const`[inline]`

Accessor to the encapsulated array. This operator is called when reading the data so the return value is read-only.

Parameters:

  in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable. If the array is constant, the function always return the first item's value.

Returns:
  A read-only reference to the indexed item.

T& operator[] | ( | ULONG | in_index | ) | `[inline]`

Accessor to the encapsulated array. This operator is used for writing to the data array.

Parameters:

  in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable.

Returns:
  A reference to the indexed item.

Since:
  11.0 (2013)

CStatus SetData | ( | ULONG | in_index,
|  | const T & | in_value
| ) |  |

Accessor to the encapsulated array for writing to the data array.

Parameters:

  in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable.

Returns:
  CStatus::OK Success.
  CStatus::InvalidArgument Index out of range.
  CStatus::AccessDenied Array is read-only.
  CStatus::Fail Attribute is undefined or non-accessible

Since:
  12.0 (2014)

CStatus SetArray | ( | const T * | in_pArray,
|  | ULONG | in_count
| ) |  |

Set the values in the array

Parameters:

  in_pArray | Input data array.
  in_count | Number of elements in the input array

Returns:
  CStatus::OK Success.
  CStatus::Fail Operation failed.

Since:
  12.0 (2014)

Example:
  This example demonstrates how to set the whole array

              Application xsi;
              Model root = xsi.GetActiveSceneRoot();
              X3DObject cone( CreatePrim( L"cone", L"MeshSurface", L"", L"") );
              {
                  ICEAttribute attr = cone.GetActivePrimitive().GetGeometry().AddICEAttribute( "DataArrayLong", XSI::siICENodeDataLong, XSI::siICENodeStructureSingle, XSI::siICENodeContextComponent0D );

                  CString l_connSet(L"cone");
                  ApplyOp( L"ICETree", l_connSet, siConstructionModeModeling );

                  AddICECompoundNode("Set Data", "cone.polymsh.ICETree");
                  AddICENode("$XSI_DSPRESETS\\ICENodes\\GetDataNode.Preset", "cone.polymsh.ICETree");
                  SetValue("cone.polymsh.ICETree.SceneReferenceNode.reference", "self.DataArrayLong");
                  SetValue("cone.polymsh.ICETree.Set_Data.Reference", "self.foo");
                  ConnectICENodes("cone.polymsh.ICETree.Set_Data.Value", "cone.polymsh.ICETree.SceneReferenceNode.value");
                  ConnectICENodes("cone.polymsh.ICETree.port1", "cone.polymsh.ICETree.Set_Data.Execute");

                  DisplayPortValues("cone.polymsh.ICETree.Set_Data.Value", true, 0, true, "", 0, 0, 0, 1, false, true, 0.62, 1, 0.62, 1, false, 0, 10000, 1, false, false, 0, 10, false, true, false, 100);

                  CICEAttributeDataArray< LONG > data;
                  attr.GetDataArray( data );

                  CICEAttributeDataLogger< LONG >::Log( attr );
                  ULONG l_nbElem = attr.GetElementCount();

                  {
                      CLongArray l_Values(l_nbElem);

                      for (ULONG i=0; i<l_nbElem; i++)
                          l_Values[i] = (i%2==0) ? -1 : 1;

                      data.SetArray(l_Values.GetArray(), l_nbElem);

                      CICEAttributeDataLogger<LONG>::Log( attr );
                  }

                  data[0] = (LONG)5;
                  data[4] = (LONG)12;
              }

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

- xsi_iceattributedataarray.h