#include <xsi_dataarray2D.h>
Public Member Functions |
|
| Accessor () | |
| Accessor (const Accessor &in_accessor) | |
| Accessor & | operator= (const Accessor &in_accessor) |
| ULONG | GetCount () const |
| const T & | operator[] (ULONG in_nIndex) const |
| T & | operator[] (ULONG in_nIndex) |
| Accessor | ( | ) | [inline] |
Constructor.
Constructs an Accessor object from another Accessor object.
| in_accessor | constant Accessor object. |
Assignment operator.
| in_accessor | constant class object. |
| ULONG GetCount | ( | void | ) | const [inline] |
Returns the number of elements in the array.
| const T& operator[] | ( | ULONG | in_nIndex | ) | const [inline] |
Accessor to elements at a given index. This operator is called when reading the data so the return value is read-only.
| in_nIndex | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredicted. |
| T& operator[] | ( | ULONG | in_nIndex | ) | [inline] |
Accessor to elements at a given index. This operator can also be used to access and modify the sub-array stored at the in_nIndex position.
| in_nIndex | Index in this zero-based array. The index must be smaller than the number of elements in the array, otherwise the results are unpredicted. |
// Demonstrates how to access/modify the CDataArray2D<T> sub-arrays from the CDataArray2D<T>::Accessor class. using namespace XSI; XSIPLUGINCALLBACK CStatus UnionArrayNode_Evaluate( ICENodeContext& in_ctxt ) { // The current output port being evaluated... ULONG out_portID = in_ctxt.GetEvaluatedOutputPortID( ); switch( out_portID ) { case ID_OUT_result: { // Get the output port array ... CDataArray2DLong outData( in_ctxt ); // Get the input data buffers for each port CDataArray2DLong InArray1Data( in_ctxt, ID_IN_InArray1 ); CDataArray2DLong InArray2Data( in_ctxt, ID_IN_InArray2 ); // We need a CIndexSet to iterate over the data CIndexSet indexSet( in_ctxt ); for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next()) { CDataArray2DLong::Accessor a1 = InArray1Data[it]; CDataArray2DLong::Accessor a2 = InArray2Data[it]; // Sort arrays in place ULONG nCount1 = a1.GetCount(); ULONG nCount2 = a2.GetCount(); std::sort( &a1[0], &a1[0]+nCount1 ); std::sort( &a2[0], &a2[0]+nCount2 ); // Resize out to max array CDataArray2DLong::Accessor out = outData.Resize( it, nCount1 + nCount2 ); // Union of a1 + a2 LONG* pLast = std::set_union( &a1[0], &a1[0]+nCount1, &a2[0], &a2[0]+nCount2, &out[0]); // resize out with number of elements in union ULONG nOutCount = (ULONG)(pLast - &out[0]); outData.Resize( it, nOutCount ); } } break; }; return CStatus::OK; }