scimesh 0.3.4
Headless CPU-only 3D software renderer for scientific mesh visualization
Loading...
Searching...
No Matches
scimesh::detail Namespace Reference

Internal helpers of the text renderer. More...

Functions

void render_text_layers (const std::vector< TextNodeRef > &layers, Image &output, const Mat4 &view_projection, float pixel_scale, const std::vector< float > &z_buffer, const Color &default_color)
 Draw all text layers into an already rendered image.
 
Vec3 hermite_segment (const Vec3 &p0, const Vec3 &p1, const Vec3 &m0, const Vec3 &m1, double h, double s)
 Cubic Hermite basis evaluation of a single curve segment.
 
size_t segment_count (size_t num_points, bool closed)
 Number of segments a sampling function has to emit.
 
size_t next_index (size_t i, size_t num_points, bool closed)
 Index of the point after i, wrapping around for closed curves.
 
int sample_count (int samples_per_segment)
 Clamp a requested sample count to at least one.
 

Variables

constexpr size_t kMinPathPoints = 2u
 Minimum number of points that can describe a path.
 
constexpr double kMinKnotInterval = 1e-6
 Smallest knot interval, to keep a degenerate point pair from producing a zero-length interval (and a division by zero).
 
constexpr double kArcLengthEpsilon = 1e-9
 Tolerance used when deciding whether an arc-length sample coincides with the end of a path, relative to the total path length.
 

Detailed Description

Internal helpers of the text renderer.

Everything in this namespace is an implementation detail: it is only public because the renderer lives in a different translation unit. Use TextLayer with a Scene (or draw_text()) instead.

Function Documentation

◆ hermite_segment()

Vec3 scimesh::detail::hermite_segment ( const Vec3 &  p0,
const Vec3 &  p1,
const Vec3 &  m0,
const Vec3 &  m1,
double  h,
double  s 
)
inline

Cubic Hermite basis evaluation of a single curve segment.

Evaluates P(s) for one segment of a cubic Hermite curve, given the two endpoint positions, the two endpoint derivatives m0/m1 with respect to the curve parameter t, and the length h of the parameter interval that the segment spans (h = t1 - t0, so that the derivative is rescaled to the local s in [0, 1]).

This is the single evaluation kernel behind hermite_path(), catmull_rom_path() and the endpoint handling of both: the other functions only differ in how they come up with m0/m1 and the knot sequence.

Parameters
p0,p1Segment endpoint positions.
m0,m1Segment endpoint derivatives (dP/dt).
hParameter interval length of the segment.
sLocal parameter in [0, 1].
Returns
The point on the curve segment at s.

Definition at line 76 of file spline.h.

◆ next_index()

size_t scimesh::detail::next_index ( size_t  i,
size_t  num_points,
bool  closed 
)
inline

Index of the point after i, wrapping around for closed curves.

Definition at line 104 of file spline.h.

◆ render_text_layers()

void scimesh::detail::render_text_layers ( const std::vector< TextNodeRef > &  layers,
Image &  output,
const Mat4 &  view_projection,
float  pixel_scale,
const std::vector< float > &  z_buffer,
const Color &  default_color 
)

Draw all text layers into an already rendered image.

Called by the renderer at the end of the render pipeline, where the view projection matrix and the depth buffer of the current frame are known.

Parameters
layersThe text layers to draw, in order.
[in,out]outputThe image to draw into (supersampled resolution).
view_projectionThe combined projection * view matrix of the frame.
pixel_scaleSupersampling factor the image was rendered with.
z_bufferDepth buffer of the frame (empty disables depth testing); must have width * height entries.
default_colorColor for labels without an explicit color.

Definition at line 448 of file text.cpp.

◆ sample_count()

int scimesh::detail::sample_count ( int  samples_per_segment)
inline

Clamp a requested sample count to at least one.

Definition at line 113 of file spline.h.

◆ segment_count()

size_t scimesh::detail::segment_count ( size_t  num_points,
bool  closed 
)
inline

Number of segments a sampling function has to emit.

An open curve through n points has n - 1 segments; a closed one has n, because the last point connects back to the first.

Definition at line 96 of file spline.h.

Variable Documentation

◆ kArcLengthEpsilon

constexpr double scimesh::detail::kArcLengthEpsilon = 1e-9
constexpr

Tolerance used when deciding whether an arc-length sample coincides with the end of a path, relative to the total path length.

Definition at line 57 of file spline.h.

◆ kMinKnotInterval

constexpr double scimesh::detail::kMinKnotInterval = 1e-6
constexpr

Smallest knot interval, to keep a degenerate point pair from producing a zero-length interval (and a division by zero).

Definition at line 53 of file spline.h.

◆ kMinPathPoints

constexpr size_t scimesh::detail::kMinPathPoints = 2u
constexpr

Minimum number of points that can describe a path.

A path needs a direction, so two distinct points are the absolute minimum; closed (looping) curves need at least three.

Definition at line 49 of file spline.h.