%!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````````````````````````````0|
% *------------------------------*

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                        %
% Licence                                                %
%                                                        %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 
% Copyright 2023-10-16 (original release) -- 2025, Matthias Fresacher
% 
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is found via
% http://www.latex-project.org/lppl.txt.

\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[typeN] (0.6, -3.4) -- (1.4, -3.4) -- (1.4, -1.7) -- (3.6, -1.7) -- (3.6, -3.4) -- (4.4, -3.4) -- (4.4, 0.7) -- (0.6, 0.7) -- cycle;
        \draw[typeB] (1.6, -3.4) rectangle (3.4, -2.3);
        \foreach \x in {0,2} {
            \begin{scope}[shift={(\x,0)}]
                \draw[typeT] (0.6, 1.3) rectangle (2.4, 2.4);
            \end{scope}
        }
    }
]{ % Added edges
    {1}{4}
}{ % Top Diagram
    { % Brick 1
        [ % Options
            degree=4
        ]{ % Upper non transversal edges
            {1}{2}
            {3}{4}
        }{ % Lower non transversal edges
            {1}{2}
            {3}{4}
        }{ % Transversal edges
            \pmdEmpty
        }
    }
}{ % Bottom Diagram
    { % Brick 1
        [ % Options
            degree=4
        ]{ % Upper non transversal edges
            {2}{3}
        }{ % Lower non transversal edges
            {2}{3}
        }{ % Transversal edges
            {1}{1}
            {4}{4}
        }
    }
}
\hspace{5em}
\pmdProduct[ % Options
    decorate before={
        \blockStyles
        \draw[typeN] (0.6, -3.4) -- (1.4, -3.4) -- (1.4, -1.7) -- (10.6, -1.7) -- (10.6, -3.4) -- (11.4, -3.4) -- (11.4, 0.7) -- (0.6, 0.7) -- cycle;
        \foreach \x in {0,2,4,7,9} {
            \begin{scope}[shift={(\x,0)}]
                \draw[typeT] (0.6, 1.3) rectangle (2.4, 2.4);
            \end{scope}
        }
        \foreach \x in {1,3,8} {
            \begin{scope}[shift={(\x,0)}]
                \draw[typeB] (0.6, -3.4) rectangle (2.4, -2.3);
            \end{scope}
        }
    }
]{ % Added edges
    {1}{5}
    {9}{11}
}{ % Top 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=4
        ]{ % Upper non transversal edges
            {1}{2}
            {3}{4}
        }{ % Lower non transversal edges
            {1}{2}
            {3}{4}
        }{ % Transversal edges
            \pmdEmpty
        }
    }
}{ % Bottom 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,
            blank bottom=2,
            degree=3
        ]{ % Upper non transversal edges
            {3}{4}
        }{ % Lower non transversal edges
            {3}{4}
        }{ % Transversal edges
            {5}{5}
        }
    }
}
