Optical methods in X-ray analysis. I. The study of imperfect structures