Automated contour refinement procedure for the 2D magnetic field analysis by the surface-current method