# CDataArray2D Class Template Reference

This template class encapsulates 2D data arrays that are passed to custom node plug-ins during a graph evaluation. The underlying data arrays are zero-based, the following types are available:. More...

`#include <xsi_dataarray2D.h>`

List of all members.

## Public Types
typedef T | TData
| TData is the underlying data type of a CDataArray2D instance. Possible values are:.
## Public Member Functions
SICPPSDK_INLINE | CDataArray2D (ICENodeContext &in_ctxt, ULONG in_nInputPortID, ULONG in_nInstanceIndex=0)
SICPPSDK_INLINE | CDataArray2D (ICENodeContext &in_ctxt)
SICPPSDK_INLINE | ~CDataArray2D ()
SICPPSDK_INLINE Accessor | operator[] (ULONG in_nArrayIndex) const
SICPPSDK_INLINE Accessor | Resize (ULONG in_nArrayIndex, ULONG in_nSize)
SICPPSDK_INLINE ULONG | GetCount () const
SICPPSDK_INLINE bool | IsConstant () const
## Classes
class | Accessor
| A class for accessing the sub-array data of CDataArray2D objects. More...

## Detailed Description

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

This template class encapsulates 2D data arrays that are passed to custom node plug-ins during a graph evaluation. The underlying data arrays are zero-based, the following types are available:.

- CDataArray2DFloat
- CDataArray2DLong
- CDataArray2DBool
- CDataArray2DVector2f
- CDataArray2DVector3f
- CDataArray2DVector4f
- CDataArray2DQuaternionf
- CDataArray2DRotationf
- CDataArray2DMatrix3f
- CDataArray2DMatrix4f
- CDataArray2DColor4f
- CDataArray2DShape

As for CDataArray, instances of CDataArray2D are created based on the current evaluation context and a specific port type (input ports only). CDataArray2D objects are also indexed with CIndexSet objects. Unlike CDataArray, CDataArray2D contains sub-arrays where data can be accessed through the CDataArray2D::Accessor class.

Note:
  If the class type doesn't match the port data type being evaluated, an error occurs at run-time and a class instance is created with an empty array.

See also:
  CDataArray2D, CIndexSet, ICENodeDef, Type Definitions for CDataArray2D

Since:
  7.0

Example:

              using namespace XSI;

              XSIPLUGINCALLBACK CStatus Custom2DArray_Evaluate( ICENodeContext& in_ctxt )
              {
                  // The current output port being evaluated...
                  ULONG out_portID = in_ctxt.GetEvaluatedOutputPortID( );

                  switch( out_portID )
                  {
                      case ID_OutPort:
                      {
                          // Here's how we access the input data buffers for each port
                          CDataArray2DVector3f InPortData( in_ctxt, ID_InPort );

                          // Declare the output port array ...
                          CDataArray2DVector3f outData( in_ctxt );

                          // We need a CIndexSet to iterate over the data
                          CIndexSet indexSet( in_ctxt );

                          for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next())
                          {
                              // Creates an Accessor object to iterate over the 2D array data
                              CDataArray2DVector3f::Accessor floatArray = InPortData[it];

                              // Output arrays must always be initialized first
                              CDataArray2DVector3f::Accessor outAccessor = outData.Resize( it, floatArray.GetCount( ) );

                              for (ULONG i=0; i<floatArray.GetCount( ); i++)
                              {
                                  outAccessor[i].Scale( floatArray[i].GetX(), floatArray[i] );
                              }
                          }
                      }
                      break;
                  };

                  return CStatus::OK;
              }

## Member Typedef Documentation

T TData

TData is the underlying data type of a CDataArray2D instance. Possible values are:.

- float
- LONG
- bool
- CVector2f
- CVector3f
- CVector4f
- CQuaternionf
- CRotationf
- CMatrix3f
- CMatrix4f
- CColor4f
- CShape

## Constructor & Destructor Documentation

SICPPSDK_INLINE CDataArray2D | ( | ICENodeContext & | in_ctxt,
|  | ULONG | in_nInputPortID,
|  | ULONG | in_nInstanceIndex = `0` |
| ) |  |  |

Constructor for data types bound to input ports.

Parameters:

  | in_ctxt | ICENode evaluation context.
  | in_nInputPortID | Input port identifier.
  | in_nInstanceIndex | The group instance of the port.

SICPPSDK_INLINE CDataArray2D | ( | ICENodeContext & | in_ctxt | ) |

Constructor for data types bound to output ports.

Parameters:

  | in_ctxt | ICENode evaluation context.

SICPPSDK_INLINE ~CDataArray2D | ( |  | ) |

Destructor.

## Member Function Documentation

SICPPSDK_INLINE CDataArray2D< T >::Accessor operator[] | ( | ULONG | in_nArrayIndex | ) | const

Returns an accessor at a given index. This operator is called when reading the data so the return value is read-only.

Parameters:

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

Returns:
  Accessor object.

SICPPSDK_INLINE CDataArray2D< T >::Accessor Resize | ( | ULONG | in_nArrayIndex,
|  | ULONG | in_nSize |
| ) |  |  |

Changes the size of the sub-array at a given position and returns an accessor pointing to the resized sub-array.

Parameters:

  | in_nArrayIndex | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredicted.
  | in_nSize | The new size.

Returns:
  Accessor object.

SICPPSDK_INLINE ULONG GetCount | ( |  | ) | const

Returns the number of elements in the array.

Returns:
  Number of elements.

SICPPSDK_INLINE bool IsConstant | ( |  | ) | const

Returns true if the array is constant or false otherwise. A constant array has only one value.

Returns:
  True if constant, false otherwise.

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

- xsi_dataarray2D.h