Automatic least-squares projection of points onto point clouds with applications in reverse engineering