Simple and Versatile Analytical Method for Monitoring the Deposition of Thin Layers by Optical Measurement and Calculation of Residual Stress