# CClusterPropertyElementArray Class Reference

Related Scripting Object: ClusterPropertyCollection

An array of cluster property elements in a ClusterProperty object. More...

`#include <xsi_clusterproperty.h>`

List of all members.

## Public Member Functions
| CClusterPropertyElementArray ()
| CClusterPropertyElementArray (const CClusterPropertyElementArray &in_array)
virtual | ~CClusterPropertyElementArray ()
CClusterPropertyElementArray & | operator= (const CClusterPropertyElementArray &in_array)
CDoubleArray | GetArray () const
CStatus | PutArray (const CDoubleArray &in_values)
LONG | GetCount () const
CDoubleArray | GetItem (LONG in_index) const
CStatus | PutItem (LONG in_index, const CDoubleArray &in_values)
CDoubleArray | GetItemsByIndex (const CLongArray &in_indices) const
CStatus | PutItemsByIndex (const CLongArray &in_indices, const CDoubleArray &in_values)
LONG | GetValueSize () const

## Detailed Description

An array of cluster property elements in a ClusterProperty object.

The cluster property maps the cluster element indices to property values (such as RGB vertex color). The value of the element in a cluster property element array is the cluster property value.

You can set elements using CClusterPropertyElementArray::PutItems and this is accessible from an operator. Unlike CClusterElementArray, a CClusterPropertyElementArray object allows editing of element values.

The following lists all cluster properties along with their data type values returned through CClusterPropertyElementArray::GetItem:

- Vertex color property: array of RGBA values

- Envelope weight property: array containing the weight value for each deformer

- Weight map property: array of only 1 value which is the weight value

- UV property: array of UVW values

Warning:
  This specialized array is returned by ClusterProperty::GetElements, it is not meant to be created and modified in user-defined functions. If you want to add and remove arbitrary items to a collection, you must use a CRefArray instead.

See also:
  ClusterProperty, Cluster

Example:

              using namespace XSI;
              Application app;
              Model root = app.GetActiveSceneRoot();

              X3DObject myCube;
              root.AddGeometry( L"Cube", L"MeshSurface", L"", myCube );

              // install the texture support object
              CValueArray args(4);
              args[0] = CValue( CString(L"Image") );
              args[1] = CValue(myCube);
              args[2] = CValue((short)1);
              args[3] = CValue(false);

              CStatus st;
              CValue outArg;
              st = app.ExecuteCommand( L"BlendInPresets", args, outArg );
              if ( st.GetCode() != CStatus::OK )
              {
                  app.LogMessage( L"BlendInPresets failed" );
                  return;
              }

              args[0] = CValue(myCube);
              args[1] = CValue((LONG)siTxtUV);
              args[2] = CValue((LONG)siTxtDefaultSpherical);
              args[3] = CValue(CString(L"Texture_Support"));

              st = app.ExecuteCommand( L"CreateTextureSupport", args, outArg );
              if ( st.GetCode() != CStatus::OK )
              {
                  app.LogMessage( L"CreateTextureSupport failed" );
                  return;
              }

              // get the sample point cluster and print out its UVW values
              Geometry geom(myCube.GetActivePrimitive().GetGeometry());

              CRefArray samplePoints;
              geom.GetClusters().Filter(siSampledPointCluster, CStringArray(), L"",
                  samplePoints );

              Cluster cluster(samplePoints.GetItem(0));
              ClusterProperty UVWProp(myCube.GetMaterial().GetCurrentUV());

              CClusterPropertyElementArray uvwElementArray(UVWProp.GetElements());

              CDoubleArray uvwArray(uvwElementArray.GetArray());

              for ( LONG i=0; i< uvwArray.GetCount(); i += uvwElementArray.GetValueSize())
              {
                  app.LogMessage( L"UVW: " +
                      CValue(uvwArray[i]).GetAsText() + L"," +
                      CValue(uvwArray[i+1]).GetAsText() + L"," +
                      CValue(uvwArray[i+2]).GetAsText() );
              }

## Constructor & Destructor Documentation

CClusterPropertyElementArray | ( |  | ) |

Default constructor

CClusterPropertyElementArray | ( | const CClusterPropertyElementArray & | in_array | ) |

Copy constructor.

Parameters:

  | in_array | constant CClusterPropertyElementArray object.

virtual ~CClusterPropertyElementArray | ( |  | ) | `[virtual]`

Default destructor

## Member Function Documentation

CClusterPropertyElementArray& operator= | ( | const CClusterPropertyElementArray & | in_array | ) |

Creates an array from a reference object.

Parameters:

  | in_array | constant CClusterPropertyElementArray object.

Returns:
  The new CClusterPropertyElementArray object.

CDoubleArray GetArray | ( |  | ) | const

Returns an array of element values which contains CClusterPropertyElementArray::GetCount() * CClusterPropertyElementArray::GetValueSize() double values. The array is laid out so that all values for an element are contiguous.

Returns:
  Array of element values

CStatus PutArray | ( | const CDoubleArray & | in_values | ) |

Sets the values on the underlying ClusterProperty.

Parameters:

  | in_values | Array of element values

Returns:
  CStatus::OK success

  CStatus::Fail failure

LONG GetCount | ( |  | ) | const

Returns the number of cluster element values

Returns:
  The number of cluster element values.

CDoubleArray GetItem | ( | LONG | in_index | ) | const

Returns the cluster element values at a given index.

Parameters:

  | in_index | Element index.

Returns:
  Array of element values. The array will be empty if the index is greater than the number of elements or smaller than zero.

CStatus PutItem | ( | LONG | in_index,
|  | const CDoubleArray & | in_values |
| ) |  |  |

Sets the cluster element values at a given index.

Parameters:

  | in_index | Element index.
  | in_values | Array of element values.

Returns:
  CStatus::OK success

  CStatus::Fail failure

  CStatus::InvalidArgument The index is greater than the number of elements or smaller than zero.

CDoubleArray GetItemsByIndex | ( | const CLongArray & | in_indices | ) | const

Returns cluster element values by indices.

Parameters:

  | in_indices | Array of indices

Returns:
  Array of element values. The array will be empty if an index is greater than the number of elements or smaller than zero.

CStatus PutItemsByIndex | ( | const CLongArray & | in_indices,
|  | const CDoubleArray & | in_values |
| ) |  |  |

Sets cluster element values by indices.

Parameters:

  | in_indices | Array of indices
  | in_values | Array of element values

Returns:
  CStatus::OK success

  CStatus::Fail failure

  CStatus::InvalidArgument If an index is greater than the number of elements or smaller than zero.

LONG GetValueSize | ( |  | ) | const

Returns the number of values per element in the cluster. For instance, a uvw cluster property returns 3(uvw) and in the case of a vertex color cluster property it returns 4(rgba).

Returns:
  The number of values per element.

The documentation for this class was generated from the following file:

- xsi_clusterproperty.h