def contain_shape_size_filter()

in dvd_generation/filters/spatial_constraint_filters.py [0:0]


def contain_shape_size_filter(scene_struct, template, constraint, param_name_to_type, 
                              state, outputs, verbose=False):
    ps = constraint['params']
    skip = False
    for p in ps:
        z1, s1, r, z2, s2 = p
        z1, s1, r, z2, s2 = state['vals'].get(z1), state['vals'].get(s1), state['vals'].get(r), \
            state['vals'].get(z2), state['vals'].get(s2)
        if r == 'containing':
            #print(z1, s1, r, z2, s2)
            if (s1 is not None and s1!= 'cone') \
                or (z1 is not None and z1=='small') \
                or (z2 is not None and z2=='large') \
                or not is_smaller(z2, z1):
                skip = True
                break
        elif r == 'contained':
            #print(z1, s1, r, z2, s2)
            if (s2 is not None and s2!= 'cone') \
                or (z2 is not None and z2=='small')  \
                or (z1 is not None and z1=='large') \
                or not is_smaller(z1, z2):
                skip = True
                break
    if skip:
        if verbose:
            print('skipping due to CONTAIN_SHAPE_SIZE constraint')
            print(constraint)
            print(state['vals'])
        return True
    return False