%!TEX root = ../pmdraw.tex

% *------------------------------*
% |0````````````````````````````9|
% |`````____````____`````````````|
% |````|MFMF\  /MFMF|````````````|
% |````|MF|MF\/MF|MF|````````````|
% |````|MF|\MFMF/|MF|_______`````|
% |````|MF|``````|MFMFMFMFMF|````|
% |````|MF|``````|MF|````````````|
% |````|MF|``````|MF|___`````````|
% |``````````````|MFMFMF|````````|
% |``````````````|MF|````````````|
% |``````````````|MF|````````````|
% |``````````````|MF|````````````|
% |3````````````````````````````8|
% *------------------------------*

\usetikzlibrary{patterns}

\newcommand{\blockStyles}{
    \tikzstyle{typeI} = [
        very thick,
        rounded corners=5pt,
        red,
        preaction={fill, red!3}
    ]
    \tikzstyle{typeT} = [
        very thick,
        rounded corners=5pt,
        dash pattern={on 7.5pt off 2.5pt},
        green,
        preaction={fill, green!3}
    ]
    \tikzstyle{typeB} = [
        very thick,
        rounded corners=5pt,
        dash pattern={on 2.5pt off 2.5pt},
        blue,
        preaction={fill, blue!3}
    ]
    \tikzstyle{typeO} = [
        very thick,
        rounded corners=5pt,
        dash pattern={on 2.5pt off 2.5pt on 7.5pt off 2.5pt},
        orange,
        preaction={fill, orange!3}
    ]
    \tikzstyle{typeU} = [
        very thick,
        rounded corners=5pt,
        dash pattern={on 2.5pt off 2.5pt on 2.5pt off 2.5pt on 7.5pt off 2.5pt},
        violet,
        preaction={fill, violet!3}
    ]
    \tikzstyle{typeN} = [
        very thick,
        rounded corners=5pt,
        dash pattern={on 7.5pt off 2.5pt on 7.5pt off 2.5pt on 2.5pt off 2.5pt},
        yellow,
        preaction={fill, yellow!3}
    ]
}

\pmdProduct[ % Options
    decorate before={
        \blockStyles
        \draw[typeI] (0.6, 2.4) -- (1.4, 2.4) -- (1.4, 0.7) -- (3.4, 0.7) -- (3.4, -3.4) -- (2.6, -3.4) -- (2.6, -1.7) -- (0.6, -1.7) -- cycle;
        \draw[typeT] (1.6, 1.3) rectangle (3.4, 2.4);
        \draw[typeB] (0.6, -3.4) rectangle (2.4, -2.3);
    }
]{ % Added edges
    {1}{3}
}{ % Top Diagram
    { % Brick 1
        [ % Options
            degree=3
        ]{ % Upper non transversal edges
            {2}{3}
        }{ % Lower non transversal edges
            {2}{3}
        }{ % Transversal edges
            {1}{1}
        }
    }
}{ % Bottom Diagram
    { % Brick 1
        [ % Options
            degree=3
        ]{ % Upper non transversal edges
            {1}{2}
        }{ % Lower non transversal edges
            {1}{2}
        }{ % Transversal edges
            {3}{3}
        }
    }
}
\hspace{5em}
\pmdProduct[ % Options
    decorate before={
        \blockStyles
        \draw[typeI] (0.6, 2.4) -- (1.4, 2.4) -- (1.4, 0.7) -- (10.4, 0.7) -- (10.4, -3.4) -- (9.6, -3.4) -- (9.6, -1.7) -- (0.6, -1.7) -- cycle;
        \foreach \x in {0,2,7} {
            \begin{scope}[shift={(\x,0)}]
                \draw[typeT] (1.6, 1.3) rectangle (3.4, 2.4);
            \end{scope}
        }
        \foreach \x in {0,2,4,7} {
            \begin{scope}[shift={(\x,0)}]
                \draw[typeB] (0.6, -3.4) rectangle (2.4, -2.3);
            \end{scope}
        }
    }
]{ % Added edges
    {1}{5}
    {9}{10}
}{ % Top Diagram
    { % Brick 1
        [ % Options
            degree=5
        ]{ % Upper non transversal edges
            {2}{3}
            {4}{5}
        }{ % Lower non transversal edges
            {2}{3}
            {4}{5}
        }{ % Transversal edges
            {1}{1}
        }
    }{ % Brick 2
        [ % Options
            blank top=2,
            degree top=2,
            blank bottom=2,
            degree bottom=2
        ]{ % Upper non transversal edges
            {3}{4}
        }{ % Lower non transversal edges
            {3}{4}
        }{ % Transversal edges
            \pmdEmpty
        }
    }
}{ % Bottom Diagram
    { % Brick 1
        [ % Options
            degree=6
        ]{ % Upper non transversal edges
            {1}{2}
            {3}{4}
            {5}{6}
        }{ % Lower non transversal edges
            {1}{2}
            {3}{4}
            {5}{6}
        }{ % Transversal edges
            \pmdEmpty
        }
    }{ % Brick 2
        [ % Options
            degree=3
        ]{ % Upper non transversal edges
            {1}{2}
        }{ % Lower non transversal edges
            {1}{2}
        }{ % Transversal edges
            {3}{3}
        }
    }
}