Measuring the level of material in a container or the position or shape of the upper surface of the material