Structured hex: extrude, revolve, sweep and mapped all-hex meshing (M5) (#40)

* Structured hex meshing: multi-level extrude and revolve, one-to-one sweep, mapped blocks (M5)

modelcraft_mesh::hex::hex_mesh meshes a face-tagged boundary surface with
hexahedra by the first structured method that fits: a straight or
rotational multi-level sweep (imprinted cross-section arrangement, cuts at
reflex corners, mapped/annulus/free regions), a one-to-one sweep through
rings of linking faces (least-squares affine layers with residual
correction), or a mapped logical cube (trivariate transfinite
interpolation). Interval assignment couples shared curves; boundary quads
carry B-rep face tags; the certified validity gate, a tiling check and a
fidelity check guard the output; hex20 mid-edge nodes go onto the faces.
Shape::face_surfaces exposes the analytic face surfaces; the corpus runner
gets a structured hex column.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* mesh.hex.generate: structured hex meshing as a command

Meshes one body, every body of the open design or an imported surface,
replaces the mesh, tags element faces with the B-rep faces (so sets by
geometry resolve) and reports per body the method, counts and quality.
The quality pass certifies each element once and feeds the validity gate
(quality::validity_gate_checks). Shape::size gives the cached body size
for defaults instead of a full measure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Hex: disk O-grids, convex interval cost, early size guard, hex20 corpus column

Smooth single-loop sections (cylinders, tori, vases) get a butterfly O-grid
instead of the free mesher; interval assignment raises counts by the
squared relative error so equal sides share increments evenly; a mesh far
beyond the element limit is refused before any work and mapped limits are
no longer swallowed. The corpus reports hex8 and hex20 quality.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Catalogue: structured hex commands ready (mesh.hex.sweep, mesh.hex.mapped, mesh.hex.generate)

mesh.hex.sweep and mesh.hex.mapped run mesh.hex.generate with the sweeping
methods or the mapped one; mesh.hex.generate is the sweep entry's related
command. The planned M6 octree entry moves to mesh.hex.octree (its icon
renamed with it). docs/features.md regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Docs: structured hex literature (B8), architecture, roadmap, parity; corpus hex column

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Hex: simplify review fixes

Prepare each sweep frame's cross-section once (arrangement, cuts, fill)
and reuse it across refinement retries; candidate frames come from one
setup pass. Edge triangles come from the feature edges, layer counts go
through size::edge_divisions, sweep residual weights are computed once
per node, flux shape functions live on the stack, and the arrangement's
exact side test and distances serve the region probe. The engine takes
the boundary options mesh.tet.generate takes and names unnamed faces by
index like it; the corpus hex20 run reuses the winning method; the
mapped entry lists mesh.hex.generate too; the octree icon is redrawn
under its new id.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md and docs/meshing/corpus.md after rebasing

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md and docs/meshing/corpus.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md and docs/meshing/corpus.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md and docs/meshing/corpus.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

* Regenerate docs/features.md after rebasing onto main

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NmAttHhUZTokgPeEJia8sm

---------

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
authored and GitHub committed 2026-10-13 22:25:50 -04:00
1 parent 5ebb9f16dc
commit 5afd1addb9
32 files changed
+5006 -47

No files matched your search

+3 -1
View File
@@ -26,7 +26,9 @@ pub(crate) mod shape;
use modelcraft_model::{ElementKind, check_coordinates};
pub use jacobian::{JacobianCheck, Validity};
pub use report::{GateOptions, GateReport, MetricStats, QualityReport, enclosed_volume, quality_report, validity_gate, validity_gate_elements};
pub use report::{
GateOptions, GateReport, MetricStats, QualityReport, enclosed_volume, quality_report, validity_gate, validity_gate_checks, validity_gate_elements,
};
pub(crate) use shape::{planar_corner, quad_axes};
use crate::predicates::{Point2, Point3, Sign, orient2d, snap_to_domain, tet_volume_sign};
+20 -3
View File
@@ -4,7 +4,7 @@ use std::collections::{BTreeMap, BTreeSet};
use modelcraft_model::{Element, ElementKind, Model, check_coordinates};
use super::{ElementQuality, Metric, Validity, element_quality, element_validity, is_measured};
use super::{ElementQuality, JacobianCheck, Metric, Validity, element_quality, element_validity, is_measured};
use crate::{Error, Result};
/// The most histogram bins a report may ask for.
@@ -218,7 +218,11 @@ impl Gate {
if kind.dimension() != 3 {
return Ok(());
}
let check = element_validity(kind, xyz)?;
self.add_check(label, &element_validity(kind, xyz)?);
Ok(())
}
fn add_check(&mut self, label: u32, check: &JacobianCheck) {
let r = &mut self.0;
r.checked += 1;
r.volume += check.volume;
@@ -227,10 +231,23 @@ impl Gate {
Validity::Invalid => r.invalid.push(label),
Validity::Undetermined => r.undetermined.push(label),
}
Ok(())
}
}
/// [`validity_gate_elements`] over certified checks already made, for a mesher that measured its
/// elements with [`super::element_quality`] (which certifies them too) and should not certify
/// them twice: `(label, check)` per solid element.
pub fn validity_gate_checks<'a, I>(checks: I, options: &GateOptions) -> Result<GateReport>
where
I: IntoIterator<Item = (u32, &'a JacobianCheck)>,
{
let mut gate = Gate::new(options)?;
for (label, check) in checks {
gate.add_check(label, check);
}
Ok(gate.0)
}
/// The validity gate every mesher runs on its output before it reaches the model: each solid
/// element's Jacobian determinant is proven positive everywhere, and the elements' total volume
/// equals the volume the boundary encloses. Elements come as `(label, kind, node coordinates in
+7 -1
View File
@@ -284,7 +284,13 @@ fn report_and_gate() {
// The same gate straight from a mesher's arrays.
let raw = validity_gate_elements([(7, ElementKind::Hex8, inside_out_hex()), (8, ElementKind::Hex8, UNIT_CUBE.to_vec())], &GateOptions::default())
.unwrap();
assert_eq!((raw.checked, raw.invalid), (2, vec![7]));
assert_eq!((raw.checked, raw.invalid.clone()), (2, vec![7]));
// And from checks a mesher already made with element_quality.
let checks: Vec<(u32, JacobianCheck)> = [(7, inside_out_hex()), (8, UNIT_CUBE.to_vec())]
.into_iter()
.map(|(l, x)| (l, element_quality(ElementKind::Hex8, &x).unwrap().jacobian.unwrap()))
.collect();
assert_eq!(validity_gate_checks(checks.iter().map(|(l, c)| (*l, c)), &GateOptions::default()).unwrap(), raw);
// A unit cube split into six tetrahedra around the 1-7 diagonal passes against its boundary.
let c = UNIT_CUBE;