WIP: thread &Kernel (#313) through geom::tol and surface_drop_lib p3 (not compiled)

This commit is contained in:
Andreas
2026-10-21 20:03:33 +02:00
parent 292d200aa3
commit 4190d481ac
3 changed files with 25 additions and 18 deletions
+2 -2
View File
@@ -464,8 +464,8 @@ fn rust_curve_case(i: &Inputs) -> Result<Output, HarnessError> {
let xsect = i.flag.then_some(tol::tol3d(a[4]));
let r = (|| -> solidcore::Result<Vec<f64>> {
Ok(vec![
tol::scaled_zero_of_curve(&curve)?,
tol::map_to_1d_on_curve(tol::tol3d(a[1]), a[0], &curve)?,
tol::scaled_zero_of_curve(&k, &curve)?,
tol::map_to_1d_on_curve(&k, tol::tol3d(a[1]), a[0], &curve)?,
flag(tol::is_degenerate_curve(&k, Some(&curve), &ivl, xsect)?),
])
})();
+8 -8
View File
@@ -622,9 +622,9 @@ pub fn map_to_1d(tol: f64, deriv: Vec3, natural_interval: &Extent1d) -> f64 {
///
/// Those of the curve evaluation (upstream ignores its status and then reads the unset
/// derivative; [`SolidError::Unported`] always propagates).
pub fn map_to_1d_on_curve(tol: f64, param: f64, curve: &Curve) -> Result<f64> {
pub fn map_to_1d_on_curve(k: &Kernel, tol: f64, param: f64, curve: &Curve) -> Result<f64> {
// evaluate CurvePt
let pd = curve.evaluate(param, 1, true, true)?;
let pd = curve.evaluate(k, param, 1, true, true)?;
let deriv = pd.get(1).copied().ok_or(SolidError::InvalidInput {
operation: "geom::tol::map_to_1d_on_curve",
reason: "no first derivative",
@@ -680,7 +680,7 @@ pub fn is_degenerate_curve(
};
let zone = zone_tol_3d_of_curve(k, curve)?;
let xsect = override_xsect_tol.unwrap_or_else(|| xsect_tol_3d_from_zones(k, zone, zone));
curve.is_degenerate(xsect, Some(interval))
curve.is_degenerate(k, xsect, Some(interval))
}
// ---- scaled zeros ------------------------------------------------------------------
@@ -791,10 +791,10 @@ pub fn scaled_zero_of_volume(k: &Kernel, volume: &Volume) -> Result<f64> {
///
/// Those of `ApproximateLength` and `EvaluatePoint` (upstream ignores the point's
/// status and then reads an unset point; [`SolidError::Unported`] always propagates).
pub fn scaled_zero_of_curve(curve: &Curve) -> Result<f64> {
pub fn scaled_zero_of_curve(k: &Kernel, curve: &Curve) -> Result<f64> {
let ivl = curve.natural_interval();
let length = curve.approximate_length(&ivl, 3, false)?.0;
let pnt = curve.evaluate_point(ivl.evaluate(0.5))?;
let length = curve.approximate_length(k, &ivl, 3, false)?.0;
let pnt = curve.evaluate_point(k, ivl.evaluate(0.5))?;
Ok(scaled_zero2(&pnt, &length))
}
@@ -1088,9 +1088,9 @@ mod tests {
let k = Kernel::default();
let c = test_line(4.0);
// the tolerance over the speed of the curve at the parameter
let speed = c.evaluate(0.5, 1, true, true).unwrap()[1].length();
let speed = c.evaluate(&k, 0.5, 1, true, true).unwrap()[1].length();
assert!(speed > scaled_zero());
let t = map_to_1d_on_curve(1.0e-3, 0.5, &c).unwrap();
let t = map_to_1d_on_curve(&k, 1.0e-3, 0.5, &c).unwrap();
assert_eq!(t, 1.0e-3 / speed);
let ivl = Extent1d::from_min_max(0.0, 1.0);
assert_eq!(is_degenerate_curve(&k, None, &ivl, None), Ok(true));
@@ -418,8 +418,8 @@ impl Surface {
// locals
let s_interval = *interval;
let curve_scaled_zero = scaled_zero_of_curve(curve)?;
let degen_curve = curve.is_degenerate(curve_scaled_zero, Some(interval))?;
let curve_scaled_zero = scaled_zero_of_curve(k, curve)?;
let degen_curve = curve.is_degenerate(k, curve_scaled_zero, Some(interval))?;
let mut start = DropPt::new(s_interval.min(), Some(degen_curve));
let mut end = DropPt::new(s_interval.max(), Some(degen_curve));
let mut max_drop_to_surf = 0.0;
@@ -490,7 +490,7 @@ impl Surface {
// UV Tolerances - proportional to surface 3d/UV mapping size
let srf_nat_domain = self.natural_uv_domain();
let project_size = approx_derivative_lengths(self, &srf_nat_domain)?;
let project_size = approx_derivative_lengths(k, self, &srf_nat_domain)?;
let uv_tol_x = approx_tol_3d / (project_size.x + 1.0);
let uv_tol_y = approx_tol_3d / (project_size.y + 1.0);
@@ -510,6 +510,7 @@ impl Surface {
// Characterize Surface seams and singularities
let mut singular_direction = SurfParamType::Neither;
let closed_u = ignored(this.is_closed(
k,
&srf_nat_domain,
SurfParamType::U,
Some(approx_tol_3d),
@@ -517,6 +518,7 @@ impl Surface {
))?
.is_some_and(|r| r.0);
let closed_v = ignored(this.is_closed(
k,
&srf_nat_domain,
SurfParamType::V,
Some(approx_tol_3d),
@@ -541,7 +543,7 @@ impl Surface {
fs.approx_singularities = u64::from(sings.approx_singular);
// set sStart's Curve Start Point, 1stDeriv, and 2nd Deriv
let pd = curve.evaluate(start.t, 2, true, true)?;
let pd = curve.evaluate(k, start.t, 2, true, true)?;
for (dst, src) in start.crv_pd.iter_mut().zip(pd.iter()) {
*dst = *src;
}
@@ -658,6 +660,7 @@ impl Surface {
// find degenParam value at a singularity that matches the dropCurve UV
// direction
let found = match this.find_degen_param_for_direction(
k,
start.uv_pd[0],
start.crv_pd[1],
true,
@@ -725,6 +728,7 @@ impl Surface {
s_uv_domain.classify_point(start.uv_pd[0], uv_tol_x, Some(uv_tol_y));
let mut poc_u = if on_seam == SurfParamType::U || on_seam == SurfParamType::Both {
start.is_moving_along_boundary(
k,
this,
&srf_nat_domain,
uv_tol_x,
@@ -737,6 +741,7 @@ impl Surface {
};
let mut poc_v = if on_seam == SurfParamType::V || on_seam == SurfParamType::Both {
start.is_moving_along_boundary(
k,
this,
&srf_nat_domain,
uv_tol_x,
@@ -817,6 +822,7 @@ impl Surface {
// try the iso curve shortcut
let iso = this.drop_iso_curve(
k,
&s_uv_domain,
curve,
&s_interval,
@@ -884,7 +890,7 @@ impl Surface {
};
// skip tiny pieces
if curve.approximate_length(&tmp_ivl, 5, false)?.0 < approx_tol_3d {
if curve.approximate_length(k, &tmp_ivl, 5, false)?.0 < approx_tol_3d {
continue;
}
ivl = tmp_ivl;
@@ -895,7 +901,7 @@ impl Surface {
end.t = ivl.max();
// span start curve point and derivatives
let pd = curve.evaluate(start.t, 2, true, true)?;
let pd = curve.evaluate(k, start.t, 2, true, true)?;
for (dst, src) in start.crv_pd.iter_mut().zip(pd.iter()) {
*dst = *src;
}
@@ -961,9 +967,9 @@ impl Surface {
&& knots.len() > 1
{
let end_ivl = Extent1d::from_min_max(start.t, s_interval.max());
let approx_length = curve.approximate_length(&end_ivl, 5, false)?.0;
let approx_length = curve.approximate_length(k, &end_ivl, 5, false)?.0;
if approx_length < approx_tol_3d {
let curve_end = curve.evaluate_point(s_interval.max())?;
let curve_end = curve.evaluate_point(k, s_interval.max())?;
let end_gap_length = start.pd_3d[0].distance(curve_end);
if end_gap_length < approx_tol_3d {
if let Some(last) = knots.last_mut() {
@@ -1045,6 +1051,7 @@ impl Surface {
// test the span
let acc = start.test_span_accuracy(
k,
this,
&s_uv_domain,
curve,