Topological phases in quantum mechanics and polarization optics