Hi everyone,
I'm trying to access the individual elements of a two dimensional array of
a custom type.
I have no problems when the array is one dimensional, but when it is two
dimensional and I try to create subArrays, I get stuck.
You can't get access to a subArray of custom type by saying subArray =
mainArray[it] like you can with normal data-types.
I could probably just hack something together by passing in the size of the
individual sub arrays and then computing the indices of the individual
elements from the 2D-array, but I would hope for a cleaner solution.
If that is actually the only way to your knowledge, then please let me know.
I know this is rather technical, but if you guys happen to have any
suggestions I would appreciate it.
case ID_OUT_DecPointPositionArray :
{
// Get the output port array ...
CDataArray2DVector3f outData( in_ctxt );
// Get the input data buffers for each port
CDataArrayCustomType EncodedGoalArrayData( in_ctxt, ID_IN_EncodedGoalArray
);
CIndexSet indexSet( in_ctxt );
for(CIndexSet::Iterator it = indexSet.Begin(); it.HasNext(); it.Next())
{
//The line below is the problem.
CDataArray2DCustomType::Accessor EncodedGoalArraySubArray =
EncodedGoalArrayData[it];
for (ULONG i=0; i<EncodedGoalArraySubArray.GetCount( ); i++)
{
GoalData* pBufferEncodedGoalArray;
ULONG nSizeEncodedGoalArray;
EncodedGoalArraySubArray.GetData(i,(const CDataArray2DCustomType::TData**)&
pBufferEncodedGoalArray, nSizeEncodedGoalArray);
CDataArray2DVector3f::Accessor outDataSubArray =
outData.Resize(it, EncodedGoalArraySubArray.GetCount());
if (nSizeEncodedGoalArray)
{
outDataSubArray[i].PutX(pBufferEncodedGoalArray->PointPosition.GetX());
outDataSubArray[i].PutY(pBufferEncodedGoalArray->PointPosition.GetY());
outDataSubArray[i].PutZ(pBufferEncodedGoalArray->PointPosition.GetZ());
}
else
{
outDataSubArray[i] = MATH::CVector3f( 0, 0, 0 ); //State not initialized yet
}
}
}
}
break;
Here is the simple structure which lives inside the custom data type:
struct GoalData
{
MATH::CVector3f PointPosition;
MATH::CVector3f PointTangent;
MATH::CVector3f PointNormal;
};
If there are any questions left open feel free to ask.