summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex')
-rw-r--r--Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex340
1 files changed, 316 insertions, 24 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex
index 5084cd21b1e..8641fed58aa 100644
--- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex
+++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsmeshplothandler.code.tex
@@ -246,14 +246,20 @@
%%
%% Helper structs for patch plots (surfaces)
-\def\pgfplotspatchvertex#1#2#3#4\endvertex{%
- \def\pgfplotspatchvertexstruct{{#1}{#2}{#3}#4}%
+% #1: the canvas x coordinate
+% #2: the canvas y coordinate
+% #3: the point meta data (cdata)
+% #4: the vertex'es depth (if required)
+% #5: the 3d coordinates of the vertex (will only be stored if it is deemed necessary)
+\def\pgfplotspatchvertex#1#2#3#4:#5\endvertex{%
+ \def\pgfplotspatchvertexstruct{{#1}{#2}{#3}#4:#5}%
\def\pgfplotspatchvertexx{#1}%
\def\pgfplotspatchvertexy{#2}%
\def\pgfplotspatchvertexmeta{#3}%
\def\pgfplotspatchvertexdepth{#4}%
+ \def\pgfplotspatchvertexcoords{#5}%
}%
-\def\pgfplotspointpatchvertex#1#2#3#4\endvertex{%
+\def\pgfplotspointpatchvertex#1#2#3#4:#5\endvertex{%
\global\pgf@x=#1
\global\pgf@y=#2
}%
@@ -275,36 +281,36 @@
\pgf@yb=0pt
\pgfplotscoordmath{meta}{zero}%
}%
-\def\pgfplotspatchvertexadd#1#2#3#4\times#5{%
+\def\pgfplotspatchvertexadd#1#2#3#4:#5\times#6{%
\global\pgf@x=#1
\global\pgf@y=#2
- \advance\pgf@xa by#5\pgf@x
- \advance\pgf@ya by#5\pgf@y
+ \advance\pgf@xa by#6\pgf@x
+ \advance\pgf@ya by#6\pgf@y
\let\pgfmathresult@=\pgfmathresult
- \pgfplotscoordmath{meta}{parsenumber}{#5}%
+ \pgfplotscoordmath{meta}{parsenumber}{#6}%
\pgfplotscoordmath{meta}{op}{multiply}{{#3}{\pgfmathresult}}%
\pgfplotscoordmath{meta}{op}{add}{{\pgfmathresult@}{\pgfmathresult}}%
\def\pgfplotspatchvertexdepth{#4}%
\ifx\pgfplotspatchvertexdepth\pgfutil@empty
\else
\global\pgf@y=#4pt
- \advance\pgf@yb by#5\pgf@y
+ \advance\pgf@yb by#6\pgf@y
\fi
}%
\def\pgfplotspatchvertexfinish#1{%
- \edef#1{{\the\pgf@xa}{\the\pgf@ya}{\pgfmathresult}\ifx\pgfplotspatchvertexdepth\pgfutil@empty\else\pgf@sys@tonumber\pgf@yb\fi}%
+ \edef#1{{\the\pgf@xa}{\the\pgf@ya}{\pgfmathresult}\ifx\pgfplotspatchvertexdepth\pgfutil@empty\else\pgf@sys@tonumber\pgf@yb\fi:}%
}
% Same as \pgfplotspatchvertexadd, but it only adds the X and Y
% coordinates (ignoring the rest).
-\def\pgfplotspatchvertexaddXY#1#2#3#4\times#5{%
+\def\pgfplotspatchvertexaddXY#1#2#3#4:#5\times#6{%
\global\pgf@x=#1
\global\pgf@y=#2
- \advance\pgf@xa by#5\pgf@x
- \advance\pgf@ya by#5\pgf@y
+ \advance\pgf@xa by#6\pgf@x
+ \advance\pgf@ya by#6\pgf@y
}%
% Same as \pgfplotspatchvertexfinish, but it only saves X and Y.
\def\pgfplotspatchvertexfinishXY#1{%
- \edef#1{{\the\pgf@xa}{\the\pgf@ya}{}}%
+ \edef#1{{\the\pgf@xa}{\the\pgf@ya}{}:}%
}
% #1 class name
@@ -415,6 +421,9 @@
recursive refine@={%
\pgfplots@error{refine: not yet implemented for \pgfplotspatchclassname}%
},%
+ compute normal={%
+ \pgfplotsplothandlermesh@compute@normal@default
+ },%
}%
}{}%
%
@@ -580,8 +589,80 @@
get pdf shading type/.style={get pdf shading type*={\def\pgfplotsretval{#1}}},
get pdf shading type*/.code=
{\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ get pdf shading type\endcsname{#1}},%
+ %
+ % A method which defines \pgfplotsretval to be the normal of the current segment.
+ % The values will be given in a format understood by
+ % \pgfplotsmathvectortostring{\pgfplotsretval}{default}
+ %
+ % This method REQUIRES that 3d coordinates are stored (see \pgfplotsplothandlermesh@serialize@logical@coords).
+ compute normal/.code=
+ {\expandafter\def\csname pgfpptch\pgfplotsdeclarepatchclass@ compute normal\endcsname{#1}},%
}
+% This implements 'compute normal' :
+\def\pgfplotsplothandlermesh@compute@normal@default{%
+ \begingroup
+ \c@pgf@countd=0
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+ \ifx\pgfplotspatchvertexcoords\pgfutil@empty
+ \pgfplotsplothandlermesh@compute@normal@error
+ \fi
+ \pgfplotsmathvectorfromstring{\pgfplotspatchvertexcoords}{default}%
+ \expandafter\let\csname point\the\c@pgf@countd\endcsname=\pgfplotsretval
+ \let\pointlast=\pgfplotsretval
+ \advance\c@pgf@countd by1 %
+ }%
+ \pgfplotsmathvectorsubtract{\csname point1\endcsname}{\csname point0\endcsname}{default}%
+ \let\diffA=\pgfplotsretval
+ % Hm. usually, I would use \point2 here... but it turned out that
+ % the result looks ugly for rectangular patches -- so I used the
+ % last point instead (which is, at least, consistent with the
+ % patch boundaries)
+ \pgfplotsmathvectorsubtract{\csname pointlast\endcsname}{\csname point0\endcsname}{default}%
+ \let\diffB=\pgfplotsretval
+ \pgfplotsmathvectorcrossprod{\diffA}{\diffB}{default}%
+ \let\crossAB=\pgfplotsretval
+ % this here is an experiment to use the MEAN of two normal
+ % vectors for rectangular patches... but it did not work as good
+ % as expected:
+ % \pgfplotspatchclass{\pgfplotspatchclassname}{get num vertices}%
+ % \ifnum\pgfplotsretval=4
+ % \pgfplotsmathvectorsubtract{\csname point3\endcsname}{\csname point0\endcsname}{default}%
+ % \let\diffC=\pgfplotsretval
+ % \pgfplotsmathvectorcrossprod{\diffB}{\diffC}{default}%
+ % \let\crossBC=\pgfplotsretval
+ % \pgfplotsmathvectoradd{\crossAB}{\crossBC}{default}%
+ % \pgfplotscoordmath{default}{parsenumber}{0.5}%
+ % \pgfplotsmathvectorscale{\pgfplotsretval}{\pgfmathresult}{default}%
+ % \let\normal=\pgfplotsretval
+ % \else
+ \let\normal=\crossAB
+ %\fi
+ %
+ % specific choices of z buffering change the sequence of points.
+ % If the number of reversals is off, we need to switch the
+ % normal's sign:
+ \def\pgfplots@switch@normal@dir{0}%
+ \if1\pgfplotsplothandlermesh@zbuffer@choice
+ % z buffer=reverse x seq
+ \def\pgfplots@switch@normal@dir{1}%
+ \else
+ \if2\pgfplotsplothandlermesh@zbuffer@choice
+ % z buffer=reverse y seq
+ \def\pgfplots@switch@normal@dir{1}%
+ \fi
+ \fi
+ \if1\pgfplots@switch@normal@dir
+ \pgfplotscoordmath{default}{parsenumber}{-1}%
+ \pgfplotsmathvectorscale{\normal}{\pgfmathresult}{default}%
+ \fi
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+}%
+\def\pgfplotsplothandlermesh@compute@normal@error{%
+ \pgfplots@error{Cannot compute normal vectors: due to some reason, only canvas coordinates of the involved patch are available in this context, but the original input coordinates are required. This indicates an incompatible combination of variables (sorry). Please report this as a bug}%
+}%
+
\def\pgfplotspatchclass@recursiverefine#1{%
\c@pgf@counta=#1
\ifnum\c@pgf@counta=1
@@ -885,8 +966,8 @@
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}10%
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}21%
\expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@A}%
- \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
\expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@B}%
+ \expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotspatchclass@rect@D}%
%
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}01%
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set edge visible}11%
@@ -1174,6 +1255,17 @@
\if\pgfplotsplothandlermesh@zbuffer@choice4% 'z buffer=sort':
\def\b@pgfplotsplothandlermesh@matrixoutput{0}%
\fi
+ %
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
+ %
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPc
+ \ifx\pgfplots@loc@TMPc\pgfutil@empty
+ \else
+ \pgfplots@warning{the combination 'shader=interp,interior colormap name' is inefficient (it uses 'shader=faceted interp,faceted color=none') and may slow down the *display* of your document}%
+ \pgfplotsset{shader=faceted interp,faceted color=none}%
+ \fi
+ \fi
\if2\pgfplotsplothandlermesh@shader
\else
% 'shader!=interp'
@@ -1194,8 +1286,8 @@
% no matrix output possible
\if5\pgfplotsretval
% pdf shading type=5 (matrix output)
- \ifnum\pgfplotsplothandlermesh@shader>1
- % shader=interp or shader=faceted interp
+ \if2\pgfplotsplothandlermesh@shader
+ % shader=interp
%
% oh. shading type=5 is *essentially* the same as
% matrix output, but matrix output is forbidden.
@@ -1203,6 +1295,9 @@
% triangles:
\def\pgfplotsplothandlermesh@triangulate{1}%
\def\pgfplotsplothandlermesh@patchclass@output{triangle}%
+ % Note shader=faceted interp can be written as
+ % matrix -- it shades individual elements anyway;
+ % and one single patch can be written as matrix.
\fi
\fi
\fi
@@ -1235,6 +1330,12 @@
% handling of jumps.
\pgfplotsplothandlermesh@init@jumphandling
%
+ \ifpgfplotsplothandlermesh@shownormals
+ \let\pgfplotsplothandlermesh@show@normals@if@configured=\pgfplotsplothandlermesh@show@normals
+ % actually store 3d coordinates:
+ \let\pgfplotsplothandlermesh@serialize@logical@coords=\pgfplotsplothandlermesh@serialize@logical@coords@doit
+ \fi
+ %
% z buffering:
\pgfplotsplothandlermesh@init@zbuffer
%
@@ -1245,6 +1346,46 @@
}%
\def\pgfplotsplothandlermesh@patchclass@defaulttext{default}%
+% implements 'show normals'. Keep in mind that this is more-or-less a
+% debugging helper, not productive code.
+\def\pgfplotsplothandlermesh@show@normals{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+ \let\pgfplots@normal@vector=\pgfplotsretval
+%\pgfplotsmathvectortostring\pgfplots@normal@vector{default}%
+%\message{got normal \pgfplotsretval^^J}%
+ \pgfplotsmathvectorlength{\pgfplots@normal@vector}{default}%
+ \pgfplotscoordmath{default}{parsenumber}{\pgfkeysvalueof{/pgfplots/mesh/show normals length factor}}% FIXME
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfmathresult}{\pgfplotsretval}}%
+ \pgfplotsmathvectorscale{\pgfplots@normal@vector}{\pgfmathresult}{default}%
+ %\pgfplotsmathvectoradd{\pgfplotspatchvertexcoords}{\pgfplotsretval}{default}%
+ \let\pgfplots@normal@vector=\pgfplotsretval
+ %
+ \draw[/pgfplots/every patch normal]
+ \pgfextra{%
+ \pgfpathmoveto
+ {%
+ \pgf@process{%
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{get num vertices}%
+ \pgfmath@basic@reciprocal@{\pgfplotsretval}%
+ \let\scale=\pgfmathresult
+ \pgfplotspatchvertexaccumstart
+ \pgfplotspatchclass{\pgfplotspatchclassname}{foreach vertex}{%
+ \expandafter\pgfplotspatchvertexadd\pgfplotspatchvertexstruct\times{\scale}%
+ }%
+ \pgfplotspatchvertexfinishXY{\pgfplots@loc@TMPa}%
+ \expandafter\pgfplotspointpatchvertex\pgfplots@loc@TMPa\endvertex%
+ }%
+ }%
+ \edef\pgfplots@loc@TMPa{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
+ %
+ \pgfpathlineto{%
+ \pgfpointadd
+ {\pgfplots@loc@TMPa}
+ {\pgfplotspointfromcsvvector\pgfplots@normal@vector{default}}%
+ }%
+ }%
+ ;
+}%
% Defines \pgfplotsretval to be either empty or the current point's
% depth according to z buffer information.
@@ -1255,10 +1396,44 @@
% contain the view depth.
%
\def\pgfplotsplothandlermesh@compute@vertex@depth@doit{%
- \pgfplotsmathviewdepthxyz{\pgfplots@current@point@x}{\pgfplots@current@point@y}{\pgfplots@current@point@z}% FIXME relies on pgfplots macros
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \pgfplotsmathvectorviewdepth{\pgfplotsretval}%
+ \pgfplotscoordmath{default}{tofixed}{\pgfplotsretval}%
\edef\pgfplotsretval{\pgfmathresult}%
}%
+% A command which defines \pgfplotsretval to be either empty or to
+% the (x,y,z) 3d coordinates of the data point. Usually, the data
+% scaling transformation will already be applied to these points.
+%
+% Note that this is unnecessary for most applications of mesh plots.
+%
+% The resulting value will be available as \pgfplotspatchvertexcoords
+\def\pgfplotsplothandlermesh@serialize@logical@coords{%
+ % empty by default
+ \let\pgfplotsretval=\pgfutil@empty
+}%
+\def\pgfplotsplothandlermesh@serialize@logical@coords@doit{%
+ \ifx\pgfplots@current@point@x\pgfutil@empty
+ \let\pgfplotsretval=\pgfutil@empty
+ \else
+ % note that these points are the result of the data scaling
+ % trafo. That is OK because the view normal is also in the
+ % same coordinate space.
+ \pgfplotsmathvectorfromstring{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}{default}%
+ \fi
+}
+
+% the inverse for \pgfplotsplothandlermesh@serialize@logical@coords: it defines \pgfplots@current@point@[xyz].
+% You should only call it if you know that there IS something to deserialize.
+\def\pgfplotsplothandlermesh@deserialize@logical@coords#1{%
+ \expandafter\pgfplotsplothandlermesh@deserialize@logical@coords@#1\relax
+}%
+\def\pgfplotsplothandlermesh@deserialize@logical@coords@#1,#2,#3\relax{%
+ \def\pgfplots@current@point@x{#1}%
+ \def\pgfplots@current@point@y{#2}%
+ \def\pgfplots@current@point@z{#3}%
+}%
% The patch visualization works like a PIPELINE:
%
@@ -1285,9 +1460,11 @@
\def\pgfplotsplothandlermesh@PIPE@DECODE#1{%
\let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
\pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
\pgf@process{#1}%
% calls \pgfplotspatchready when ready
- \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set next vertex}{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplotsretval}%%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{set next vertex}{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%%
}%
\def\pgfplotspatchready{%
\pgfplotsplothandlermesh@PIPE@CHECKJUMP
@@ -1310,6 +1487,11 @@
% invoked when a patch is completely processed.
% This might be replaced by the z buffering algorithm
\def\pgfplotsplothandlermesh@PIPE@FINISH{%
+ \pgfplotsplothandlermesh@PIPE@interior@exterior@styles
+}%
+
+\def\pgfplotsplothandlermesh@PIPE@interior@exterior@styles{%
+ \pgfplotsplothandlermesh@interior@exterior@hook
\pgfplotsplothandlermesh@VISUALIZE
}%
@@ -1318,11 +1500,14 @@
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{fill path}%
\pgfplotsplothandlermesh@definecolor
\pgfplotsplothandlermesh@usepath
+ \pgfplotsplothandlermesh@show@normals@if@configured
}%
\let\pgfplotsplothandlermesh@VISUALIZE@std=\pgfplotsplothandlermesh@VISUALIZE@std@fill@andor@stroke
\let\pgfplotsplothandlermesh@VISUALIZE=\pgfplotsplothandlermesh@VISUALIZE@std
+\let\pgfplotsplothandlermesh@show@normals@if@configured\relax
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\pgfplotsplothandlermesh@init@DECODE{%
@@ -1582,10 +1767,87 @@
\fi
}%
+\let\pgfplotsplothandlermesh@interior@exterior@hook=\relax
+\def\pgfplotsplothandlermesh@interior@exterior@hook@active@zerothresh{%
+ \begingroup
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+% \let\pgfplots@normal=\pgfplotsretval
+% \pgfplotsmathvectorlength{\pgfplotsretval}{default}%
+% \pgfplotscoordmath{default}{op}{reciprocal}{{\pgfplotsretval}}%
+% \pgfplotsmathvectorscale{\pgfplots@normal}{\pgfmathresult}{default}%
+ %
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplotsretval}{default}%
+ \pgfplotscoordmath{default}{if is}{\pgfplotsretval}{-}{%
+ % <0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@interior
+ }{%
+ % >=0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@exterior
+ }%
+ \endgroup
+ \pgfplots@glob@TMPc
+}%
+
+\def\pgfplotsplothandlermesh@interior@exterior@hook@active{%
+ \begingroup
+ \pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{compute normal}%
+ \let\pgfplots@normal=\pgfplotsretval
+ \pgfplotsmathvectorlength{\pgfplotsretval}{default}%
+ \let\pgfplots@normal@len=\pgfplotsretval
+ %
+ \pgfplotsmathvectorscalarproduct{\pgfplots@view@dir@threedim}{\pgfplots@normal}{default}%
+ \let\pgfplots@dot=\pgfplotsretval
+ \pgfplotscoordmath{default}{op}{multiply}{{\pgfplots@view@dir@threedim@len}{\pgfplots@normal@len}}%
+ \pgfplotscoordmath{default}{op}{divide}{{\pgfplots@dot}{\pgfmathresult}}%
+
+ \pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplotsplothandlermesh@interior@thresh}{%
+ % <0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@interior
+ }{%
+ % >=0:
+ \global\let\pgfplots@glob@TMPc\pgfplotsplothandlermesh@is@exterior
+ }%
+ \endgroup
+ \pgfplots@glob@TMPc
+}%
+
+
+% only used if
+% \pgfplotsplothandlermesh@interior@exterior@hook@active is
+% active
+\def\pgfplotsplothandlermesh@is@interior{%
+%\def\pgfplotsplothandlermesh@usepath{\pgfusepath{discard}}%
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname@interior
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsplothandlermesh@shader@colormap@interior
+}%
+\def\pgfplotsplothandlermesh@is@exterior{%
+%\let\pgfplotsplothandlermesh@usepath=\pgfusepathqfillstroke
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsplothandlermesh@shader@colormap
+}%
\def\pgfplotsplothandlermesh@init@cdata{%
% Ok, we have color data.
%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplotsplothandlermesh@colormapname
+ %
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplotsplothandlermesh@colormapname@interior
+ \ifx\pgfplotsplothandlermesh@colormapname@interior\pgfutil@empty
+ \else
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap thresh}\pgfplotsplothandlermesh@interior@thresh
+ \pgfplotscoordmath{default}{parsenumber}{\pgfplotsplothandlermesh@interior@thresh}%
+ \let\pgfplotsplothandlermesh@interior@thresh=\pgfmathresult
+ \pgfplotscoordmath{default}{if is}{\pgfplotsplothandlermesh@interior@thresh}{0}{%
+ \let\pgfplotsplothandlermesh@interior@exterior@hook=\pgfplotsplothandlermesh@interior@exterior@hook@active@zerothresh
+ }{%
+ \pgfplotsmathvectorlength{\pgfplots@view@dir@threedim}{default}% should be 1, but never mind
+ \let\pgfplots@view@dir@threedim@len=\pgfplotsretval
+ \let\pgfplotsplothandlermesh@interior@exterior@hook=\pgfplotsplothandlermesh@interior@exterior@hook@active
+ }%
+ % actually store 3d coordinates:
+ \let\pgfplotsplothandlermesh@serialize@logical@coords=\pgfplotsplothandlermesh@serialize@logical@coords@doit
+ \fi
+ %
% Prepare:
\def\pgfplotsplothandlermesh@definecolor{%
\pgfplotsplothandlermesh@get@flat@color
@@ -1684,9 +1946,21 @@
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass@output}{get pdf shading type}%
\fi
\pgfkeyslet{/pgfplots/surf shading/shading type}\pgfplotsretval%
+ %
+ \pgfplotsplothandlermesh@set@shader@colormap
+ \pgfkeysgetvalue{/pgfplots/mesh/interior colormap name}\pgfplots@loc@TMPa
+ \ifx\pgfplots@loc@TMPa\pgfutil@empty
+ \else
+ \let\pgfplotsplothandlermesh@shader@colormap=\pgfplotsretval
+ \begingroup
+ \pgfkeyslet{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \pgfplotsplothandlermesh@set@shader@colormap
+ \pgfmath@smuggleone\pgfplotsretval
+ \endgroup
+ \let\pgfplotsplothandlermesh@shader@colormap@interior=\pgfplotsretval
+ \fi
+ %
\pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa
- \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}%
- \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval
\pgfplotscolormapgetcolorspace\pgfplots@loc@TMPa
\pgfkeyslet{/pgfplots/surf shading/colorspace}\pgfplotsretval
\if2\pgfplotsplothandlermesh@shader
@@ -1909,6 +2183,12 @@
%
\let\pgfplotsplothandlermesh@compute@vertex@depth=\pgfplotsplothandlermesh@compute@vertex@depth@doit%
%
+ % the "element depth" is defined to be the MEAN of all
+ % vertex depths.
+ % And since the mean is 1/n * sum_{i=1}^n V_i, we can
+ % directly omit the 1/n --- it is the same for every
+ % vertex anyway, and we only want to compare the depth
+ % values.
\let\pgfplotsplothandlermesh@accum@element@depth=\pgfmath@basic@add@
%
% and collect each point into the z buffer
@@ -1955,6 +2235,12 @@
\pgfplotspatchclass{\pgfplotsplothandlermesh@patchclass}{new}%
}
+\def\pgfplotsplothandlermesh@set@shader@colormap{%
+ \pgfkeysgetvalue{/pgfplots/colormap name}\pgfplots@loc@TMPa
+ \expandafter\pgfplotscolormaptopdffunction\expandafter{\pgfplots@loc@TMPa}%
+ \pgfkeyslet{/pgfplots/surf shading/colormap}\pgfplotsretval
+}%
+
{
\dimen0=-16000.0pt
\xdef\pgfplotsplothandlermesh@check@unbounded@text{\the\dimen0}%
@@ -2031,7 +2317,7 @@
\pgfkeyslet{/pgfplots/iflessthan/.@cmd}\pgfplotsplothandlermesh@zbuffer@sort@iflessthen
\pgfkeysdef{/pgfplots/array/unscope pre}{%
\let\pgfplotsplothandlermesh@patchclass=\pgfplotsplothandlermesh@patchclass@output
- \def\pgfplotspatchready{\pgfplotsplothandlermesh@VISUALIZE}%
+ \def\pgfplotspatchready{\pgfplotsplothandlermesh@PIPE@interior@exterior@styles}%
\pgfplotsarrayforeachungrouped\pgfplots@zbuffer@local\as\curelem{%
\expandafter\pgfplotsplothandlermesh@draw@zbufferelement\curelem%
}%
@@ -2063,8 +2349,10 @@
\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@ONEDIMMODE#1{%
\let\pgfplotsplothandlermesh@patchclass\pgfplotsplothandlermesh@patchclass@input
\pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
\pgf@process{#1}%
- \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplotsretval}%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplotsplothandlermesh@i{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%
\ifnum\c@pgfplots@scanlineindex>0
\expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@im}%
\expandafter\pgfplotsplothandlermesh@setnextvertex\expandafter{\pgfplotsplothandlermesh@i}%
@@ -2077,8 +2365,10 @@
% the pgf@plotstreampoint routine for the first scan line:
\def\pgfplotsplothandlermesh@PIPE@DECODE@matrix@fillscanline#1{%
\pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
\pgf@process{#1}%
- \edef\pgfplots@loc@TMPa{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplotsretval}%
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplots@loc@TMPa{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}%
\expandafter\pgfplotsdequepushback\pgfplots@loc@TMPa\to{lastscanline}%
\advance\c@pgfplots@scanlineindex by1
\ifnum\c@pgfplots@scanlineindex=\pgfplotsplothandlermesh@scanlinelength\relax
@@ -2114,8 +2404,10 @@
% 'im == (i-1)'
% 'jm == (j-1)'
\pgfplotsplothandlermesh@compute@vertex@depth% <-- this modifies \pgfplotsretval
+ \let\pgfplots@view@depth=\pgfplotsretval
\pgf@process{#1}%
- \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplotsretval}% FIXME relies on pgfplots macros
+ \pgfplotsplothandlermesh@serialize@logical@coords
+ \edef\pgfplotsplothandlermesh@i@j{{\the\pgf@x}{\the\pgf@y}{\pgfplots@current@point@meta}\pgfplots@view@depth:\pgfplotsretval}% FIXME relies on pgfplots macros
%\message{##\the\c@pgfplots@scanlineindex: prepare rectangle with corner \meaning\pgfplotsplothandlermesh@i@j.}%
\pgfplotsdequepopfront{lastscanline}\to\pgfplotsplothandlermesh@im@j
\expandafter\pgfplotsdequepushback\pgfplotsplothandlermesh@i@j\to{lastscanline}%