Skip to content

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 ​

Variables ​

NameTypeAttributesDescription
CORNERS_MEANinteger(kind=I4P)parametercorners2color mean, gnuplot's default.
CORNERS_GEOMEANinteger(kind=I4P)parametergeomean.
CORNERS_HARMEANinteger(kind=I4P)parameterharmean.
CORNERS_RMSinteger(kind=I4P)parameterrms.
CORNERS_MEDIANinteger(kind=I4P)parametermedian.
CORNERS_MINinteger(kind=I4P)parametermin.
CORNERS_MAXinteger(kind=I4P)parametermax.
CORNERS_C1integer(kind=I4P)parameterc1; c2, c3, c4 the next three codes.

Derived Types ​

pm3d_object ​

pm3d settings of a panel (gnuplot set pm3d).

Components

NameTypeAttributesDescription
implicitlogicalEvery surface drawn with pm3d too (set pm3d, implicit), else only the items with pm3d (explicit, unset pm3d).
atcharacter(len=6)at bstbst: drawn in that order).
interpinteger(kind=I4P)Steps along and between the scans (interpolate N,M; 0 or negative: gnuplot's automatic counts).
cornersinteger(kind=I4P)corners2color.
clip4inlogicalclip4in: a quadrangle needs its 4 corners in range, else one.
clip_zlogicalclip z (gnuplot's default): in a 3D view the quadrangles at the surface clipped smoothly to the z range; clip1in, clip4in whole.
borderlogicalborder: the quadrangles outlined.
border_colorcharacter(len=24)Color of the outlines (border lc|lt ...); blank with retrace (each in its fill color).
border_lwreal(kind=R8P)Width of the outlines (border lw W).
directioninteger(kind=I4P)Drawing order in 3D views: 0 scansautomatic, 1 scansforward, 2 scansbackward, 3 depthorder.
base_sortlogicaldepthorder base: sorted by the depth of the base below each.
strengthreal(kind=R8P)lighting primary F: the primary light's share, 0 without lighting.
specreal(kind=R8P)lighting specular F: the specular highlights' share.
spec2real(kind=R8P)lighting spec2 F: the spotlight's share.
spot_rotreal(kind=R8P)spotlight rot_x A rot_z B [deg].
spot_rgbinteger(kind=I4P)spotlight rgbcolor C (gnuplot's 0xff0044).
spot_phongreal(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

fortran
subroutine pm3d_polygons(x, y, z, c, scans, sets, grid, settings, inrange, px, py, pc, rgb, pz, swap_scans, reverse_points)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.
creal(kind=R8P)inColor values (the heights, or a column of their own).
scansinteger(kind=I4P)inScans: first and last point.
setsinteger(kind=I4P)inDataset of each scan.
gridinteger(kind=I4P)inScans of the grid.
settingstype(pm3d_object)inpm3d settings.
inrangelogicalinPoints within the x and y ranges.
pxreal(kind=R8P)outallocatablePolygon abscissae.
pyreal(kind=R8P)outallocatablePolygon ordinates.
pcreal(kind=R8P)outallocatablePolygon color values.
rgblogicalinoptionalPacked colors.
pzreal(kind=R8P)outallocatable, optionalPolygon heights.
swap_scanslogicalinoptionalScans from the last (scan A the later one).
reverse_pointslogicalinoptionalPoints 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

fortran
subroutine add(px, py, pc, n, qx, qy, value)

Arguments

NameTypeIntentAttributesDescription
pxreal(kind=R8P)inoutPolygon abscissae.
pyreal(kind=R8P)inoutPolygon ordinates.
pcreal(kind=R8P)inoutPolygon color values.
ninteger(kind=I4P)inoutRows used.
qxreal(kind=R8P)inCorner abscissae.
qyreal(kind=R8P)inCorner ordinates.
valuereal(kind=R8P)inColor 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

fortran
subroutine contour_slices(mode, n, zlo, zhi, tics, lows, highs, mids)

Arguments

NameTypeIntentAttributesDescription
modeinteger(kind=I4P)in0 auto, else ticks.
ninteger(kind=I4P)inSlices of auto.
zloreal(kind=R8P)inAxis range, low end.
zhireal(kind=R8P)inAxis range, high end.
ticsreal(kind=R8P)inTicks within the range.
lowsreal(kind=R8P)outallocatableSlice lows.
highsreal(kind=R8P)outallocatableSlice highs.
midsreal(kind=R8P)outallocatableSlice 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

fortran
subroutine clip_band(x, y, z, zmin, zmax, ox, oy, oz, nvo)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.
zminreal(kind=R8P)inLowest height kept.
zmaxreal(kind=R8P)inHighest height kept.
oxreal(kind=R8P)outClipped abscissae.
oyreal(kind=R8P)outClipped ordinates.
ozreal(kind=R8P)outClipped heights.
nvointeger(kind=I4P)outVertices 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

fortran
subroutine contourfill_polygons(px, py, pz, lows, highs, zrange, cx, cy, cz, slice, source)

Arguments

NameTypeIntentAttributesDescription
pxreal(kind=R8P)inQuadrangle abscissae.
pyreal(kind=R8P)inQuadrangle ordinates.
pzreal(kind=R8P)inQuadrangle heights.
lowsreal(kind=R8P)inSlice lows.
highsreal(kind=R8P)inSlice highs.
zrangereal(kind=R8P)inz axis range.
cxreal(kind=R8P)outallocatablePolygon abscissae.
cyreal(kind=R8P)outallocatablePolygon ordinates.
czreal(kind=R8P)outallocatablePolygon heights.
sliceinteger(kind=I4P)outallocatableSlice of each row.
sourceinteger(kind=I4P)outallocatableFirst 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

fortran
function masked(x, y, mx, my) result(yes)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inAbscissa.
yreal(kind=R8P)inOrdinate.
mxreal(kind=R8P)inPolygon abscissae.
myreal(kind=R8P)inPolygon ordinates.

Call graph

defined ​

Whether point k is defined: its coordinates and color finite.

Attributes: pure

Returns: logical

fortran
function defined(x, y, z, c, k) result(yes)

Arguments

NameTypeIntentAttributesDescription
xreal(kind=R8P)inAbscissae.
yreal(kind=R8P)inOrdinates.
zreal(kind=R8P)inHeights.
creal(kind=R8P)inColor values.
kinteger(kind=I4P)inPoint.

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)

fortran
function corner_color(cb, mode) result(v)

Arguments

NameTypeIntentAttributesDescription
cbreal(kind=R8P)inCorner values.
modeinteger(kind=I4P)incorners2color.

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)

fortran
function corner_rgb(cb, mode) result(v)

Arguments

NameTypeIntentAttributesDescription
cbreal(kind=R8P)inCorner colors.
modeinteger(kind=I4P)incorners2color.

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)

fortran
function packed_hex(v) result(color)

Arguments

NameTypeIntentAttributesDescription
vreal(kind=R8P)inPacked 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)

fortran
function lit_color(f, alpha, v0, v1, v2, v3, pm, scale3d, rot_x, rot_z) result(packed)

Arguments

NameTypeIntentAttributesDescription
freal(kind=R8P)inRed, green, blue, 0 to 1.
alphainteger(kind=I8P)inTransparency, in the top byte.
v0real(kind=R8P)inCorner A(i).
v1real(kind=R8P)inCorner A(i+1).
v2real(kind=R8P)inCorner B(i).
v3real(kind=R8P)inCorner B(i+1).
pmtype(pm3d_object)inpm3d settings.
scale3dreal(kind=R8P)inThe view's x, y, z scales.
rot_xreal(kind=R8P)inView rotation about x [deg].
rot_zreal(kind=R8P)inView rotation about z [deg].

Call graph

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.