mesh: the octree roots at a field's largest size and plans depth to its smallest (#435)

SizeField::range gives a field's smallest and largest size. The octree
starts its root cells at the largest instead of the size at the part's
centre, and refuses before building when the smallest needs more levels
than max_depth.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-16 17:08:27 -04:00
1 parent 950d86c54e
commit 4d0790565c
3 files changed
+60 -2

No files matched your search

+15
View File
@@ -29,6 +29,13 @@ use crate::{Error, Result};
/// treat anything else as invalid input.
pub trait SizeField {
fn size(&self, p: [f64; 3]) -> f64;
/// The smallest and largest size anywhere, when the field knows them (a mesher that builds
/// from a root size, such as the octree, starts from the largest and plans its depth from
/// the smallest).
fn range(&self) -> Option<(f64, f64)> {
None
}
}
impl<F: Fn([f64; 3]) -> f64> SizeField for F {
@@ -45,6 +52,10 @@ impl SizeField for UniformSize {
fn size(&self, _: [f64; 3]) -> f64 {
self.0
}
fn range(&self) -> Option<(f64, f64)> {
Some((self.0, self.0))
}
}
/// The largest division count of one curve.
@@ -348,6 +359,10 @@ impl SizeField for RegionSize {
}
h
}
fn range(&self) -> Option<(f64, f64)> {
Some((self.finest(), self.global))
}
}
#[cfg(test)]