Piecewise polynomial functions, convex polytopes and enumerative geometry