use a swap operation: If the minimum value is greater than the max-
imum (which it shouldn’t be), swap them around, so we know that
the min is actually the minimum.
I bet you were expecting some procedure of cosmic complexity.
9.5.3 Code and Comments
global proc annoDataGetVisibleElements(
string $node, int $res[],
float $min, float $max
//swap operation
if ($min > $max) {
float $tmp = $min;
$min = $max;
$max = $tmp;
// linear search
int $all[];
annoDataGetExistingElements($node, $all);
int $i, $num = size($all);
int $count = 0;
for ($i=0; $i<$num; $i++) {
int $idx = $all[$i];
string $elemPlug = $node+".block["+$idx+"]";
float $in = `getAttr ($elemPlug+".in")`;
float $out = `getAttr ($elemPlug+".out")`;
if ($in >= $max || $out <= $min) {
$res[$count] = $idx;
Chapter 9

Get Professional MEL Solutions for Production now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.