Flexible piecewise function evaluation methods with application to explicit model predictive control