Change default tolerance value to not depend on units (#6055)

This commit is contained in:
Jonathan Tran
2025-03-31 15:28:15 -04:00
committed by GitHub
parent 0b1e79871f
commit d8e84cb5e3
5 changed files with 15 additions and 24 deletions

View File

@ -8,6 +8,7 @@ use kittycad_modeling_cmds as kcmc;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use super::DEFAULT_TOLERANCE;
use crate::{
errors::{KclError, KclErrorDetails},
execution::{
@ -15,7 +16,6 @@ use crate::{
EdgeCut, ExecState, ExtrudeSurface, FilletSurface, GeoMeta, KclValue, Solid, TagIdentifier,
},
parsing::ast::types::TagNode,
settings::types::UnitLength,
std::Args,
SourceRange,
};
@ -165,7 +165,7 @@ async fn inner_fillet(
edge_id,
object_id: solid.id,
radius: LengthUnit(radius),
tolerance: LengthUnit(tolerance.unwrap_or_else(|| default_tolerance(&exec_state.length_unit().into()))),
tolerance: LengthUnit(tolerance.unwrap_or(DEFAULT_TOLERANCE)),
cut_type: CutType::Fillet,
// We make this a none so that we can remove it in the future.
face_id: None,
@ -195,17 +195,6 @@ async fn inner_fillet(
Ok(solid)
}
pub(crate) fn default_tolerance(units: &UnitLength) -> f64 {
match units {
UnitLength::Mm => 0.0000001,
UnitLength::Cm => 0.0000001,
UnitLength::In => 0.0000001,
UnitLength::Ft => 0.0001,
UnitLength::Yd => 0.001,
UnitLength::M => 0.001,
}
}
#[cfg(test)]
mod tests {
use super::*;