Automatic generation of triangulations for piecewise polynomial approximation