Files
OneCAD-Simulation/crates/render/src/lib.rs
T
Christian Svensson 0d30ddb747 render: slices, surface values and streamlines of cell flow fields
A fluid step's result is a field per cell of a regular grid, not per
node, so the contour machinery had nothing to draw it with and the
viewport showed nothing after a fluid solve.

Add `render::flow`, CPU display data for such fields with no solver
dependency (render stays at L1): an axis-aligned slice through the
cells as triangles carrying cell-centred values (interpolated between
the two layers either side, outer centres moved to the domain faces,
cells inside obstacles left out), the field sampled at a surface
beside the fluid cells for colouring an obstacle, and streamlines
traced through the trilinear velocity field by the midpoint rule,
seeded on a lattice upstream of the obstacles. Seeds, steps and the
total number of points are capped so hostile counts cost a bounded
time. `contour::banded` fans band pieces into scene triangles for the
callers.

Part of #193.
2026-10-17 07:25:04 -04:00

27 lines
1.2 KiB
Rust

//! Display data for FieldCraft, with no GPU dependency: what a finite element model looks like
//! on screen ([`DisplayMesh`]: the visible faces, element edges, line elements and nodes), an
//! orbit camera with perspective or orthographic projection, picking ([`pick`]: what a ray through
//! a pixel hits), flow fields on a grid of cells ([`flow`]: slices, surface values and
//! streamlines), and a CPU rasterizer for headless snapshots. The desktop viewport draws the
//! same [`Scene`] on the GPU.
#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)]
#![forbid(unsafe_code)]
mod camera;
pub mod contour;
mod display;
pub mod flow;
mod font;
pub mod glyphs;
pub mod pick;
mod raster;
mod vec;
pub use camera::{Camera, FIT_MARGIN, FULL_VIEW, Mat4, Orientation, StandardView};
pub use display::{DisplayEdge, DisplayLine, DisplayMesh, DisplayNode, DisplayTri, SurfaceCurve, SurfaceTri};
pub use raster::{
Canvas, LABEL_OFFSET, MAX_DIM, MAX_PIXELS, MAX_PRIMITIVES, RenderError, Rgb, Scene, SceneFill, SceneLabel, SceneLine, ScenePoint, SceneTri,
draw_labels, fit_size, png, render, render_layers, render_layers_png, render_png, shade,
};
pub use vec::{Aabb3, Vec3};