Set Expressions
Set expressions are a convenient way to build sets from other sets or locations. For the following examples we will assume that the scene has the following hierarchy :
A
B
C
D
E
Set memberships in this imaginary scene are as follows.
set1 |
set2 |
set3 |
set4 |
---|---|---|---|
A B C |
B C D |
C D E |
E |
The following operators are currently supported
Operator |
Behaviour |
---|---|
|
Union, unites two sets |
|
Intersection, intersects two sets |
|
Difference, removes elements from sets |
|
Descendant query, selects locations from one set which are parented under locations in another |
|
Ancestor query, selections locations from one set which are parents of locations in another |
Simple Examples
SetExpression |
Objects in resulting set |
---|---|
|
A B C |
|
A B C D |
|
B C |
|
A |
|
A B |
|
E |
|
D |
The last example illustrates the use of objects in set expressions. Gaffer will interpret them as a set with the specified object as its sole member. Gaffer will also conveniently interpret space separated lists of sets and objects as a set that contains all the elements in the list (think of it as Gaffer inserting the | for you).
SetExpression |
Objects in resulting set |
---|---|
|
A B C D |
|
A B C D |
Note that you can build sets on-the-fly to be used in the expression by using these space separated list of sets and objects.
SetExpression |
Objects in resulting set |
---|---|
|
A B C D E |
|
A B |
|
A |
Operator Precedence
Operations in the expression are executed in the following order : -
, &
, containing
and then in
. The following examples demonstrate this in action.
SetExpression |
Objects in resulting set |
---|---|
|
A B C E |
|
A E |
|
B |
Parenthesis can be used to explicitly change the order of evaluation. The following examples use the same sets and operations as before, and demonstrate the effect of changing the evaluation order.
SetExpression |
Objects in resulting set |
---|---|
|
E |
|
A |
|
A B |