Generalized model of TE- and TM-polarized light diffraction on periodical structures of different types