Boundary element method for dielectric resonators and waveguides