Bragg–Gray cavity theory