Commit 35fcb2b1 authored by Cory Quammen's avatar Cory Quammen

Remove Python recipe that is no longer valid

ParaView can color surfaces directly from float and double arrays with
data values in the range [0, 1], so remove the recipe that computes
unsigned char arrays from such arrays to use for coloring.
parent 55ecdba3
......@@ -543,38 +543,40 @@ output.ShallowCopy(B.VTKObject)
output.PointData.append(mask, "labels")
\end{python}
\subsection{Coloring points}
Let's consider a case where you have three scalar colors (``R'', ``G'', and ``B'')
available on the point data. Let's say each of these has values in the range
$[0,1]$, and we want to use these for coloring the points directly without using
a color map.
Remember, to not use a color map, you uncheck \ui{Map Scalars} in the \ui{Display} properties
section on the \ui{Properties} panel. However, the array being color with needs to be
an unsigned-char array with values in the range $[0, 255]$ for each component. So,
we'll need to convert the three scalar arrays into a single vector and then scale it
too. This can be done as follows:
\begin{python}
# Code for 'Script'
from vtk.numpy_interface import algorithms as algs
import numpy as np
r = inputs[0].PointData["R"]
g = inputs[0].PointData["G"]
b = inputs[0].PointData["B"]
# combine components into a single array.
rgb = algs.make_vector(r, g, b)
# now scale and convert the type to uint8 ==> unsigned char
rgb = np.asarray(rgb * 255.0, dtype=np.uint8)
# Add the array
output.PointData.append(rgb, "RGBColors")
\end{python}
As before, this will work just fine for composite datasets too, without having to
iterate over the blocks in the composite dataset explicitly.
% The following subsection is no longer needed because you can indeed color
% points by floats and double arrays.
% \subsection{Coloring points}
%
% Let's consider a case where you have three scalar colors (``R'', ``G'', and ``B'')
% available on the point data. Let's say each of these has values in the range
% $[0,1]$, and we want to use these for coloring the points directly without using
% a color map.
%
% Remember, to not use a color map, you uncheck \ui{Map Scalars} in the \ui{Display} properties
% section on the \ui{Properties} panel. However, the array being color with needs to be
% an unsigned-char array with values in the range $[0, 255]$ for each component. So,
% we'll need to convert the three scalar arrays into a single vector and then scale it
% too. This can be done as follows:
% \begin{python}
% # Code for 'Script'
% from vtk.numpy_interface import algorithms as algs
% import numpy as np
% r = inputs[0].PointData["R"]
% g = inputs[0].PointData["G"]
% b = inputs[0].PointData["B"]
% # combine components into a single array.
% rgb = algs.make_vector(r, g, b)
% # now scale and convert the type to uint8 ==> unsigned char
% rgb = np.asarray(rgb * 255.0, dtype=np.uint8)
% # Add the array
% output.PointData.append(rgb, "RGBColors")
% \end{python}
% As before, this will work just fine for composite datasets too, without having to
% iterate over the blocks in the composite dataset explicitly.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment