Control of Residual Thermal Stresses in Shape Deposition Manufacturing