This reference page is linked to from the following overview topics: Softimage 2014.
#include <xsi_iceattributedataarray2D.h>
This template class encapsulates ICEAttribute data as a 2D array. CICEAttributeDataArray2D objects are read-only and can be filled with the methods supplied with the ICEAttribute class. CICEAttributeDataArray2D is zero-based and can be one of the following types:
All types are associated to specific ICEAttribute 2D 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; X3DObject cone = CreatePrim( L"Cone", L"MeshSurface", L"", L""); Create2DSkeleton( 2.95, 3.34, -0.33, 4.73, 0.0, 0.0, -5.71, 0, 0, 4, CValue(""), CValue("")); AppendBone( L"eff", 3.70, -3.02, 0.30, L""); XSI::siConstructionMode mode = siConstructionModeModeling; ApplyFlexEnv( L"cone;bone,bone1,eff", true, mode ); SelectObj( L"cone.polymsh.cls.EnvelopWeightCls.Envelope_Weights", L"", L"" ); // Make sure to generate the data first cone.GetActivePrimitive().GetGeometry(0); Application xsi; ProjectItem envProp = xsi.GetSelection()[0]; ICEAttribute attr = envProp.GetICEAttributeFromName( L"EnvelopeWeightsPerDeformer" ); CICEAttributeDataArray2DFloat weight2D; attr.GetDataArray2D( weight2D ); for( ULONG i=0; i<weight2D.GetCount( ); i++ ) { CICEAttributeDataArray< float > weights; weight2D.GetSubArray( i, weights ); for( ULONG j=0; j<weights.GetCount( ); j++ ) { xsi.LogMessage( CString( weights[ j ] ) ); } } // Helpers 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; } CValue Create2DSkeleton( const CValue& in_rx, const CValue& in_ry, const CValue& in_rz, const CValue& in_ex, const CValue& in_ey, const CValue& in_ez, const CValue& in_nx, const CValue& in_ny, const CValue& in_nz, const CValue& in_viewtype, CValue& out_bone, CValue& out_effector ) { CValueArray args(12); CValue retval; args[0]= in_rx; args[1]= in_ry; args[2]= in_rz; args[3]= in_ex; args[4]= in_ey; args[5]= in_ez; args[6]= in_nx; args[7]= in_ny; args[8]= in_nz; args[9]= in_viewtype; Application app; app.ExecuteCommand( L"Create2DSkeleton", args, retval ); out_bone = args[10]; out_effector = args[11]; return retval; } CValue AppendBone( const CValue& in_inputobjs, const CValue& in_ex, const CValue& in_ey, const CValue& in_ez, bool in_pin ) { CValueArray args(5); CValue retval; args[0]= in_inputobjs; args[1]= in_ex; args[2]= in_ey; args[3]= in_ez; args[4]= in_pin; Application app; app.ExecuteCommand( L"AppendBone", args, retval ); return retval; } CValue ApplyFlexEnv( const CValue& in_connectionset, bool in_assignnewdeformers, XSI::siConstructionMode & io_constructionmode ) { CValueArray args(3); CValue retval; args[0]= in_connectionset; args[1]= in_assignnewdeformers; args[2]= io_constructionmode; Application app; app.ExecuteCommand( L"ApplyFlexEnv", args, retval ); io_constructionmode = (XSI::siConstructionMode)(LONG)args[2]; return retval; } void SelectObj( const CValue& in_selectionlist, const CString& in_hierarchylevel, bool in_checkobjectselectability ) { CValueArray args(3); CValue retval; args[0]= in_selectionlist; args[1]= in_hierarchylevel; args[2]= in_checkobjectselectability; Application app; CStatus st = app.ExecuteCommand( L"SelectObj", args, retval ); return; }
using namespace XSI; 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; } template < class T > class CICEAttributeData2D { public: static void Log( ICEAttribute& attr ) { Application xsi; xsi.LogMessage( L"*******************************************************************" ); xsi.LogMessage( L"Name: " + attr.GetName() ); xsi.LogMessage( L"DataType: " + CString(attr.GetDataType()) ); CICEAttributeDataArray2D< T > data2D; attr.GetDataArray2D( data2D ); 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( j ) + " " + CString( data[ j ] ) ); } } } static void SetData( const X3DObject & in_Obj, XSI::siICENodeDataType in_DataType, const CString& in_csDataName, const T in_Value ) { ICEAttribute attr = in_Obj.GetActivePrimitive().GetGeometry().AddICEAttribute( in_csDataName, in_DataType, XSI::siICENodeStructureArray, XSI::siICENodeContextComponent0D ); CICEAttributeDataArray2D< T > data2D; attr.GetDataArray2D( data2D ); CICEAttributeDataArray< T > data; ULONG subArraySize = 6; // This can be any number. data2D.ResizeSubArray( 0 ,subArraySize ,data ); T l_Values[subArraySize] = { in_Value, in_Value, in_Value, in_Value, in_Value, in_Value }; memcpy( &data[0], &l_Values[0], subArraySize * sizeof(T) ); CICEAttributeData2D<T>::Log( attr ); } }; template < > class CICEAttributeData2D< bool > { public: static void Log( ICEAttribute& attr ) { Application xsi; xsi.LogMessage( L"*******************************************************************" ); xsi.LogMessage( L"Name: " + attr.GetName() ); xsi.LogMessage( L"DataType: " + CString(attr.GetDataType()) ); CICEAttributeDataArray2D< bool > data2D; attr.GetDataArray2D( data2D ); for( ULONG i=0; i<data2D.GetCount( ); i++ ) { CICEAttributeDataArray< bool > data; data2D.GetSubArray( i, data ); for( ULONG j=0; j<data.GetCount( ); j++ ) { xsi.LogMessage( CString( j ) + " " + CString( data[ j ] ) ); } } } static void SetData( const X3DObject & in_Obj, XSI::siICENodeDataType in_DataType, const CString& in_csDataName, const bool in_Value ) { ICEAttribute attr = in_Obj.GetActivePrimitive().GetGeometry().AddICEAttribute( in_csDataName, in_DataType, XSI::siICENodeStructureArray, XSI::siICENodeContextComponent0D ); CICEAttributeDataArray2D< bool > data2D; attr.GetDataArray2D( data2D ); CICEAttributeDataArray< bool > data; ULONG subArraySize = 6; // This can be any number. data2D.ResizeSubArray( 0, subArraySize, data ); data.SetData(0, in_Value); data.SetData(1, !in_Value); data.SetData(2, in_Value); data.SetData(3, !in_Value); data.SetData(4, in_Value); data.SetData(5, !in_Value); CICEAttributeData2D<bool>::Log( attr ); } }; template < > class CICEAttributeData2D< 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( CString( i ) + " , " + CString( j ) + " : " +data[ j ] ); } } } static void SetData( const X3DObject & in_Cone, XSI::siICENodeDataType in_DataType, const CString& in_csDataName, const XSI::CString in_Value ) { ICEAttribute attr = in_Cone.GetActivePrimitive().GetGeometry().AddICEAttribute( in_csDataName, in_DataType, XSI::siICENodeStructureArray, XSI::siICENodeContextComponent0D ); CICEAttributeDataArray2DString data2D; attr.GetDataArray2D( data2D ); { CICEAttributeDataArrayString data; ULONG subArraySize = 6; // This can be any number. data2D.ResizeSubArray( 0, subArraySize, data ); data.SetData(0, in_Value); data.SetData(2, in_Value); data.SetData(4, in_Value); } { CICEAttributeDataArrayString data; ULONG subArraySize = 24; // This can be any number. data2D.ResizeSubArray( 1, subArraySize, data ); data.SetData(0, in_Value); data.SetData(12, in_Value); data.SetData(60, in_Value); } CICEAttributeData2D<XSI::CString>::Log( attr ); } }; void SetDataArray2D( const X3DObject & in_Cone ) { CICEAttributeData2D<LONG>::SetData( in_Cone, XSI::siICENodeDataLong, "TestLong", 20 ); CICEAttributeData2D<float>::SetData( in_Cone, XSI::siICENodeDataFloat, "Testfloat", -20 ); CICEAttributeData2D<bool>::SetData( in_Cone, XSI::siICENodeDataBool, "TestBOOL", true ); MATH::CVector2f Vec2f( 20, -20); CICEAttributeData2D<MATH::CVector2f>::SetData( in_Cone, XSI::siICENodeDataVector2, "TestVector2", Vec2f ); MATH::CVector3f Vec3f( 20, -20, 20); CICEAttributeData2D<MATH::CVector3f>::SetData( in_Cone, XSI::siICENodeDataVector3, "TestVector3", Vec3f ); MATH::CVector4f Vec4f( 20, -20, 20, -20); CICEAttributeData2D<MATH::CVector4f>::SetData( in_Cone, XSI::siICENodeDataVector4, "TestVector4", Vec4f ); MATH::CQuaternionf Quat( 20, -20, 20 ,20); CICEAttributeData2D<MATH::CQuaternionf>::SetData( in_Cone, XSI::siICENodeDataQuaternion, "TestQuat", Quat ); MATH::CRotationf Rot( 45, -45, 45 ); CICEAttributeData2D<MATH::CRotationf>::SetData( in_Cone, XSI::siICENodeDataRotation, "TestRot", Rot ); MATH::CMatrix3f Mat3( 1, 2, 3, 4, 5, 6, 7, 8, 9); CICEAttributeData2D<MATH::CMatrix3f>::SetData( in_Cone, XSI::siICENodeDataMatrix33, "TestMat3", Mat3 ); MATH::CMatrix4f Mat4( 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 ); CICEAttributeData2D<MATH::CMatrix4f>::SetData( in_Cone, XSI::siICENodeDataMatrix44, "TestMat4", Mat4 ); MATH::CColor4f Col4( 20, -20, 20, 1); CICEAttributeData2D<MATH::CColor4f>::SetData( in_Cone, XSI::siICENodeDataColor4, "TestCol4", Col4 ); CICEAttributeData2D<CString>::SetData( in_Cone, XSI::siICENodeDataString, "TestString", "hum!" ); } { Application xsi; CreatePrim( L"Cone", L"MeshSurface", L"", L""); Selection selection = xsi.GetSelection(); X3DObject cone = selection[0]; SetDataArray2D( cone ); }
Public Member Functions |
|
CICEAttributeDataArray2D () | |
~CICEAttributeDataArray2D () | |
CStatus | GetSubArray (ULONG in_index, CICEAttributeDataArray< T > &out_dataArray) const |
CStatus | ResizeSubArray (ULONG in_index, ULONG in_size, CICEAttributeDataArray< T > &out_dataArray) |
CStatus | SetSubArray (ULONG in_index, const T *in_pArray, ULONG in_count) |
CStatus | SetArray2D (const T **in_ppArray, ULONG in_nbSubArrays, ULONG *in_pSubArraySizes) |
CICEAttributeDataArray2D | ( | ) | [inline] |
Constructor.
~CICEAttributeDataArray2D | ( | ) | [inline] |
Destructor.
CStatus GetSubArray | ( | ULONG | in_index, |
CICEAttributeDataArray< T > & | out_dataArray | ||
) | 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 result is unpredictable. |
out_dataArray | A read-only reference to a
CICEAttributeDataArray<T> object at a specific
index. |
in_index
or
out_dataArray
is invalid.CStatus ResizeSubArray | ( | ULONG | in_index, |
ULONG | in_size, | ||
CICEAttributeDataArray< T > & | 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_nIndex
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 T * | in_pArray, | ||
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_pArray | Array containing the input data |
in_index
,
in_pArray
or in_count
is invalid.CStatus SetArray2D | ( | const T ** | in_ppArray, |
ULONG | in_nbSubArrays, | ||
ULONG * | in_pSubArraySizes | ||
) |
Set all the values in the 2D ICE attribute
in_ppArray | Input 2D data array |
in_nbSubArrays | Number of subarrays |
in_pSubArraySizes | Sizes of the subarrays |
in_ppArray
,
in_nbSubArrays
or in_pSubArraySizes
is
invalid.Application xsi; Model root = xsi.GetActiveSceneRoot(); X3DObject grid( CreatePrim("Grid", "MeshSurface", L"", L"")); SetValue("grid.grid.ulength", 256); SetValue("grid.grid.vlength", 256); SetValue("grid.polymsh.geom.subdivu", 256); SetValue("grid.polymsh.geom.subdivv", 256); ICEAttribute attr = grid.GetActivePrimitive().GetGeometry().AddICEAttribute( "DataArrayLong", XSI::siICENodeDataLong, XSI::siICENodeStructureArray, XSI::siICENodeContextComponent0D ); CString l_connSet(L"grid"); ApplyOp( L"ICETree", l_connSet, siConstructionModeModeling ); AddICECompoundNode("Set Data", "grid.polymsh.ICETree"); AddICENode("$XSI_DSPRESETS\\ICENodes\\GetDataNode.Preset", "grid.polymsh.ICETree"); SetValue("grid.polymsh.ICETree.SceneReferenceNode.reference", "self.DataArrayLong"); SetValue("grid.polymsh.ICETree.Set_Data.Reference", "self.foo"); ConnectICENodes("grid.polymsh.ICETree.Set_Data.Value", "grid.polymsh.ICETree.SceneReferenceNode.value"); ConnectICENodes("grid.polymsh.ICETree.port1", "grid.polymsh.ICETree.Set_Data.Execute"); DisplayPortValues( "grid.polymsh.ICETree.Set_Data.Value", true, 0, true, "", 0, 0, 0, 1, false, true, 0.62, 1, 0.62, 1, false, 0, 10000, 1, true, false, 0, 10, false, true, false, 100); CICEAttributeDataArray2D< LONG > data; attr.GetDataArray2D( data ); CICEAttributeData2DLogger< LONG >::Log( attr ); ULONG l_nbElem = attr.GetElementCount(); { LONG** l_Values = new LONG*[l_nbElem]; ULONG* subArraySizes = new ULONG[l_nbElem]; LONG* sub0; LONG* sub1; const ULONG SUBARRAY_SIZE = 64; sub0 = new LONG[SUBARRAY_SIZE]; sub1 = new LONG[SUBARRAY_SIZE]; for (ULONG i=0; i<SUBARRAY_SIZE; i++) { sub0[i] = (i%2==0) ? -1 : 1; sub1[i] = (i%2==0) ? -2 : 2; } for (ULONG i=0; i<l_nbElem; i++) { l_Values[i] = (i%2==0) ? sub0 : sub1; subArraySizes[i] = SUBARRAY_SIZE; } data.SetArray2D((const LONG**)l_Values, l_nbElem, subArraySizes); delete[] sub0; delete[] sub1; delete[] l_Values; delete[] subArraySizes; }