I think the code is more flexible and maintenable if you use named nodes and coordinates, as in the following example:
\usetikzlibrary{calc}
\begin{tikzpicture}
% Background
\filldraw[color=lightgray] (1,0) rectangle (7,4);
% North pole
\node[draw, minimum width=1cm, minimum height=2.5cm, inner sep=0pt, fill=blue, anchor=south west] at (1.5, 0.5) (north pole) {\sffamily\bfseries N};
% South pole
\node[draw, minimum width=1cm, minimum height=2.5cm, inner sep=0pt, fill=blue, anchor=south west] at (5.5, 0.5) (south pole) {\sffamily\bfseries S};
% White block
\node[draw, minimum width=1cm , minimum height=1.2cm, inner sep=0pt, fill=white, anchor=center] at ($(north pole)!.5!(south pole)$) (block) {};
% Vertical points at which the field lines are distorted
% as percentage of the distance between poles and white block
\coordinate (outer left edge) at ($(north pole.east)!.8!(block.west)$);
\coordinate (inner left edge) at ($(block.west)!.2!(block.east)$);
\coordinate (inner right edge) at ($(block.west)!.8!(block.east)$);
\coordinate (outer right edge) at ($(block.east)!.2!(south pole.west)$);
% To draw the field lines, I use a for loop. The numbers in the list
% is the vertical distance each line is deflected
\foreach \p [count=\i] in {0.1,0.2,0.3,0.4,0.3,0,-0.4,-0.4,-0.3,-0.2,-0.1} {
% Vertical coordenate of the undeflected line
\coordinate (aux1) at ($(north pole.north east)!\i*1/12!(north pole.south east)$);
% Vertical coordinate of the deflected line
\coordinate (aux2) at ($(aux1)+(0,\p)$);
\draw[red, rounded corners=2pt] (aux1) -- (aux1-|outer left edge) --
(aux2-|inner left edge) -- (aux2-|inner right edge) --
(aux1-|outer right edge) -- (aux1-|south pole.west);
}
\end{tikzpicture}
Which produces:

The advantage of this approach is that it is simple to change the dimensions, for example of the poles, and have the figure automatically adjusted. For example, changing the height of the poles to 2cm:
% North pole
\node[draw, minimum width=1cm, minimum height=2cm, inner sep=0pt, fill=blue, anchor=south west] at (1.5, 0.5) (north pole) {\sffamily\bfseries N};
% South pole
\node[draw, minimum width=1cm, minimum height=2cm, inner sep=0pt, fill=blue, anchor=south west] at (5.5, 0.5) (south pole) {\sffamily\bfseries S};
the new figure is:
