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:
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.
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>
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) |
CICEAttributeDataArray | ( | ) | [inline] |
Constructor.
~CICEAttributeDataArray | ( | ) | [inline] |
Destructor.
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.
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. |
T& operator[] | ( | ULONG | in_index | ) | [inline] |
Accessor to the encapsulated array. This operator is used for writing to the data array.
in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable. |
CStatus SetData | ( | ULONG | in_index, |
const T & | in_value | ||
) |
Accessor to the encapsulated array for writing to the data array.
in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the results are unpredictable. |
CStatus SetArray | ( | const T * | in_pArray, |
ULONG | in_count | ||
) |
Set the values in the array
in_pArray | Input data array. |
in_count | Number of elements in the input 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; }