Self-consistent solution for general nonlinear slab waveguides