# Flush wrapfigures in an automatic way?

This is a follow up of Typesetting errors with two wrapfigures on one page?.

Consider the case here:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}

\def\a{One two three four five six. }
\def\b{\a\a Red green blue yellow white black. }
\def\c{\b\b\a\b\b\b\a\b\b}

\begin{document}

\begin{wrapfigure}{r}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Figure with little text}
\label{hausdorffShapes}
\end{wrapfigure}
\b

\begin{wrapfigure}{l}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Another figure here}
\end{wrapfigure}
\b\b\c

\end{document}


which is quite a common case when I write a solution to an exercise of electronics --- quite a lot of schematics and sometime just a little of text on the side. Unfortunately, with the due warning, I have this output:

I can fix it like this (adding the [3] and the \vspace{} manually, by visually editing at the end).

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}

\def\a{One two three four five six. }
\def\b{\a\a Red green blue yellow white black. }
\def\c{\b\b\a\b\b\b\a\b\b}

\begin{document}

\begin{wrapfigure}[3]{r}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Figure with little text}
\label{hausdorffShapes}
\end{wrapfigure}
\b

\vspace{4cm}

\begin{wrapfigure}{l}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Another figure here}
\end{wrapfigure}
\b\b\c

\end{document}


which led to the correct (at least, in this case; I admit is not so nice) document:

Is it possible to do this automatically? I mean, a \clearwrapfigure command that emits the necessary vertical space and restart the normal paragraph shape?

Something like this seems to work, you may prefer it with \mbox{} rather than \mbox{zz} but this shows what it is doing.

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}

\def\a{One two three four five six. }
\def\b{\a\a Red green blue yellow white black. }
\def\c{\b\b\a\b\b\b\a\b\b}

\makeatletter
\def\clearwf{\par{\count@\c@WF@wrappedlines\zz}\par}

\def\zz{{%
\ifnum\count@>\@ne
\noindent\mbox{zz}\\%
\expandafter\zz
\else
\ifhmode\unskip\unpenalty\fi
\fi}}

\makeatother

\begin{document}

\begin{wrapfigure}{r}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Figure with little text}
\label{hausdorffShapes}
\end{wrapfigure}
\b

\clearwf

\begin{wrapfigure}{l}{0.4\textwidth}
\centering
\includegraphics[width=0.38\textwidth]{none}
\caption{Another figure here}