Explicit convex and concave envelopes through polyhedral subdivisions