\documentclass{article}
% translate with >> pdflatex -shell-escape <file>

% This file is used as unit test for pgfplots, copyright by Christian Feuersaenger.
% 
% See
%   http://pgfplots.sourceforge.net/pgfplots.pdf
% for pgfplots.
%
% Any required input files (for <plot table> or <plot file> or the table package) can be downloaded
% at
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/
% and
% http://www.ctan.org/tex-archive/graphics/pgf/contrib/pgfplots/doc/latex/plotdata/

\usepackage{pgfplots}
\pgfplotsset{compat=1.4}
\usepgfplotslibrary{patchplots}

\pagestyle{empty}

\begin{document}
\pgfplotsset{
	show nodes/.style={nodes near coords=\coordindex,nodes near coords align={center}},
	small,
	title style={text width=5cm},
}

\pgfmathsetseed{5000}

	\newcommand\BICUBICSHAPE[1]{%
		\begin{tikzpicture}
%		\tracingcommands=2 \tracingmacros=2
			\begin{axis}[title={PGFPlots bicubic (#1)},shader=#1]
			\addplot3[mark=*,mark size=2pt,patch,patch type=bicubic] coordinates {
				(0,0,\AA)	(1,0,\BA) (2,0,\CA) (3,0,\DA) 
				(0,1,\AB)	(1,1,\BB) (2,1,\CB) (3,1,\DB) 
				(0,2,\AC)	(1,2,\BC) (2,2,\CC) (3,2,\DC) 
				(0,3,\AD)	(1,3,\BD) (2,3,\CD) (3,3,\DD) 
			};
			\end{axis}
		\end{tikzpicture}
%
	}
	\newcommand\BICUBICSHAPES[1]{%
		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{1} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{1} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{1} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{1} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{1} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{1} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{1}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{1}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{1}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{1}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{1} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{1} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{1} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{1} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{0} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%

		\noindent
		\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
		\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
		\def\AB{1} \def\BB{0} \def\CB{0} \def \DB{0}
		\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
		\BICUBICSHAPE{#1,point meta=rand}%
	}%
		\subsubsection{interpolated}
		{
			\BICUBICSHAPES{interp,
			%	view/h=90,view/v=90,
			}
		}%

		\def\TESTAXIS[#1]{
				\def\AD{0} \def\BD{0} \def\CD{0} \def \DD{0}
				\def\AC{0} \def\BC{0} \def\CC{0} \def \DC{0}
				\def\AB{0} \def\BB{0} \def\CB{1} \def \DB{0}
				\def\AA{0} \def\BA{0} \def\CA{0} \def \DA{0}
				\BICUBICSHAPE{interp,point meta=rand,#1}%
		}
		\foreach \v in {0,30,90,120,180,210,270,300} {
			\foreach \h in {0,30,90,120,180,210,270,300} {
				\message{view=\h,\v^^J}%
				%\TESTAXIS[view/h=\h,view/v=\v]
			}
			\par\noindent
		}

		\subsubsection{filled}
		{
			\BICUBICSHAPES{faceted,
			%	view/h=90,view/v=90,
			}
		}%


		\subsubsection{refined}
		{
	%		\BICUBICSHAPES{faceted interp,patch refines=1}
		}

		\subsubsection{triangulated}
		{
		%\tracingmacros=2 \tracingcommands=2
			\BICUBICSHAPES{faceted interp,patch to triangles}
		}
\end{document}
