foresight_pm3d
foresight_pm3d, gnuplot's pm3d: the surfaces of the 3D plots as colored quadrangles.
A port of gnuplot 6.0's pm3d.c (pm3d_plot): each pair of neighbouring scans of a surface grid joined point by point into quadrangles, each colored by its corners (corners2color: their mean, geometric or harmonic mean, rms, median, minimum, maximum, or one corner), optionally subdivided by bilinear interpolation (interpolate N,M, gnuplot's automatic counts for 0 or negative values).
Source: src/lib/foresight_pm3d.F90
Dependencies
Contents
- pm3d_object
- pm3d_polygons
- add
- contour_slices
- clip_band
- contourfill_polygons
- masked
- defined
- corner_color
- corner_rgb
- packed_hex
- lit_color
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
CORNERS_MEAN | integer(kind=I4P) | parameter | corners2color mean, gnuplot's default. |
CORNERS_GEOMEAN | integer(kind=I4P) | parameter | geomean. |
CORNERS_HARMEAN | integer(kind=I4P) | parameter | harmean. |
CORNERS_RMS | integer(kind=I4P) | parameter | rms. |
CORNERS_MEDIAN | integer(kind=I4P) | parameter | median. |
CORNERS_MIN | integer(kind=I4P) | parameter | min. |
CORNERS_MAX | integer(kind=I4P) | parameter | max. |
CORNERS_C1 | integer(kind=I4P) | parameter | c1; c2, c3, c4 the next three codes. |
Derived Types
pm3d_object
pm3d settings of a panel (gnuplot set pm3d).
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
implicit | logical | Every surface drawn with pm3d too (set pm3d, implicit), else only the items with pm3d (explicit, unset pm3d). | |
at | character(len=6) | at bstbst: drawn in that order). | |
interp | integer(kind=I4P) | Steps along and between the scans (interpolate N,M; 0 or negative: gnuplot's automatic counts). | |
corners | integer(kind=I4P) | corners2color. | |
clip4in | logical | clip4in: a quadrangle needs its 4 corners in range, else one. | |
clip_z | logical | clip z (gnuplot's default): in a 3D view the quadrangles at the surface clipped smoothly to the z range; clip1in, clip4in whole. | |
border | logical | border: the quadrangles outlined. | |
border_color | character(len=24) | Color of the outlines (border lc|lt ...); blank with retrace (each in its fill color). | |
border_lw | real(kind=R8P) | Width of the outlines (border lw W). | |
direction | integer(kind=I4P) | Drawing order in 3D views: 0 scansautomatic, 1 scansforward, 2 scansbackward, 3 depthorder. | |
base_sort | logical | depthorder base: sorted by the depth of the base below each. | |
strength | real(kind=R8P) | lighting primary F: the primary light's share, 0 without lighting. | |
spec | real(kind=R8P) | lighting specular F: the specular highlights' share. | |
spec2 | real(kind=R8P) | lighting spec2 F: the spotlight's share. | |
spot_rot | real(kind=R8P) | spotlight rot_x A rot_z B [deg]. | |
spot_rgb | integer(kind=I4P) | spotlight rgbcolor C (gnuplot's 0xff0044). | |
spot_phong | real(kind=R8P) | spotlight Phong P. |
Subroutines
pm3d_polygons
The quadrangles of a surface: the points (x, y, z, color values c) of its first grid scans (first and last point of each), neighbouring scans of a dataset (sets) joined point by point over the shorter one, as gnuplot's pm3d_plot; a quadrangle needs its 4 corners defined and one in range (inrange; all 4 with clip4in). The result is a polygon per quadrangle: its 4 corners (px, py, their heights pz) and a NaN row, each row in the quadrangle's color value pc (NaN quadrangles left out). With rgb the color values are packed colors 0xAARRGGBB (gnuplot's lc rgb variable): a quadrangle takes the mean of its corners channel by channel (or one corner, c1 ... c4), as gnuplot's pm3d_plot; the interpolated ones the plain mean of the numbers, as gnuplot's. The order of gnuplot's scan array: with swap_scans the scans taken from the last (scan A the later of a pair, the pairs from the last), with reverse_points the points of a pair from the last (gnuplot's pm3d_rearrange_part, the 3D views); without them, the map's: a surface of fewer than 3 scans has its scans in reverse order (gnuplot's scansautomatic when no depth tells), as c1 ... c4 show.
Attributes: pure
subroutine pm3d_polygons(x, y, z, c, scans, sets, grid, settings, inrange, px, py, pc, rgb, pz, swap_scans, reverse_points)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. | |
c | real(kind=R8P) | in | Color values (the heights, or a column of their own). | |
scans | integer(kind=I4P) | in | Scans: first and last point. | |
sets | integer(kind=I4P) | in | Dataset of each scan. | |
grid | integer(kind=I4P) | in | Scans of the grid. | |
settings | type(pm3d_object) | in | pm3d settings. | |
inrange | logical | in | Points within the x and y ranges. | |
px | real(kind=R8P) | out | allocatable | Polygon abscissae. |
py | real(kind=R8P) | out | allocatable | Polygon ordinates. |
pc | real(kind=R8P) | out | allocatable | Polygon color values. |
rgb | logical | in | optional | Packed colors. |
pz | real(kind=R8P) | out | allocatable, optional | Polygon heights. |
swap_scans | logical | in | optional | Scans from the last (scan A the later one). |
reverse_points | logical | in | optional | Points from the last. |
Call graph
add
Append the quadrangle (qx, qy) of color value and its NaN row at row n of the polygons, unless the value is NaN.
Attributes: pure
subroutine add(px, py, pc, n, qx, qy, value)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
px | real(kind=R8P) | inout | Polygon abscissae. | |
py | real(kind=R8P) | inout | Polygon ordinates. | |
pc | real(kind=R8P) | inout | Polygon color values. | |
n | integer(kind=I4P) | inout | Rows used. | |
qx | real(kind=R8P) | in | Corner abscissae. | |
qy | real(kind=R8P) | in | Corner ordinates. | |
value | real(kind=R8P) | in | Color value. |
Call graph
contour_slices
The z slices of with contourfill, gnuplot's plot3d_contourfill: mode 0 (set contourfill auto N) n equal slices of the z axis range [zlo, zhi]; else (ztics, cbtics) a slice from each tick of tics (those within the range, ascending) to the next, the first from zlo and the last to zhi; at most 100 slices. mids the values of their colors (each slice's middle).
Attributes: pure
subroutine contour_slices(mode, n, zlo, zhi, tics, lows, highs, mids)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
mode | integer(kind=I4P) | in | 0 auto, else ticks. | |
n | integer(kind=I4P) | in | Slices of auto. | |
zlo | real(kind=R8P) | in | Axis range, low end. | |
zhi | real(kind=R8P) | in | Axis range, high end. | |
tics | real(kind=R8P) | in | Ticks within the range. | |
lows | real(kind=R8P) | out | allocatable | Slice lows. |
highs | real(kind=R8P) | out | allocatable | Slice highs. |
mids | real(kind=R8P) | out | allocatable | Slice color values. |
Call graph
clip_band
The convex polygon x, y, z clipped to the heights [zmin, zmax], gnuplot's clip_filled_polygon: nvo -1 nothing left, 0 all within (the polygon itself), else the vertices ox, oy, oz left (at most 2 more).
Attributes: pure
subroutine clip_band(x, y, z, zmin, zmax, ox, oy, oz, nvo)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. | |
zmin | real(kind=R8P) | in | Lowest height kept. | |
zmax | real(kind=R8P) | in | Highest height kept. | |
ox | real(kind=R8P) | out | Clipped abscissae. | |
oy | real(kind=R8P) | out | Clipped ordinates. | |
oz | real(kind=R8P) | out | Clipped heights. | |
nvo | integer(kind=I4P) | out | Vertices left. |
Call graph
contourfill_polygons
The pm3d quadrangles px, py, pz (4 corners and a NaN row each) of with contourfill, gnuplot's: for each slice [lows, highs] in turn (within zrange), every quadrangle clipped to it (clip_band; whole when within), as polygons of 3 to 6 corners and a NaN row; slice the slice of each row, source the first row of its quadrangle (0 on the NaN rows).
Attributes: pure
subroutine contourfill_polygons(px, py, pz, lows, highs, zrange, cx, cy, cz, slice, source)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
px | real(kind=R8P) | in | Quadrangle abscissae. | |
py | real(kind=R8P) | in | Quadrangle ordinates. | |
pz | real(kind=R8P) | in | Quadrangle heights. | |
lows | real(kind=R8P) | in | Slice lows. | |
highs | real(kind=R8P) | in | Slice highs. | |
zrange | real(kind=R8P) | in | z axis range. | |
cx | real(kind=R8P) | out | allocatable | Polygon abscissae. |
cy | real(kind=R8P) | out | allocatable | Polygon ordinates. |
cz | real(kind=R8P) | out | allocatable | Polygon heights. |
slice | integer(kind=I4P) | out | allocatable | Slice of each row. |
source | integer(kind=I4P) | out | allocatable | First row of the quadrangle of each row. |
Call graph
Functions
masked
Whether the point (x, y) is masked: inside none of the mask polygons (mx, my, NaN separated, closed or not), gnuplot's masked() over its interior() even-odd test (gadgets.c); no polygon masks nothing.
Attributes: pure
Returns: logical
function masked(x, y, mx, my) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Abscissa. | |
y | real(kind=R8P) | in | Ordinate. | |
mx | real(kind=R8P) | in | Polygon abscissae. | |
my | real(kind=R8P) | in | Polygon ordinates. |
Call graph
defined
Whether point k is defined: its coordinates and color finite.
Attributes: pure
Returns: logical
function defined(x, y, z, c, k) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Abscissae. | |
y | real(kind=R8P) | in | Ordinates. | |
z | real(kind=R8P) | in | Heights. | |
c | real(kind=R8P) | in | Color values. | |
k | integer(kind=I4P) | in | Point. |
Call graph
corner_color
The color value of a quadrangle from its corners cb, gnuplot's (pm3d.c): their mean, geometric mean (0 for mixed signs), harmonic mean (NaN unless all positive), rms (half the root of the sum of squares), median, minimum, maximum, or one of them (c1 ... c4, in gnuplot's corner order).
Attributes: pure
Returns: real(kind=R8P)
function corner_color(cb, mode) result(v)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
cb | real(kind=R8P) | in | Corner values. | |
mode | integer(kind=I4P) | in | corners2color. |
Call graph
corner_rgb
The packed color 0xAARRGGBB of a quadrangle from its corners' cb, gnuplot's (pm3d.c, lc rgb variable): one of them (c1 ... c4), else the mean of each channel, the sums shifted right by two and masked (the transparency as gnuplot's: its sum shifted left by 22).
Attributes: pure
Returns: real(kind=R8P)
function corner_rgb(cb, mode) result(v)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
cb | real(kind=R8P) | in | Corner colors. | |
mode | integer(kind=I4P) | in | corners2color. |
Call graph
packed_hex
The SVG color of a packed color 0xAARRGGBB (gnuplot's rgb variable), its number truncated to 32 bits: #rrggbb, with the opacity aa = 255 - AA appended unless opaque (#rrggbbaa); blank for a NaN.
Attributes: pure
Returns: character(len=9)
function packed_hex(v) result(color)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
v | real(kind=R8P) | in | Packed color. |
Call graph
lit_color
The packed color 0xAARRGGBB of a pm3d quadrangle of color f (red, green, blue from 0 to 1, transparency alpha in the top byte) lit by gnuplot's apply_lighting_model (set pm3d lighting): the normal of its corners v0, v1, v2 (linear spaces, scaled by the view's scale3d) turned to the viewer (rot_x, rot_z [deg]), towards the viewer; the ambient light 1, the primary light (from 45, 85 degrees) of share strength, its Phong highlights (exponent 5) of share spec, the spotlight (spec2, from spot_rot, in spot_rgb, exponent spot_phong) on the faces turned away; a degenerate corner v2 replaced by v3 once.
Attributes: pure, recursive
Returns: integer(kind=I8P)
function lit_color(f, alpha, v0, v1, v2, v3, pm, scale3d, rot_x, rot_z) result(packed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
f | real(kind=R8P) | in | Red, green, blue, 0 to 1. | |
alpha | integer(kind=I8P) | in | Transparency, in the top byte. | |
v0 | real(kind=R8P) | in | Corner A(i). | |
v1 | real(kind=R8P) | in | Corner A(i+1). | |
v2 | real(kind=R8P) | in | Corner B(i). | |
v3 | real(kind=R8P) | in | Corner B(i+1). | |
pm | type(pm3d_object) | in | pm3d settings. | |
scale3d | real(kind=R8P) | in | The view's x, y, z scales. | |
rot_x | real(kind=R8P) | in | View rotation about x [deg]. | |
rot_z | real(kind=R8P) | in | View rotation about z [deg]. |
Call graph