File size: 6,111 Bytes
c09a3f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
\ProvidesPackage{RightBandedBox}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This Block can draw simple block of boxes with custom colors. 
% Can be used for conv, deconv etc
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\tikzset{RightBandedBox/.pic={\tikzset{/block/.cd,#1}
                
        \tikzstyle{box}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=\opacity, pic actions,fill=\fill]
        
        \tikzstyle{band}=[every edge/.append style={pic actions, densely dashed, opacity=.7},fill opacity=\bandopacity, pic actions,fill=\bandfill,draw=\bandfill]
        
        \pgfmathsetmacro{\y}{\cubey*\scale}
        \pgfmathsetmacro{\z}{\cubez*\scale}

        %Multiple concatenated boxes	 	  	
        \foreach[count=\i,%
                 evaluate=\i as \xlabel using {array({\boxlabels},\i-1)},% 
                 evaluate=\unscaledx as \k using {\unscaledx*\scale+\prev}, remember=\k as \prev (initially 0)] 
                 \unscaledx in \cubex
        {
            \pgfmathsetmacro{\x}{\unscaledx*\scale}
            \coordinate (a)     at (\k-\x   , \y/2 , \z/2); 
            \coordinate (art)   at (\k-\x/3 , \y/2 , \z/2); %a_right_third
            \coordinate (b)     at (\k-\x   ,-\y/2 , \z/2); 
            \coordinate (brt)   at (\k-\x/3 ,-\y/2 , \z/2); %b_right_third
            \coordinate (c)     at (\k      ,-\y/2 , \z/2); 
            \coordinate (d)     at (\k      , \y/2 , \z/2); 
            \coordinate (e)     at (\k      , \y/2 ,-\z/2); 
            \coordinate (f)     at (\k      ,-\y/2 ,-\z/2); 
            \coordinate (g)     at (\k-\x   ,-\y/2 ,-\z/2); 
            \coordinate (h)     at (\k-\x   , \y/2 ,-\z/2); 
            \coordinate (hrt)   at (\k-\x/3 , \y/2 ,-\z/2); %h_right_third
            
            %fill box color 			
            \draw [box] 
                (d) -- (a) -- (b) -- (c) -- cycle     
                (d) -- (a) -- (h) -- (e) -- cycle;
            %dotted edges
            \draw [box]
                (f) edge (g)
                (b) edge (g)
                (h) edge (g);
            %fill band color    
            \draw [band] 
                (d) -- (art) -- (brt) -- (c) -- cycle     
                (d) -- (art) -- (hrt) -- (e) -- cycle;
            %draw edges again which were covered by band
            \draw [box,fill opacity=0] 
                (d) -- (a) -- (b) -- (c) -- cycle     
                (d) -- (a) -- (h) -- (e) -- cycle;            
            	
            \path (b) edge ["\xlabel"',midway] (c);

            

            \xdef\LastEastx{\k} %\k persists as \LastEastx after loop 

        }%Loop ends

        \draw [box] (d) -- (e) -- (f) -- (c) -- cycle; %East face of last box

        \draw [band] (d) -- (e) -- (f) -- (c) -- cycle; %East face of last box 

        \draw [pic actions] (d) -- (e) -- (f) -- (c) -- cycle; %East face edges of last box     

        

        \coordinate (a1) at (0 , \y/2 , \z/2);

        \coordinate (b1) at (0 ,-\y/2 , \z/2);

        \tikzstyle{depthlabel}=[pos=0,text width=14*\z,text centered,sloped]       

        

        \path (c) edge ["\small\zlabels"',depthlabel](f); %depth label
        \path (b1) edge ["\ylabel",midway] (a1);  %height label 	  
        
        \tikzstyle{captionlabel}=[text width=15*\LastEastx/\scale,text centered] 
        \path (\LastEastx/2,-\y/2,+\z/2) + (0,-25pt) coordinate (cap) 
        edge ["\textcolor{black}{ \bf \caption}"',captionlabel] (cap); %Block caption/pic object label

         

        %Define nodes to be used outside on the pic object

        \coordinate (\name-west)   at (0,0,0) ;

        \coordinate (\name-east)   at (\LastEastx, 0,0) ;

        \coordinate (\name-north)  at (\LastEastx/2,\y/2,0);

        \coordinate (\name-south)  at (\LastEastx/2,-\y/2,0);       

        \coordinate (\name-anchor) at (\LastEastx/2, 0,0) ;

        

        \coordinate (\name-near) at (\LastEastx/2,0,\z/2);

        \coordinate (\name-far)  at (\LastEastx/2,0,-\z/2);       

        

        \coordinate (\name-nearwest) at (0,0,\z/2);

        \coordinate (\name-neareast) at (\LastEastx,0,\z/2);

        \coordinate (\name-farwest)  at (0,0,-\z/2);

        \coordinate (\name-fareast)  at (\LastEastx,0,-\z/2);

        

        \coordinate (\name-northeast) at (\name-north-|\name-east);

        \coordinate (\name-northwest) at (\name-north-|\name-west);

        \coordinate (\name-southeast) at (\name-south-|\name-east);

        \coordinate (\name-southwest) at (\name-south-|\name-west);

        

        \coordinate (\name-nearnortheast)  at (\LastEastx, \y/2, \z/2);

        \coordinate (\name-farnortheast)   at (\LastEastx, \y/2,-\z/2);

        \coordinate (\name-nearsoutheast)  at (\LastEastx,-\y/2, \z/2);

        \coordinate (\name-farsoutheast)   at (\LastEastx,-\y/2,-\z/2);

        

        \coordinate (\name-nearnorthwest)  at (0, \y/2, \z/2);

        \coordinate (\name-farnorthwest)   at (0, \y/2,-\z/2);

        \coordinate (\name-nearsouthwest)  at (0,-\y/2, \z/2);

        \coordinate (\name-farsouthwest)   at (0,-\y/2,-\z/2);

    },

    /block/.search also={/tikz},

    /block/.cd,

    width/.store        in=\cubex,

    height/.store       in=\cubey,

    depth/.store        in=\cubez,

    scale/.store        in=\scale,

    xlabel/.store       in=\boxlabels,

    ylabel/.store       in=\ylabel,

    zlabel/.store       in=\zlabels,

    caption/.store      in=\caption,

    name/.store         in=\name,

    fill/.store         in=\fill,

    bandfill/.store     in=\bandfill,

    opacity/.store      in=\opacity,

    bandopacity/.store  in=\bandopacity,

    fill={rgb:red,5;green,5;blue,5;white,15},

    bandfill={rgb:red,5;green,5;blue,5;white,5},

    opacity=0.4,

    bandopacity=0.6,

    width=2,

    height=13,

    depth=15,

    scale=.2,

    xlabel={{"","","","","","","","","",""}},

    ylabel=,

    zlabel=,

    caption=,

    name=,

}