A computational approach to the optical characterization of photonic crystals and photonic glasses