Working with Arrays in ICE Trees

A data set may be composed of single values or arrays. An array is an ordered set of values of the same data type. Among other things, arrays are used to implement particle strands.

Arrays are zero-based. This means that in an array of size 5, the first element has index 0 and the last element has index 4.

 

Note that the Build Array node has inputs called Value1, Value2, and so on, but these are just the names of the ports. The array indices are 0, 1, etc.

Arrays may have different sizes for different members of the same data set. For example, Get Closest Points may return a different number of locations for each position depending on how many points are within the cutoff distance.

Many of the basic nodes support arrays in addition to single values, including nodes in the Math and Conversion categories. There is also a set of nodes that allow building and modifying arrays; for example, the Push On Array node adds a value at the end of the array. There are also nodes that access array attributes such as the size of the array, the average of the values, etc.

The nodes in the Array category are used to perform the standard array operations: popping, pushing, removing, and so on. See the sections below for special notes on specific nodes.

Array Size

Arrays are dynamic — they automatically change size when you insert, remove, pop, or push items.

However, if you know the maximum size that the array will grow to in advance, you can improve performance by using the Reserve Array node to reserve memory for it, for example, in a separate ICE tree earlier in the construction stack that does not get re-evaluated during a simulation. You can also use Reserve Array to reserve additional memory for existing arrays. For example, if you are about to push four items into every array in a data set, it may be more efficient to reserve the memory first. Reserving memory does not change the size of arrays.

The Resize Array node from differs Reserve Array in that it does change the array size. If the new size is larger, new elements are filled with default values.

Inserting into Arrays

In addition to using the Insert in Array node to insert a value into an array, you can use it to insert an array into another array. This is like splicing one array inside another beginning at the specified index.

Selecting Items in Arrays

The Select in Array node returns the item in an array at a specified index value. You can also connect an array of index values to return an array containing the specified items.

Sorting Items in Arrays

There are two nodes for sorting arrays:

• Sort Array rearranges the items in the array in ascending or descending order. It uses the same criteria as the Compare node — see Comparing Values.

• Sort Array with Key sorts one array based on another of the same size. It is similar to sorting the rows of a table or spreadsheet based on one of two columns — the other column is rearranged in the same way.

Getting Array Indices

The Get Array Sub Indices node simply returns an array of the integer indices used by another array. This is typically used with Sort Array with Key. For example, if you have an array of deformers and an array of point weights and you want to get the two deformers with the strongest influence, you can get the indices of the deformer array, sort it according to the point weight array (using descending order), and then return the first two indices.



Autodesk Softimage v.7.5