Contour regression: a general approach to dimension reduction