Calculation of nonlinear modes guided by multilayer dielectric structures using the resonance technique