Debian Codegraph @

texmf-dist/tex/generic/pgfplots/pgfplotsmeshplotimage.code.tex

raw
1 %--------------------------------------------
2 %
3 % Package pgfplots
4 %
5 % Provides a user-friendly interface to create function plots (normal
6 % plots, semi-logplots and double-logplots).
7 %
8 % It is based on Till Tantau's PGF package.
9 %
10 % Copyright 2007-2015 by Christian Feuersänger.
11 %
12 % This program is free software: you can redistribute it and/or modify
13 % it under the terms of the GNU General Public License as published by
14 % the Free Software Foundation, either version 3 of the License, or
15 % (at your option) any later version.
16 %
17 % This program is distributed in the hope that it will be useful,
18 % but WITHOUT ANY WARRANTY; without even the implied warranty of
19 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 % GNU General Public License for more details.
21 %
22 % You should have received a copy of the GNU General Public License
23 % along with this program. If not, see <http://www.gnu.org/licenses/>.
24 %
25 %--------------------------------------------
26
27 % This file essentially belongs to the 'mesh' plot handler.
28 % It implements the (rather involved) feature 'mesh input=image'.
29 %
30 % 'mesh input=image' is implemented during the visualization phase
31 % and, partially, during the survey phase. The survey phase merely
32 % updates the data limits. The visualization phase has the complete
33 % knowledge about the input matrix size and can compute the cells.
34
35 \def\pgfplotsplothandlersurveystart@mesh@image{%
36 \let\pgfplotsplothandlermesh@image@lastA=\pgfutil@empty
37 \let\pgfplotsplothandlermesh@image@lastlastA=\pgfutil@empty
38 \let\pgfplotsplothandlermesh@image@lastB=\pgfutil@empty
39 \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{1}%
40 \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{0}%
41 \def\c@pgfplotsplothandlermesh@image@numscanlines{0}%
42 %
43 \if\pgfplots@plot@mesh@ordering0%
44 % ordering = x varies= rowwise -> scanline is cols!
45 \def\pgfplotsplothandlermesh@image@A@dir{x}%
46 \def\pgfplotsplothandlermesh@image@B@dir{y}%
47 \def\pgfplotsplothandlermesh@image@updatelimits@AB##1##2##3{%
48 \pgfplotsaxisupdatelimitsforcoordinate{##1}{##2}{##3}%
49 }%
50 \else
51 % ordering = y varies = colwise: scanline is rows!
52 \def\pgfplotsplothandlermesh@image@A@dir{y}%
53 \def\pgfplotsplothandlermesh@image@B@dir{x}%
54 \def\pgfplotsplothandlermesh@image@updatelimits@AB##1##2##3{%
55 \pgfplotsaxisupdatelimitsforcoordinate{##2}{##1}{##3}%
56 }%
57 \fi
58 }%
59 \def\pgfplotsplothandlersurveyend@mesh@image{%
60 \if1\pgfplotsaxisplothasjumps
61 % the approach to interpolate cell corners using the adjacent cell midpoints becomes extremely complicated once
62 % we allow all kinds of holes in the input matrix.
63 % If you want to make invisible cells, you can add "nan" as color data
64 \pgfplots@error{Sorry, 'matrix plot' supports no holes (jumps) in the input data. Please implement jumps using an unbounded point meta value (i.e. inf or nan)}%
65 \fi
66 %
67 }%
68 \def\pgfplotsplothandlersurveypoint@mesh@image{%
69 % already called:
70 %\pgfplotsplothandlersurveypoint@default
71 %
72 % The 'update limits' routine for 'mesh input=image' is a
73 % HEURISTICS.
74 %
75 % It works well for "real" image plots, i.e. for those which are
76 % not skewed or changed parametrically.
77 %
78 % The main challenge is that we have to update the matrix limits
79 % while we pass through the scanlines.
80 %
81 % The idea is:
82 % - update cell midpoint limits using the standard PGFPlots
83 % methods. We would like to have the cell limits instead,
84 % though... to this end:
85 % - update the lower x cell limit for the first encountered X in every
86 % scanline
87 % - update the upper x cell limit for the last encountered X in every
88 % scanline
89 % - update the lower AND upper y cell limit for the first encountered Y
90 % in every scanline.
91 %
92 % That means:
93 % - we do NOT update X limits for mid points
94 % - we do NOT update Y limits for the second, third, ..., nth
95 % point on scanlines. Only for the first.
96 %
97 % For parametric image plots, these limits will be inaccurate. I
98 % suppose these are rather exotic anyway, so I accept that to
99 % simplify the implementation.
100 %
101 \expandafter\let\expandafter\pgfplotsplothandlermesh@cur\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@A@dir\endcsname
102 \expandafter\let\expandafter\pgfplotsplothandlermesh@cur@B\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@B@dir\endcsname
103 %
104 \if1\b@pgfplotsplothandlermesh@image@updatedlimits@A@next
105 \ifx\pgfplotsplothandlermesh@cur\pgfutil@empty
106 \else
107 \ifx\pgfplotsplothandlermesh@image@lastA\pgfutil@empty
108 \else
109 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@A@dir}{parse}{\pgfplotsplothandlermesh@image@lastA - 0.5*(\pgfplotsplothandlermesh@cur - \pgfplotsplothandlermesh@image@lastA)}%
110 \pgfplots@if{pgfplots@\pgfplotsplothandlermesh@image@A@dir islinear}{}{%
111 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@A@dir}{parsenumber}{\pgfmathresult}%
112 }
113 \let\pgfplots@current@point@xh=\pgfmathresult
114 \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplots@current@point@xh\pgfplotsplothandlermesh@cur@B\pgfplots@current@point@z
115 %
116 \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{0}%
117 \fi
118 \fi
119 \fi
120 %
121 \if1\b@pgfplotsplothandlermesh@image@updatedlimits@B@next
122 \ifx\pgfplotsplothandlermesh@cur@B\pgfutil@empty
123 \else
124 \ifx\pgfplotsplothandlermesh@image@lastB\pgfutil@empty
125 \else
126 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@B@dir}{parse}{\pgfplotsplothandlermesh@image@lastB - 0.5*(\pgfplotsplothandlermesh@cur@B - \pgfplotsplothandlermesh@image@lastB)}%
127 \pgfplots@if{pgfplots@\pgfplotsplothandlermesh@image@B@dir islinear}{}{%
128 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@B@dir}{parsenumber}{\pgfmathresult}%
129 }
130 \let\pgfplots@current@point@yh=\pgfmathresult
131 \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplotsplothandlermesh@cur\pgfplots@current@point@yh\pgfplots@current@point@z
132 %
133 %
134 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@B@dir}{parse}{\pgfplotsplothandlermesh@cur@B + 0.5*(\pgfplotsplothandlermesh@cur@B - \pgfplotsplothandlermesh@image@lastB)}%
135 \pgfplots@if{pgfplots@\pgfplotsplothandlermesh@image@B@dir islinear}{}{%
136 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@B@dir}{parsenumber}{\pgfmathresult}%
137 }
138 \let\pgfplots@current@point@yh=\pgfmathresult
139 \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplotsplothandlermesh@cur\pgfplots@current@point@yh\pgfplots@current@point@z
140 %
141 \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{0}%
142 \fi
143 \fi
144 \fi
145 \let\pgfplotsplothandlermesh@image@lastlastA=\pgfplotsplothandlermesh@image@lastA
146 \let\pgfplotsplothandlermesh@image@lastA=\pgfplotsplothandlermesh@cur
147 %
148 \let\pgfplotsplothandlermesh@image@lastB=\pgfplotsplothandlermesh@cur@B
149 }%
150
151 \def\pgfplotsplothandlersurveyend@mesh@image@scanlinecomplete{%
152 \ifx\pgfplotsplothandlermesh@image@lastlastA\pgfutil@empty
153 \else
154 \ifx\pgfplotsplothandlermesh@image@lastA\pgfutil@empty
155 \else
156 \expandafter\let\expandafter\pgfplotsplothandlermesh@cur@B\csname pgfplots@current@point@\pgfplotsplothandlermesh@image@B@dir\endcsname
157 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@A@dir}{parse}{\pgfplotsplothandlermesh@image@lastA + 0.5*(\pgfplotsplothandlermesh@image@lastA - \pgfplotsplothandlermesh@image@lastlastA)}%
158 \pgfplots@if{pgfplots@\pgfplotsplothandlermesh@image@A@dir islinear}{}{%
159 \pgfplotscoordmath{\pgfplotsplothandlermesh@image@A@dir}{parsenumber}{\pgfmathresult}%
160 }
161 \let\pgfplots@current@point@xh=\pgfmathresult
162 \pgfplotsplothandlermesh@image@updatelimits@AB\pgfplots@current@point@xh\pgfplotsplothandlermesh@cur@B\pgfplots@current@point@z
163 \fi
164 \fi
165 %
166 \def\b@pgfplotsplothandlermesh@image@updatedlimits@B@next{1}%
167 %
168 \let\pgfplotsplothandlermesh@image@lastlastA=\pgfutil@empty
169 \let\pgfplotsplothandlermesh@image@lastA=\pgfutil@empty
170 \def\b@pgfplotsplothandlermesh@image@updatedlimits@A@next{1}%
171 %
172 \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@numscanlines
173 }%
174
175 %
176 % The 'mesh' plot handler has a "visualization pipeline" as part of
177 % its visualization:
178 %
179 % if it is active, the coordinate stream used for the visualization
180 % (\pgfplotsplothandlermesh@stream) invokes
181 % \pgfplotsplothandlermesh@PIPE@DECODE as first item. This, in turn,
182 % fires other elements of the mesh plot pipeline, but its most
183 % important task is to assemble patches while it goes.
184 %
185 % That's where 'mesh input=image' hooks in: it simply generates special patches.
186
187 % this is part of the implementation of mesh input=image
188 % the pgf@plotstreampoint routine for the first scan line:
189 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@fillscanline#1{%
190 \pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline@common{#1}%
191 \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
192 % second line!
193 \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@image@secondscanline%%
194 \c@pgfplots@scanlineindex=0
195 \def\c@pgfplotsplothandlermesh@image@nextrownum{2}%
196 \fi
197 }%
198
199 % IDEA:
200 %
201 % 1. The first scanline is merely buffered and collected into the deque 'lastscanline' (just as any mesh plot).
202 % 2. The second scanline
203 % - generates cells for the first scanline _and_
204 % - appends the computed intermediate vertices to the deque 'lastinterpscanline'.
205 % - during the sweep, a single cell of the first scanline is
206 % generated
207 % - only the _last_ element of the scanline generates two cells
208 % 3. All scanlines after the second
209 % - pop the intermediate vertices from the deque
210 % - use them to construct cells for the previous scanline
211 % - append their computed intermediate vertices to the deque 'lastinterpscanline'.
212 % - during the sweep, a single cell of the first scanline is
213 % generated
214 % - only the _last_ element of the scanline generates two cells (just as in step 2)
215 % 4. the last scanline is special in that it generates cells for the
216 % previous scanline _and_ the last scanline.
217 %
218 % The "computed intermediate vertices" are mean values and
219 % extrapolation points. My idea is to make this special cell-based
220 % mesh more flexible than a simple imagesc, hoping that this pays off.
221 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@secondscanline#1{%
222 \pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback{#1}{%
223 %
224 % create cell:
225 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell{1}%
226 %
227 \advance\c@pgfplots@scanlineindex by1
228 \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
229 % ok, we have to extrapolate the last column.
230 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn{1}%
231 \fi
232 \advance\c@pgfplots@scanlineindex by-1
233 }{%
234 % if scanline is completed, switch states:
235 \let\pgfplotsplothandlermesh@PIPE@DECODE=\pgfplotsplothandlermesh@PIPE@DECODE@image@after@second%%
236 \c@pgfplots@scanlineindex=0
237 \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@nextrownum
238 }%
239 }%
240 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@after@second#1{%
241 \pgfplotsplothandlermesh@PIPE@DECODE@matrix@collect@and@callback{#1}{%
242 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell{0}%
243 %
244 \advance\c@pgfplots@scanlineindex by1
245 \ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
246 % ok, we have to extrapolate the last column.
247 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn{0}%
248 \fi
249 \advance\c@pgfplots@scanlineindex by-1
250 }{%
251 % if scanline is completed: advance to next
252 \c@pgfplots@scanlineindex=0
253 \pgfplotsutil@advancestringcounter\c@pgfplotsplothandlermesh@image@nextrownum
254 }%
255 }%
256
257 % To be used within the DECODE "loop" only! It assembles temporary
258 % variables for the next iteration (and consumes it).
259 %
260 % #1: '1' if topmost row is to be extrapolated, '0' if it should be
261 % acquired from the datastructure 'lastinterpscanline'
262 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell#1{%
263 \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
264 %
265 % we have to compute the four corners by means of
266 % averaging/extrapolation.
267 %
268 % We place the rectangle around (i-1,j-1), i.e. imjm
269 % Notation: the four corners are aa, ab, ba, and bb.
270 % aa ----- ab
271 % | |
272 % | |
273 % | imjm |
274 % | |
275 % | |
276 % ba ------ bb
277 %
278 % bb is the average of the four cell mid points of our
279 % scanline, the others are acquired from previous iterations
280 % or from extrapolation schemes.
281 %
282 % compute bb:
283 \pgfplotspatchvertexaccumstart
284 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
285 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{0.25}%
286 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{0.25}%
287 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{0.25}%
288 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{0.25}%
289 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@bb
290 \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@bb
291 %
292 %
293 \if1#1%
294 % Ah -- this here is the very first row! That means we
295 % have to extrapolate the topmost coordinates.
296 %
297 % Apply extrapolation for ab:
298 %
299 % compute ab = bb + 2* ( 1/2 (imj + imjm) - bb)
300 % which resolves to the following:
301 \pgfplotspatchvertexaccumstart
302 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
303 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
304 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{1.0}%
305 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{1.0}%
306 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ab
307 \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@im@j\to\pgfplotsplothandlermesh@ab
308 \else
309 \ifnum\c@pgfplots@scanlineindex=1
310 \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@aa
311 \fi
312 \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@ab
313 \fi
314 %
315 \ifnum\c@pgfplots@scanlineindex=1
316 % ah, we have to apply special treatment for the leftmost
317 % cell.
318 %
319 %
320 % compute ba = bb + 2* ( 1/2 (imjm + ijm) - bb)
321 % which resolves to the following:
322 \pgfplotspatchvertexaccumstart
323 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
324 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
325 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{1.0}%
326 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@jm\times{1.0}%
327 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ba
328 \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@ba
329 %
330 \if1#1%
331 % ok, extrapolate 'aa' as well:
332 %
333 % compute aa = ba + (ab - bb)
334 % which resolves to the following:
335 \pgfplotspatchvertexaccumstart
336 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
337 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
338 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{1.0}%
339 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ab\times{1.0}%
340 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@aa
341 \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@im@jm\to\pgfplotsplothandlermesh@aa
342 \else
343 % in this case, 'aa' has been fetched from the deque
344 % (from the previous scanline)
345 \fi
346 %
347 % as soon as we process the next scanline, we need to know the
348 % interpolated values -- they will become the top row of the
349 % next scanline's cells.
350 \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@ba\to{lastinterpscanline}%
351 \else
352 % ok, we take the left edge (ba and aa) from the previous
353 % iteration (see the end of this code where the previous
354 % loop iteration prepared them).
355 \fi
356 %
357 \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@im@jm\to\pgfplotsplothandlermesh@aa
358 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
359 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ab}%
360 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@bb}%
361 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ba}%
362 %
363 % ... and communicate this as well to the next scanline (see
364 % \pgfplotsplothandlermesh@PIPE@DECODE@image@after@second)
365 \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@bb\to{lastinterpscanline}%
366 %
367 \ifnum\c@pgfplotsplothandlermesh@image@nextrownum=\pgfplotsplothandlermesh@numscanlines\relax
368 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow
369 \fi
370 %
371 % merely shift the current points such that the next loop
372 % iteration can use them without modifications:
373 \let\pgfplotsplothandlermesh@ba=\pgfplotsplothandlermesh@bb
374 \let\pgfplotsplothandlermesh@aa=\pgfplotsplothandlermesh@ab
375 %
376 }%
377
378 % The color handling of 'matrix input=image' is quite involved.
379 % There are the following requirements:
380 % 1. the point meta of the cell's first vertex _must_ be equal to the point meta of the cell mid point, i.e. equal to the user input.
381 % 2. All other vertices should be interpolated "as smart as possible". This interpolation scheme should work even if adjacent cell midpoints have _no_ bounded meta data!
382 % 3. The routines which glue adjacent cells together have to ensure that they do not accidentally intermix (1) and (2). This is complicated since the sweep loop intermingles both responsibilities (sigh).
383 %
384 % This helper function ensures (1): it copies the point meta of the \pgfplotspatchvertex #1 to the values of of #2 and assigns the result to \pgfplotsretval.
385 % #1 a valid \pgfplotspatchvertex
386 % #2 a valid \pgfplotspatchvertex
387 %
388 % POSTCONDITION: \pgfplotsretval contains the result, i.e. a copy of '#2' which contains the point meta of '#1'.
389 \def\pgfplotsplothandlermesh@image@set@first@color@to#1\to#2{%
390 \let\pgfplotsretval=#2%
391 \pgfplotspatchvertexcopymeta#1\to\pgfplotsretval
392 }%
393
394 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow{%
395 %
396 \let\pgfplotsplothandlermesh@last@aa=\pgfplotsplothandlermesh@ba
397 \let\pgfplotsplothandlermesh@last@ab=\pgfplotsplothandlermesh@bb
398 %
399 % ASSUMPTION: we want to compute Laa, Lab, Lba and Lbb in the following setup:
400 %
401 % aa ----- ab
402 % | |
403 % | |
404 % | imjm |
405 % | |
406 % | |
407 % ba ------ bb
408 % =Laa =Lab
409 % | |
410 % | |
411 % | ijm |
412 % | |
413 % | |
414 % Lba------ Lbb
415 %
416 % compute Lbb = bb + 2 * (1/2 ( ijm + ij) - bb ). We assume that
417 % we can still access 'bb', the coordinate of the current point.
418 % This resolves to the following:
419 \pgfplotspatchvertexaccumstart
420 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
421 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{-1.0}%
422 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@jm\times{1.0}%
423 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{1.0}%
424 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@bb
425 % FIXME : which is the correctly extrapolated cdata!?
426 %\pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@bb
427 %
428 \ifnum\c@pgfplots@scanlineindex=1
429 % compute Lba = Lbb + Laa - Lab
430 \pgfplotspatchvertexaccumstart
431 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
432 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@bb\times{1.0}%
433 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@aa\times{1.0}%
434 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@ab\times{-1.0}%
435 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@ba
436 % FIXME : which is the correctly extrapolated cdata!?
437 %\pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@last@ba
438 \else
439 % transported from previous iteration.
440 \fi
441 %
442 \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@i@jm\to\pgfplotsplothandlermesh@last@aa
443 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
444 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ab}%
445 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@bb}%
446 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ba}%
447 %
448 \let\pgfplotsplothandlermesh@last@ba=\pgfplotsplothandlermesh@last@bb
449 }%
450
451 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow@lastcol{%
452 %
453 % ASSUMPTION: we want to compute Laa, Lab, Lba and Lbb in the following setup:
454 %
455 % aa ----- ab
456 % | |
457 % | |
458 % | imj |
459 % | |
460 % | |
461 % ba ------ bb
462 % =Laa =Lab
463 % | |
464 % | |
465 % | ij |
466 % | |
467 % | |
468 % Lba------ Lbb
469 \let\pgfplotsplothandlermesh@last@aa=\pgfplotsplothandlermesh@ba
470 \let\pgfplotsplothandlermesh@last@ab=\pgfplotsplothandlermesh@bb
471 %
472 % I mirrored the formula for lastrow.
473 \pgfplotspatchvertexaccumstart
474 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
475 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@bb\times{1.0}%
476 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@aa\times{-1.0}%
477 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@last@ab\times{1.0}%
478 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@last@bb
479 \pgfplotspatchvertexcopymetaifbounded\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@bb
480 %
481 \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@i@j\to\pgfplotsplothandlermesh@last@aa
482 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
483 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ab}%
484 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@bb}%
485 % this value is transported from previous iteration:
486 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@last@ba}%
487 }%
488
489 \def\pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastcolumn#1{%
490 \let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
491 %
492 % we have to compute the four corners by means of
493 % averaging/extrapolation.
494 %
495 % We place the rectangle around (i-1,j), i.e. imj.
496 % This is in contrast to
497 % \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell
498 % where we placed the rectangle around (i-1,j-1).
499 %
500 % Notation: the four corners are aa, ab, ba, and bb.
501 % aa ----- ab
502 % | |
503 % | |
504 % | imj |
505 % | |
506 % | |
507 % ba ------ bb
508 %
509 % We can simply copy aa and ba from the previous cell (as in
510 % the standard case). Note that this has already been prepared
511 % for us, i.e. the variables have already been set by the
512 % previous iteration.
513 %
514 % compute ab and bb by means of extrapolation:
515 %
516 % compute bb:
517 \pgfplotspatchvertexaccumstart
518 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
519 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{-1.0}%
520 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@im@j\times{1.0}%
521 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@i@j\times{1.0}%
522 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@bb
523 % FIXME : which is the correctly extrapolated cdata!?
524 %
525 %
526 \if1#1%
527 % Ah -- this here is the very first row! That means we
528 % have to extrapolate the topmost coordinates.
529 %
530 % Apply extrapolation for ab:
531 %
532 % compute ab = bb + (aa - ba)
533 \pgfplotspatchvertexaccumstart
534 \pgfplotspatchvertexaccum@configure@ignore@unboundedmetadata
535 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@bb\times{1.0}%
536 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@aa\times{1.0}%
537 \expandafter\pgfplotspatchvertexadd\pgfplotsplothandlermesh@ba\times{-1.0}%
538 \pgfplotspatchvertexfinish\pgfplotsplothandlermesh@ab
539 % FIXME : which is the correctly extrapolated cdata!?
540 \else
541 \pgfplotsdequepopfront{lastinterpscanline}\to\pgfplotsplothandlermesh@ab
542 \fi
543 %
544 \pgfplotsplothandlermesh@image@set@first@color@to\pgfplotsplothandlermesh@im@j\to\pgfplotsplothandlermesh@aa
545 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsretval}%
546 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ab}%
547 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@bb}%
548 \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@ba}%
549 %
550 % ... and communicate this as well to the next scanline (see
551 % \pgfplotsplothandlermesh@PIPE@DECODE@image@after@second)
552 \expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@bb\to{lastinterpscanline}%
553 %
554 \ifnum\c@pgfplotsplothandlermesh@image@nextrownum=\pgfplotsplothandlermesh@numscanlines\relax
555 \pgfplotsplothandlermesh@PIPE@DECODE@image@sweep@create@cell@lastrow@lastcol
556 \fi
557 }%