A CUserDataArray is an uni-dimensional array used to store binary values. CUserDataArray contains items of type CUserDataArray::Value which holds the data set on a user data map property.
The array is-zero based, which means that the first item index is 0 and the larger index is one less that the number of elements contained in the array.
- See also:
- UserDataMap::GetValues, UserDataMap::SetValues, UserDataMap::SetFixedSizeValues
- Since:
- 5.0
- Example:
#include "xsi_application.h"
#include "xsi_userdatamap.h"
#include "xsi_userdataarray.h"
#include "xsi_x3dobject.h"
#include "xsi_model.h"
#include "xsi_primitive.h"
#include "xsi_geometry.h"
#include "xsi_polygonmesh.h"
#include "xsi_clusterpropertybuilder.h"
#include "xsi_geometryaccessor.h"
Application app;
Model root = app.GetActiveSceneRoot();
X3DObject mySphere;
root.AddGeometry( L"Sphere", L"MeshSurface", L"", mySphere );
PolygonMesh mesh = mySphere.GetActivePrimitive().GetGeometry();
CClusterPropertyBuilder cpBuilder = mesh.GetClusterPropertyBuilder();
UserDataMap udm = cpBuilder.AddUserDataMap(XSI::siClusterVertexType);
struct FooData
{
FooData(float a,float b,float c) : x(a), y(b), z(c) {}
float x,y,z;
};
FooData f1(10,10,10);
FooData f2(20,20,20);
FooData f3(30,30,30);
unsigned char* fds[] =
{
(unsigned char*)&f1,
(unsigned char*)&f2,
(unsigned char*)&f3,
};
LONG vtxIndices[] = {10,20,30};
udm.SetFixedSizeValues( vtxIndices,
(const unsigned char**)fds,
3,
sizeof(FooData) );
CGeometryAccessor ga = mesh.GetGeometryAccessor();
CRefArray udmaps = ga.GetUserDataMaps( XSI::siClusterVertexType );
for (LONG i=0; i<udmaps.GetCount(); i++)
{
udm = udmaps[i];
CUserDataArray data;
udm.GetValues( data );
for (LONG j=0; j<data.GetCount(); j++)
{
CUserDataArray::Value val = data[j];
FooData* pfd = (FooData*)val.m_pData;
if (pfd)
{
app.LogMessage( CString(L"FooData[") + CString(j) + CString(L"]=")
+ CString(pfd->x) + L","
+ CString(pfd->y) + L","
+ CString(pfd->z) );
}
else
{
app.LogMessage( CString(L"FooData[") + CString(j) + CString(L"]=empty") );
}
}
}
for (LONG i=0; i<udmaps.GetCount(); i++)
{
udm = udmaps[i];
CUserDataArray data;
CBitArray flags;
udm.GetValues( data, flags );
LONG j = flags.GetIterator();
while (flags.GetNextTrueBit(j))
{
CUserDataArray::Value val = data[j];
FooData* pfd = (FooData*)val.m_pData;
app.LogMessage( CString(L"FooData[") + CString(j) + CString(L"]=")
+ CString(pfd->x) + L","
+ CString(pfd->y) + L","
+ CString(pfd->z) );
}
}