Lossy Waveguides with an Arbitrary Boundary Contour and Distribution of Material