fortplot_contour_algorithms Module

Contour plotting algorithms module

This module implements the marching squares algorithm and related functions for contour line extraction and rendering.



Subroutines

public subroutine calculate_marching_squares_config(z1, z2, z3, z4, level, config)

Calculate marching squares configuration for a cell

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: z1
real(kind=wp), intent(in) :: z2
real(kind=wp), intent(in) :: z3
real(kind=wp), intent(in) :: z4
real(kind=wp), intent(in) :: level
integer, intent(out) :: config

public subroutine get_contour_lines(config, x1, y1, x2, y2, x3, y3, x4, y4, z1, z2, z3, z4, level, line_points, num_lines)

Extract contour lines from a cell using marching squares

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: config
real(kind=wp), intent(in) :: x1
real(kind=wp), intent(in) :: y1
real(kind=wp), intent(in) :: x2
real(kind=wp), intent(in) :: y2
real(kind=wp), intent(in) :: x3
real(kind=wp), intent(in) :: y3
real(kind=wp), intent(in) :: x4
real(kind=wp), intent(in) :: y4
real(kind=wp), intent(in) :: z1
real(kind=wp), intent(in) :: z2
real(kind=wp), intent(in) :: z3
real(kind=wp), intent(in) :: z4
real(kind=wp), intent(in) :: level
real(kind=wp), intent(out) :: line_points(8)
integer, intent(out) :: num_lines

public subroutine interpolate_edge_crossings(x1, y1, x2, y2, x3, y3, x4, y4, z1, z2, z3, z4, level, xa, ya, xb, yb, xc, yc, xd, yd)

Interpolate the positions where contour crosses cell edges

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: x1
real(kind=wp), intent(in) :: y1
real(kind=wp), intent(in) :: x2
real(kind=wp), intent(in) :: y2
real(kind=wp), intent(in) :: x3
real(kind=wp), intent(in) :: y3
real(kind=wp), intent(in) :: x4
real(kind=wp), intent(in) :: y4
real(kind=wp), intent(in) :: z1
real(kind=wp), intent(in) :: z2
real(kind=wp), intent(in) :: z3
real(kind=wp), intent(in) :: z4
real(kind=wp), intent(in) :: level
real(kind=wp), intent(out) :: xa
real(kind=wp), intent(out) :: ya
real(kind=wp), intent(out) :: xb
real(kind=wp), intent(out) :: yb
real(kind=wp), intent(out) :: xc
real(kind=wp), intent(out) :: yc
real(kind=wp), intent(out) :: xd
real(kind=wp), intent(out) :: yd

public subroutine apply_marching_squares_lookup(config, xa, ya, xb, yb, xc, yc, xd, yd, line_points, num_lines)

Apply marching squares lookup table to get line segments

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: config
real(kind=wp), intent(in) :: xa
real(kind=wp), intent(in) :: ya
real(kind=wp), intent(in) :: xb
real(kind=wp), intent(in) :: yb
real(kind=wp), intent(in) :: xc
real(kind=wp), intent(in) :: yc
real(kind=wp), intent(in) :: xd
real(kind=wp), intent(in) :: yd
real(kind=wp), intent(out) :: line_points(8)
integer, intent(out) :: num_lines

public subroutine smooth_contour_chain(n_in, x_in, y_in, subdivisions, n_out, x_out, y_out)

Smooth a polyline using Catmull-Rom spline interpolation

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: n_in
real(kind=wp), intent(in) :: x_in(:)
real(kind=wp), intent(in) :: y_in(:)
integer, intent(in) :: subdivisions
integer, intent(out) :: n_out
real(kind=wp), intent(out), allocatable :: x_out(:)
real(kind=wp), intent(out), allocatable :: y_out(:)

public pure subroutine catmull_rom_interpolate(t, x0, y0, x1, y1, x2, y2, x3, y3, px, py)

Catmull-Rom spline interpolation between P1 and P2 t in [0,1], P0/P3 are control points

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: t
real(kind=wp), intent(in) :: x0
real(kind=wp), intent(in) :: y0
real(kind=wp), intent(in) :: x1
real(kind=wp), intent(in) :: y1
real(kind=wp), intent(in) :: x2
real(kind=wp), intent(in) :: y2
real(kind=wp), intent(in) :: x3
real(kind=wp), intent(in) :: y3
real(kind=wp), intent(out) :: px
real(kind=wp), intent(out) :: py