This reference page is linked to from the following overview topics: Softimage 2014.
#include <xsi_iceattributedataarray2D.h>
This class is a specialization of CICEAttributeDataArray2D which allows access to the ICEAttribute data as a 2D array of type siICENodeDataString. CICEAttributeDataArray2DString objects are read-only and can be filled with the methods supplied with the ICEAttribute class.
using namespace XSI;
Application app;
X3DObject x3dObj = app.GetSelection().GetItem(0);
ICEAttribute attr = x3dObj.GetActivePrimitive().GetGeometry().GetICEAttributeFromName( L"MyStringData2DAttribute" );
// Log the string and number of characters.
CICEAttributeDataArray2DString stringData2D;
attr.GetDataArray2D( stringData2D );
for( ULONG i=0; i<stringData2D.GetCount( ); i++ )
{
CICEAttributeDataArrayString stringData;
stringData2D.GetSubArray( i, stringData );
for( ULONG j=0; j<stringData.GetCount( ); j++ )
{
ULONG nCount;
const CICEAttributeDataArrayString::TData* pStr;
stringData.GetData( j, &pStr, nCount );
app.LogMessage( CString( pStr, nCount ) + L":" + CString( nCount ) );
}
}
Public Member Functions |
|
| CICEAttributeDataArray2DString () | |
| ~CICEAttributeDataArray2DString () | |
| CStatus | GetSubArray (ULONG in_index, CBaseICEAttributeDataArray &out_dataArray) const |
| CStatus | ResizeSubArray (ULONG in_index, ULONG in_size, CBaseICEAttributeDataArray &out_dataArray) |
| CStatus | SetSubArray (ULONG in_index, const wchar_t **in_ppData, ULONG in_count) |
| CICEAttributeDataArray2DString | ( | ) | [inline] |
Constructor.
| ~CICEAttributeDataArray2DString | ( | ) | [inline] |
Destructor.
| CStatus GetSubArray | ( | ULONG | in_index, |
| CBaseICEAttributeDataArray & | out_dataArray | ||
| ) | const [inline] |
Returns the sub-array containing the string data at a given index.
| in_index | Index in the array. The index must be smaller than the number of elements in the array, otherwise the result is unpredictable. |
| out_dataArray | A read-only reference to a
CICEAttributeDataArrayString object. |
in_index or
out_dataArray is invalid.| CStatus ResizeSubArray | ( | ULONG | in_index, |
| ULONG | in_size, | ||
| CBaseICEAttributeDataArray & | out_dataArray | ||
| ) | [inline] |
Changes the size of the sub-array at a given index and returns a new array pointing to the resized sub-array. This is only supported for writable attributes and not available for built-in attributes.
| in_index | Index in the array. The index must be smaller than the number
of elements in the array, otherwise the result is unpredictable. If
this DataArray2D is an array chunk, in_index is
relative to the chunk offset. |
| out_dataArray | A reference to a CICEAttributeDataArray<T>
object at a specific index. |
| in_size | The size of the array. |
in_index or
out_dataArray is invalid.| CStatus SetSubArray | ( | ULONG | in_index, |
| const wchar_t ** | in_ppData, | ||
| ULONG | in_count | ||
| ) |
Set the sub-array at a given index This is only supported for writable attributes and not available for built-in attributes.
| in_index | Index in the array. The index must be smaller than the number
of elements in the array, otherwise the result is unpredictable. If
this DataArray2D is an array chunk, in_index is
relative to the chunk offset. |
| in_array | array containing the input strings, all strings in the array must be NULL-terminated |
in_index,
in_ppData or in_count is invalid.
// Template class to log the values in a CICEAttributeDataArray2D
template < class T >
class CICEAttributeData2DLogger
{
public:
static void Log( ICEAttribute& attr )
{
CICEAttributeDataArray2D< T > data2D;
attr.GetDataArray2D( data2D );
Application xsi;
for( ULONG i=0; i<data2D.GetCount( ); i++ )
{
CICEAttributeDataArray< T > data;
data2D.GetSubArray( i, data );
for( ULONG j=0; j<data.GetCount( ); j++ )
{
xsi.LogMessage( CString( data[ j ] ) );
}
}
}
};
// Template specilization to log the values in a CICEAttributeDataArray2DString
template < >
class CICEAttributeData2DLogger< XSI::CString >
{
public:
static void Log( ICEAttribute& attr )
{
CICEAttributeDataArray2DString data2D;
attr.GetDataArray2D( data2D );
Application xsi;
for( ULONG i=0; i<data2D.GetCount( ); i++ )
{
CICEAttributeDataArrayString data;
data2D.GetSubArray( i, data );
for( ULONG j=0; j<data.GetCount( ); j++ )
{
xsi.LogMessage( data[ j ] );
}
}
}
};
Application xsi;
Model root = xsi.GetActiveSceneRoot();
X3DObject cone( CreatePrim( L"cone", L"MeshSurface", L"", L"") );
{
ICEAttribute attr = cone.GetActivePrimitive().GetGeometry().AddICEAttribute( "DataArray2DString", XSI::siICENodeDataString, XSI::siICENodeStructureArray, 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.DataArray2DString");
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);
CICEAttributeDataArray2DString data;
attr.GetDataArray2D( data );
CICEAttributeData2DLogger<CString>::Log( attr );
ULONG l_nbElem = attr.GetElementCount();
typedef const wchar_t* RawWStringType;
typedef const wchar_t** RawWStringArray;
{
RawWStringType sub0[2] = {L"even", L"EVEN"};
RawWStringType sub1[2] = {L"odd", L"ODD"};
for (ULONG i=l_nbElem; i>0; i--)
{
data.SetSubArray(i-1, (i-1)%2==0 ? sub0 : sub1, 2);
}
CICEAttributeData2DLogger<CString>::Log( attr );
}
{
RawWStringType sub3[3] = {L"three", L"THREE", L"thrEE"};
RawWStringType sub4[4] = {L"four", L"Four", L"FouR", L"FOUR"};
RawWStringType sub5[5] = {L"FIVE", L"FivE", L"fIVe", L"Five", L"five"};
CICEAttributeDataArray2DString dataChunk;
attr.GetDataArray2DChunk(3, 3, dataChunk);
dataChunk.SetSubArray(0, sub3, 3);
dataChunk.SetSubArray(1, sub4, 4);
dataChunk.SetSubArray(2, sub5, 5);
}
}