Wave 90/509: kernel: solids an SMLib boolean leaves touching come back as separate solids (and 2 more)
3 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 29d307bdc jyviko: doc: a modelled thread through SMLib cuts the exact groove - 5dd3acdec Brennen Herbruck: kernel-cases: on the kernel branch a thread off its hole or shaft size is refused - b900d6d46 jyviko: kernel: solids an SMLib boolean leaves touching come back as separate solids Co-authored-by: Brennen Herbruck <brennen.herbruck@gmail.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
+41
-53
@@ -524,7 +524,27 @@ fn thread_on_impl(
|
||||
/// profile, 60° flanks): cut from the shaft (external) or the hole wall (internal), running from
|
||||
/// `start` to `end` along the axis. `radius` is the face's own radius; `open` says which ends
|
||||
/// of the threaded length are free ends of the face.
|
||||
/// The groove of [`thread_groove_shape`] as the faceted solid the truck kernel cuts.
|
||||
fn thread_groove(t: &ThreadInfo, radius: f64, open: (bool, bool)) -> Result<solidcraft_geom::Mesh> {
|
||||
let g = thread_groove_shape(t, radius, open)?;
|
||||
Ok(kernel::sweep_helix_mesh(&g.plane, &g.section, g.base, g.axis, g.pitch, g.turns, g.stations)?)
|
||||
}
|
||||
|
||||
/// A thread's groove as a screw sweep: its trapezoid `section` in `plane` (an axial plane
|
||||
/// through `base`), carried `turns` turns about `axis` through `base`, rising `pitch` per turn;
|
||||
/// `stations` per turn where it is faceted.
|
||||
struct GrooveShape {
|
||||
plane: Plane,
|
||||
section: [Vec2; 4],
|
||||
base: Vec3,
|
||||
axis: Vec3,
|
||||
pitch: f64,
|
||||
turns: f64,
|
||||
stations: usize,
|
||||
}
|
||||
|
||||
/// The shape of [`thread_groove`].
|
||||
fn thread_groove_shape(t: &ThreadInfo, radius: f64, open: (bool, bool)) -> Result<GrooveShape> {
|
||||
let (p, d) = (t.pitch, t.major_diameter);
|
||||
let h = p * 3f64.sqrt() / 2.0;
|
||||
let slope = (std::f64::consts::PI / 6.0).tan();
|
||||
@@ -610,52 +630,7 @@ fn thread_groove(t: &ThreadInfo, radius: f64, open: (bool, bool)) -> Result<soli
|
||||
crate::ThreadHandedness::Right => (*k, p),
|
||||
crate::ThreadHandedness::Left => (-*k, -p),
|
||||
};
|
||||
Ok(kernel::sweep_helix_mesh(&plane, §ion, base, sweep_axis, sweep_pitch, (s1 - s0) / p, stations as usize)?)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod thread_handedness_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn thread_handedness_groove_reflects_exactly_about_the_physical_axis() {
|
||||
for direction in [Vec3::Z, Vec3::X, Vec3::new(1.0, 2.0, 3.0)] {
|
||||
for internal in [false, true] {
|
||||
let axis = UnitVec3::new(direction).unwrap();
|
||||
let radius = if internal { 2.5 } else { 3.0 };
|
||||
let mut info = ThreadInfo {
|
||||
feature: 1,
|
||||
body: "Stock".into(),
|
||||
designation: "M6x1".into(),
|
||||
major_diameter: 6.0,
|
||||
radius,
|
||||
pitch: 1.0,
|
||||
internal,
|
||||
handedness: crate::ThreadHandedness::Right,
|
||||
axis_point: Vec3::new(7.0, -5.0, 2.0),
|
||||
axis,
|
||||
start: 1.3,
|
||||
end: 4.3,
|
||||
};
|
||||
let right = thread_groove(&info, radius, (false, true)).unwrap();
|
||||
info.handedness = crate::ThreadHandedness::Left;
|
||||
let left = thread_groove(&info, radius, (false, true)).unwrap();
|
||||
// Reflection in the radial plane of the initial profile, independent of the
|
||||
// helix parameterization: the projected coordinate along the axis stays fixed.
|
||||
let seed = if axis.x.abs() < 0.9 { Vec3::X } else { Vec3::Y };
|
||||
let normal = (seed - *axis * axis.dot(seed)).normalized().unwrap();
|
||||
assert_eq!(right.positions.len(), left.positions.len());
|
||||
for (r, l) in right.positions.iter().zip(&left.positions) {
|
||||
let expected = *r - normal * (2.0 * (*r - info.axis_point).dot(normal));
|
||||
assert!((*l - expected).len() < 1e-10, "physical reflection: {direction:?}/{internal}");
|
||||
assert!(((*r - *l).dot(*axis)).abs() < 1e-10, "axial extent must not change");
|
||||
}
|
||||
let (r, l) = (right.measure(), left.measure());
|
||||
assert!(r.volume > 0.0 && l.volume > 0.0, "outward, watertight sweep");
|
||||
assert!((r.volume - l.volume).abs() < r.volume * 1e-12, "exact tool volume: {r:?}/{l:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(GrooveShape { plane, section, base, axis: sweep_axis, pitch: sweep_pitch, turns: (s1 - s0) / p, stations: stations as usize })
|
||||
}
|
||||
|
||||
/// What a modelled external thread turns off a shaft thicker than its major diameter before it
|
||||
@@ -7241,13 +7216,26 @@ fn eval_feature(doc: &Document, vals: &BTreeMap<String, Value>, f: &Feature, st:
|
||||
}
|
||||
None => (input, cyl.radius),
|
||||
};
|
||||
let groove = thread_groove(&t, radius, ((t.start - cyl.start).abs() < tol, (t.end - cyl.end).abs() < tol))?;
|
||||
// The B-rep boolean can't take helical walls in reasonable time: the body is cut
|
||||
// faceted (curved faces within a two-hundredth of the pitch).
|
||||
let nb = kernel::faceted_boolean(&input.body, &groove, BoolOp::Cut, t.pitch * 0.005)?
|
||||
.ok_or_else(|| DocError::Invalid("the thread removed everything".into()))?;
|
||||
// The groove's faces are its triangles, with no role to name them by.
|
||||
let groove = crate::lineage::Lineage::unnamed_faces(groove.triangles.len());
|
||||
let open = ((t.start - cyl.start).abs() < tol, (t.end - cyl.end).abs() < tol);
|
||||
let (nb, groove_faces) = match kernel::backend()? {
|
||||
kernel::Backend::Truck => {
|
||||
let groove = thread_groove(&t, radius, open)?;
|
||||
// The B-rep boolean can't take helical walls in reasonable time: the body is cut
|
||||
// faceted (curved faces within a two-hundredth of the pitch).
|
||||
let nb = kernel::faceted_boolean(&input.body, &groove, BoolOp::Cut, t.pitch * 0.005)?;
|
||||
(nb, groove.triangles.len())
|
||||
}
|
||||
kernel::Backend::Smlib => {
|
||||
// SMLib cuts the exact groove: its screw sweep, a B-rep boolean.
|
||||
let g = thread_groove_shape(&t, radius, open)?;
|
||||
let section = Region2 { outer: solidcraft_geom::Loop2::polygon(&g.section), holes: Vec::new() };
|
||||
let groove = kernel::sweep_helix(&g.plane, §ion, g.base, g.axis, g.pitch, g.turns)?;
|
||||
(kernel::boolean(&input.body, &groove, BoolOp::Cut)?, groove.face_count())
|
||||
}
|
||||
};
|
||||
let nb = nb.ok_or_else(|| DocError::Invalid("the thread removed everything".into()))?;
|
||||
// The groove's faces have no role to name them by.
|
||||
let groove = crate::lineage::Lineage::unnamed_faces(groove_faces);
|
||||
let lineage = input.lineage.and_then(|l| crate::lineage::Lineage::step(&nb, &[&l, &groove]));
|
||||
let nb = Traced { body: nb, lineage };
|
||||
if let Some(slot) = st.bodies.get_mut(i) {
|
||||
|
||||
@@ -585,6 +585,35 @@ mod smlib {
|
||||
assert_eq!(meets(h).len(), 4, "{}", show(h));
|
||||
}
|
||||
|
||||
/// Cubes sharing an edge, and cubes sharing a vertex: SMLib's union touches itself there;
|
||||
/// it comes back as two closed shells, the shared edge and vertices split into one copy per
|
||||
/// cube, each copy with its edge's history (verified against the geometry).
|
||||
#[test]
|
||||
fn cubes_touching_along_an_edge_or_at_a_vertex_unite_into_two_solids() {
|
||||
let a = boxed(0.0, 0.0, 0.0, 10.0, 10.0, 10.0);
|
||||
for (name, b) in [("edge", boxed(10.0, 10.0, 0.0, 20.0, 20.0, 10.0)), ("vertex", boxed(10.0, 10.0, 10.0, 20.0, 20.0, 20.0))] {
|
||||
let r = through_smlib(&a, &b, BoolOp::Union);
|
||||
assert_eq!(r.solid.boundaries().len(), 2, "{name}");
|
||||
assert_eq!((r.face_count(), r.edge_count()), (12, 24), "{name}");
|
||||
let v = crate::measure(&r).unwrap().volume;
|
||||
assert!((v - 2000.0).abs() < 1e-6 * 2000.0, "{name}: {v}");
|
||||
let h = verified(&r, &[&a, &b], 0.02);
|
||||
assert!(h.faces.iter().all(|f| f.origins.len() == 1), "{name}: {}", show(h));
|
||||
}
|
||||
}
|
||||
|
||||
/// Pieces of a cut meeting along a line (two opposite quarters of a slab cut away) come
|
||||
/// back as separate solids rather than a refusal.
|
||||
#[test]
|
||||
fn a_cut_leaving_pieces_along_a_line_gives_two_solids() {
|
||||
let a = boxed(0.0, 0.0, 0.0, 20.0, 20.0, 10.0);
|
||||
let once = through_smlib(&a, &boxed(10.0, -1.0, -1.0, 21.0, 10.0, 11.0), BoolOp::Cut);
|
||||
let r = through_smlib(&once, &boxed(-1.0, 10.0, -1.0, 10.0, 21.0, 11.0), BoolOp::Cut);
|
||||
assert_eq!(r.solid.boundaries().len(), 2);
|
||||
let v = crate::measure(&r).unwrap().volume;
|
||||
assert!((v - 2000.0).abs() < 1e-6 * 2000.0, "{v}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn disjoint_intersection_is_empty() {
|
||||
let a = boxed(0.0, 0.0, 0.0, 1.0, 1.0, 1.0);
|
||||
|
||||
@@ -35,7 +35,18 @@ mod smlib {
|
||||
BoolOp::Intersect => BooleanOp::Intersect,
|
||||
};
|
||||
let Some(r) = ta.boolean(&tb, kind).map_err(|e| failed("operation", e))? else { return Ok(None) };
|
||||
let check = r.check(CheckLevel::All).map_err(|e| failed("check", e))?;
|
||||
// Solids touching each other along an edge or at a vertex come back as one non-manifold
|
||||
// body, which the export splits into separate solids: SMLib's check is of those, imported
|
||||
// as given (its check of the touching arrangement itself refuses the radial order of
|
||||
// faces round an edge they share).
|
||||
let manifold = r.is_manifold_solid().map_err(|e| failed("check", e))?;
|
||||
let check = if manifold {
|
||||
r.check(CheckLevel::All).map_err(|e| failed("check", e))?
|
||||
} else {
|
||||
let record = r.to_native().map_err(|e| failed("export", e))?;
|
||||
let split = solidcraft_smlib::Brep::from_record(&record, true).map_err(|e| failed("the separate solids", e))?;
|
||||
split.check(CheckLevel::All).map_err(|e| failed("check", e))?
|
||||
};
|
||||
if !check.is_valid() {
|
||||
// Whether an operand failed it already says whose the fault is.
|
||||
let operands: Vec<&str> = [("the first operand", &sa), ("the second operand", &sb)]
|
||||
|
||||
@@ -1 +1 @@
|
||||
ffcf56d195d1d0c98c5190dd993d61732f099642
|
||||
e87e9b3bdc348b00de5238963f387bfa4ba337d6
|
||||
|
||||
+157
-53
@@ -34,7 +34,7 @@ use solidcraft_geom::Vec3;
|
||||
use solidcraft_geom::brep as b;
|
||||
|
||||
use crate::flat::{self, *};
|
||||
use crate::history::Order;
|
||||
use crate::history::{Order, Piece};
|
||||
use crate::import::Arrays;
|
||||
use crate::{Brep, Result, error, ffi, init};
|
||||
|
||||
@@ -576,6 +576,7 @@ enum Loop {
|
||||
}
|
||||
|
||||
/// One edge before renumbering, along its record's parameter.
|
||||
#[derive(Clone)]
|
||||
struct Edge {
|
||||
curve: b::Curve,
|
||||
interval: [f64; 2],
|
||||
@@ -727,66 +728,59 @@ fn native_ordered(arrays: &Arrays) -> Res<(b::Brep, Report, Order)> {
|
||||
face_uses.get_mut(f).ok_or_else(|| invalid("face"))?.push((s, same));
|
||||
}
|
||||
}
|
||||
let mut shell_of: Vec<Option<u32>> = vec![None; n_shells];
|
||||
let mut shells: Vec<Vec<(u32, bool)>> = Vec::new();
|
||||
for s in 0..n_shells {
|
||||
if shell_of.get(s).copied().flatten().is_some() {
|
||||
continue;
|
||||
}
|
||||
let uses = shell_faceuses.get(s).ok_or_else(|| invalid("shell"))?;
|
||||
let (f0, _) = faceuse(uses.start).map_err(|_| invalid("empty shell"))?;
|
||||
let mate = match face_uses.get(f0).map(Vec::as_slice) {
|
||||
Some([(a, _), (b, _)]) => {
|
||||
if *a == s {
|
||||
*b
|
||||
} else {
|
||||
*a
|
||||
}
|
||||
}
|
||||
_ => return Err(invalid("a face without its two uses")),
|
||||
};
|
||||
let side = if mate == s {
|
||||
s
|
||||
} else {
|
||||
let (rs, rm) = (region_of.get(s).copied().unwrap_or(0), region_of.get(mate).copied().unwrap_or(0));
|
||||
match (material(rs), material(rm)) {
|
||||
(false, true) => s,
|
||||
(true, false) => mate,
|
||||
_ => return Err(unsupported("a shell between two material regions or two empty ones")),
|
||||
}
|
||||
};
|
||||
let mut oriented = Vec::new();
|
||||
for fu in shell_faceuses.get(side).ok_or_else(|| invalid("shell"))?.clone() {
|
||||
// Each record shell is one closed boundary between an empty region and a material one: the
|
||||
// faces with the same runtime shell on the empty side and on the material side, as the empty
|
||||
// side uses them. Solids touching along an edge or at a vertex share their empty side's
|
||||
// runtime shell but not their material side's, so each gets its own record shell (the edges
|
||||
// and vertices they share are split below). A sheet's one shell holds both uses of each
|
||||
// face: the `same` one is kept.
|
||||
let mut groups: Vec<((usize, usize), Vec<(u32, bool)>)> = Vec::new();
|
||||
for (s, uses) in shell_faceuses.iter().enumerate() {
|
||||
for fu in uses.clone() {
|
||||
let (f, same) = faceuse(fu)?;
|
||||
// A sheet lists both uses of each face in its one shell: keep the `same` one.
|
||||
if mate == s && !same {
|
||||
continue;
|
||||
}
|
||||
if !face_uses.get(f).is_some_and(|u| u.iter().any(|(o, _)| *o == mate)) {
|
||||
return Err(unsupported("a shell whose faces' other sides are in different shells"));
|
||||
}
|
||||
let key = match face_uses.get(f).map(Vec::as_slice) {
|
||||
Some([(a, _), (b, _)]) if a == b => {
|
||||
if !same {
|
||||
continue;
|
||||
}
|
||||
(*a, *a)
|
||||
}
|
||||
Some([(a, _), (b, _)]) => {
|
||||
let other = if *a == s { *b } else { *a };
|
||||
let (here, there) = (region_of.get(s).copied().unwrap_or(0), region_of.get(other).copied().unwrap_or(0));
|
||||
match (material(here), material(there)) {
|
||||
(false, true) => (s, other),
|
||||
(true, false) => continue,
|
||||
_ => return Err(unsupported("a face between two material regions or two empty ones")),
|
||||
}
|
||||
}
|
||||
_ => return Err(invalid("a face without its two uses")),
|
||||
};
|
||||
let agrees = faces.get(f).ok_or_else(|| invalid("face"))?.agrees;
|
||||
oriented.push((index(f)?, same == agrees));
|
||||
}
|
||||
let id = index(shells.len())?;
|
||||
shells.push(oriented);
|
||||
for k in [s, mate] {
|
||||
if let Some(slot) = shell_of.get_mut(k) {
|
||||
*slot = Some(id);
|
||||
}
|
||||
let at = match groups.iter().position(|(k, _)| *k == key) {
|
||||
Some(at) => at,
|
||||
None => {
|
||||
groups.push((key, Vec::new()));
|
||||
groups.len() - 1
|
||||
}
|
||||
};
|
||||
groups.get_mut(at).ok_or_else(|| invalid("shell"))?.1.push((index(f)?, same == agrees));
|
||||
}
|
||||
}
|
||||
let mut regions = Vec::with_capacity(region_shells.len());
|
||||
for (r, block) in region_shells.iter().enumerate() {
|
||||
let mut listed = Vec::new();
|
||||
for s in block.clone() {
|
||||
let id = shell_of.get(s).copied().flatten().ok_or_else(|| invalid("shell"))?;
|
||||
if !listed.contains(&id) {
|
||||
listed.push(id);
|
||||
for (g, ((empty, solid), _)) in groups.iter().enumerate() {
|
||||
let id = index(g)?;
|
||||
if (*empty == s || *solid == s) && !listed.contains(&id) {
|
||||
listed.push(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
regions.push(b::Region { shells: listed, void: r > 0 && !material(r) });
|
||||
}
|
||||
let shells: Vec<Vec<(u32, bool)>> = groups.into_iter().map(|(_, faces)| faces).collect();
|
||||
// Shells renumbered in first appearance walking the regions.
|
||||
let mut order: Vec<u32> = Vec::new();
|
||||
for r in ®ions {
|
||||
@@ -818,7 +812,10 @@ struct Parts {
|
||||
/// the edges and then the vertex loops, with each face's pcurves; validated. With it, the
|
||||
/// canonical index of each array face and edge.
|
||||
fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerance: f64) -> Res<(b::Brep, Order)> {
|
||||
let Parts { faces, edges, shells, regions } = parts;
|
||||
let Parts { mut faces, mut edges, shells, regions } = parts;
|
||||
let n_edges = edges.len();
|
||||
let (edge_source, vertex_source) = split_shared(&mut faces, &mut edges, &shells, n_vertices)?;
|
||||
let n_vertices = vertex_source.len();
|
||||
let mut face_new: Vec<Option<u32>> = vec![None; faces.len()];
|
||||
let (mut face_order, mut direction) = (Vec::new(), Vec::new());
|
||||
for shell in &shells {
|
||||
@@ -865,7 +862,7 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerance: f64) -> Res
|
||||
return Err(unsupported("wire edges from SMLib"));
|
||||
}
|
||||
if edge_uses.iter().any(|u| u.len() > 2) {
|
||||
return Err(unsupported("the radial order of an edge with more than two uses"));
|
||||
return Err(unsupported("a solid touching itself along an edge"));
|
||||
}
|
||||
let mut vertex_new: Vec<Option<u32>> = vec![None; n_vertices];
|
||||
let mut vertex_order = Vec::new();
|
||||
@@ -934,7 +931,13 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerance: f64) -> Res
|
||||
face_records.push(b::Face { surface: face.surface.clone(), domain: face.domain, loops });
|
||||
}
|
||||
let positions = flat.f(VERTEX_POSITION);
|
||||
let vertices = vertex_order.iter().map(|&v| Ok(b::Vertex { point: v3(positions, v as usize, "vertex")?, tolerance })).collect::<Res<Vec<_>>>()?;
|
||||
let vertices = vertex_order
|
||||
.iter()
|
||||
.map(|&v| {
|
||||
let at = vertex_source.get(v as usize).copied().ok_or_else(|| invalid("vertex"))?;
|
||||
Ok(b::Vertex { point: v3(positions, at, "vertex")?, tolerance })
|
||||
})
|
||||
.collect::<Res<Vec<_>>>()?;
|
||||
let shells = shells
|
||||
.into_iter()
|
||||
.map(|s| {
|
||||
@@ -952,10 +955,111 @@ fn canonical(parts: Parts, n_vertices: usize, flat: View, tolerance: f64) -> Res
|
||||
let placed = |new: &[Option<u32>]| {
|
||||
new.iter().map(|i| i.map(|i| i as usize).ok_or_else(|| invalid("an entity outside the canonical walk"))).collect::<Res<Vec<_>>>()
|
||||
};
|
||||
let order = Order { faces: placed(&face_new)?, edges: placed(&edge_new)? };
|
||||
let edge_new = placed(&edge_new)?;
|
||||
// SMLib's edges split where solids touch: every piece, with the faces it bounds.
|
||||
let mut pieces = Vec::new();
|
||||
for (e, &canonical) in edge_new.iter().enumerate() {
|
||||
let edge = edge_source.get(e).copied().ok_or_else(|| invalid("edge"))?;
|
||||
if edge_source.iter().filter(|s| **s == edge).count() > 1 {
|
||||
let record = brep.edges.get(canonical).ok_or_else(|| invalid("edge"))?;
|
||||
let faces: std::collections::BTreeSet<usize> = record.uses.iter().map(|u| u.face as usize).collect();
|
||||
pieces.push(Piece { edge, canonical, faces: faces.into_iter().collect() });
|
||||
}
|
||||
}
|
||||
pieces.sort_by_key(|p| (p.edge, p.canonical));
|
||||
let mut edges_out = Vec::with_capacity(n_edges);
|
||||
for e in 0..n_edges {
|
||||
edges_out
|
||||
.push(pieces.iter().find(|p| p.edge == e).map_or_else(|| edge_new.get(e).copied().ok_or_else(|| invalid("edge")), |p| Ok(p.canonical))?);
|
||||
}
|
||||
let order = Order { faces: placed(&face_new)?, edges: edges_out, pieces };
|
||||
Ok((brep, order))
|
||||
}
|
||||
|
||||
/// Edges and vertices that solids touching each other share (faces of more than one shell use
|
||||
/// them), split into one copy per shell, so each shell is a closed manifold boundary of its own.
|
||||
/// The geometry is unchanged. Returns, for every edge and vertex after the split, the array edge
|
||||
/// and vertex it is (a copy's original).
|
||||
fn split_shared(faces: &mut [Face], edges: &mut Vec<Edge>, shells: &[Vec<(u32, bool)>], n_vertices: usize) -> Res<(Vec<usize>, Vec<usize>)> {
|
||||
let mut shell_of = vec![None; faces.len()];
|
||||
for (k, shell) in shells.iter().enumerate() {
|
||||
for &(f, _) in shell {
|
||||
*shell_of.get_mut(f as usize).ok_or_else(|| invalid("face"))? = Some(k);
|
||||
}
|
||||
}
|
||||
let mut edge_source: Vec<usize> = (0..edges.len()).collect();
|
||||
// Edges: the first shell to use one keeps it, every other gets a copy.
|
||||
let mut edge_shell: Vec<Option<usize>> = vec![None; edges.len()];
|
||||
let mut copies: HashMap<(u32, usize), u32> = HashMap::new();
|
||||
for (f, face) in faces.iter_mut().enumerate() {
|
||||
let Some(k) = shell_of.get(f).copied().flatten() else { continue };
|
||||
for l in &mut face.loops {
|
||||
let Loop::Edges(uses) = l else { continue };
|
||||
for (e, _) in uses.iter_mut() {
|
||||
let slot = edge_shell.get_mut(*e as usize).ok_or_else(|| invalid("edge"))?;
|
||||
match slot {
|
||||
None => *slot = Some(k),
|
||||
Some(owner) if *owner == k => {}
|
||||
Some(_) => {
|
||||
let copy = match copies.get(&(*e, k)) {
|
||||
Some(c) => *c,
|
||||
None => {
|
||||
let c = index(edges.len())?;
|
||||
edges.push(edges.get(*e as usize).ok_or_else(|| invalid("edge"))?.clone());
|
||||
edge_source.push(*e as usize);
|
||||
edge_shell.push(Some(k));
|
||||
copies.insert((*e, k), c);
|
||||
c
|
||||
}
|
||||
};
|
||||
*e = copy;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Vertices: likewise, through the edges (each now in one shell) and the vertex loops.
|
||||
let mut vertex_source: Vec<usize> = (0..n_vertices).collect();
|
||||
let mut vertex_shell: Vec<Option<usize>> = vec![None; n_vertices];
|
||||
let mut vertex_copies: HashMap<(u32, usize), u32> = HashMap::new();
|
||||
let mut place = |v: &mut u32, k: usize| -> Res<()> {
|
||||
let slot = vertex_shell.get_mut(*v as usize).ok_or_else(|| invalid("vertex"))?;
|
||||
match slot {
|
||||
None => *slot = Some(k),
|
||||
Some(owner) if *owner == k => {}
|
||||
Some(_) => {
|
||||
let copy = match vertex_copies.get(&(*v, k)) {
|
||||
Some(c) => *c,
|
||||
None => {
|
||||
let c = index(vertex_source.len())?;
|
||||
vertex_source.push(*v as usize);
|
||||
vertex_shell.push(Some(k));
|
||||
vertex_copies.insert((*v, k), c);
|
||||
c
|
||||
}
|
||||
};
|
||||
*v = copy;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
};
|
||||
for (e, edge) in edges.iter_mut().enumerate() {
|
||||
let Some(k) = edge_shell.get(e).copied().flatten() else { continue };
|
||||
for v in &mut edge.vertices {
|
||||
place(v, k)?;
|
||||
}
|
||||
}
|
||||
for (f, face) in faces.iter_mut().enumerate() {
|
||||
let Some(k) = shell_of.get(f).copied().flatten() else { continue };
|
||||
for l in &mut face.loops {
|
||||
if let Loop::Vertex(v) = l {
|
||||
place(v, k)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok((edge_source, vertex_source))
|
||||
}
|
||||
|
||||
/// A face's pcurves, edge loop by edge loop, from the plain-record routine on the face's
|
||||
/// records, each loop moved by whole periods into the face's domain.
|
||||
fn pcurves(surface: &b::Surface, domain: [[f64; 2]; 2], loops: &[Loop], edges: &[b::Edge], tolerance: f64) -> Res<Vec<Vec<b::Curve2>>> {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
use std::ffi::{c_char, c_void};
|
||||
|
||||
/// `SMLIB_ABI_VERSION` this crate was written against.
|
||||
pub const ABI_VERSION: i32 = 2;
|
||||
pub const ABI_VERSION: i32 = 3;
|
||||
|
||||
pub const OK: i32 = 0;
|
||||
pub const ERR_EXCEPTION: i32 = -1000;
|
||||
|
||||
+48
-10
@@ -41,10 +41,26 @@ pub struct Raw {
|
||||
|
||||
/// Where one body's faces and edges go in canonical order: `faces[i]` is the canonical index of
|
||||
/// SMLib's face i, likewise for edges. Empty means SMLib's order is the canonical one.
|
||||
///
|
||||
/// An SMLib edge solids touch along (non-manifold) becomes one record edge per solid:
|
||||
/// `edges[i]` is the first of them, and `pieces` lists every piece of such an edge, the first
|
||||
/// too, with the canonical faces it bounds.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct Order {
|
||||
pub faces: Vec<usize>,
|
||||
pub edges: Vec<usize>,
|
||||
pub pieces: Vec<Piece>,
|
||||
}
|
||||
|
||||
/// One record edge of an SMLib edge split where solids touch along it.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
pub struct Piece {
|
||||
/// The SMLib edge.
|
||||
pub edge: usize,
|
||||
/// The record edge.
|
||||
pub canonical: usize,
|
||||
/// The canonical faces it bounds, ascending.
|
||||
pub faces: Vec<usize>,
|
||||
}
|
||||
|
||||
impl Brep {
|
||||
@@ -122,7 +138,23 @@ impl Raw {
|
||||
}
|
||||
Ok(at)
|
||||
};
|
||||
let (fat, eat) = (place(&result.faces, self.faces.len())?, place(&result.edges, self.edges.len())?);
|
||||
let fat = place(&result.faces, self.faces.len())?;
|
||||
// Each raw edge's record edges with the faces each bounds where it is split (`None`: as
|
||||
// SMLib has them); together a permutation of the result's edges.
|
||||
let n_edges = self.edges.len() + result.pieces.len() - result.pieces.iter().map(|p| p.edge).collect::<BTreeSet<_>>().len();
|
||||
let mut targets: Vec<(usize, usize, Option<&[usize]>)> = Vec::with_capacity(n_edges);
|
||||
for i in 0..self.edges.len() {
|
||||
let mut split = result.pieces.iter().filter(|p| p.edge == i).peekable();
|
||||
if split.peek().is_none() {
|
||||
targets.push((i, map(&result.edges, i)?, None));
|
||||
} else {
|
||||
targets.extend(split.map(|p| (i, p.canonical, Some(p.faces.as_slice()))));
|
||||
}
|
||||
}
|
||||
let distinct: BTreeSet<usize> = targets.iter().map(|t| t.1).collect();
|
||||
if targets.len() != n_edges || distinct.len() != n_edges || targets.iter().any(|t| t.1 >= n_edges) {
|
||||
return Err(bad("the result's order is no permutation"));
|
||||
}
|
||||
|
||||
let mut faces: Vec<Option<FaceProv>> = vec![None; self.faces.len()];
|
||||
for (f, at) in self.faces.iter().zip(&fat) {
|
||||
@@ -131,14 +163,20 @@ impl Raw {
|
||||
}
|
||||
let faces: Vec<FaceProv> = faces.into_iter().collect::<Option<_>>().ok_or(bad("the result's order is no permutation"))?;
|
||||
|
||||
let mut edges: Vec<Option<EdgeProv>> = vec![None; self.edges.len()];
|
||||
for (e, at) in self.edges.iter().zip(&eat) {
|
||||
let bounds: BTreeSet<usize> = e
|
||||
.faces
|
||||
.iter()
|
||||
.map(|f| fat.get(*f).copied().ok_or(bad("an edge lies on a face outside the result")))
|
||||
.collect::<std::result::Result<_, _>>()?;
|
||||
let bounds: Vec<usize> = bounds.into_iter().collect();
|
||||
let mut edges: Vec<Option<EdgeProv>> = vec![None; n_edges];
|
||||
for &(i, at, split) in &targets {
|
||||
let e = self.edges.get(i).ok_or(bad("an edge lies outside the result"))?;
|
||||
let bounds: Vec<usize> = match split {
|
||||
Some(faces) => faces.to_vec(),
|
||||
None => {
|
||||
let bounds: BTreeSet<usize> = e
|
||||
.faces
|
||||
.iter()
|
||||
.map(|f| fat.get(*f).copied().ok_or(bad("an edge lies on a face outside the result")))
|
||||
.collect::<std::result::Result<_, _>>()?;
|
||||
bounds.into_iter().collect()
|
||||
}
|
||||
};
|
||||
let origins = if e.origins.is_empty() {
|
||||
// New: where its two faces meet, each side what that face came from.
|
||||
let side = |f: usize| faces.get(f).and_then(|p| Side::new(p.origins.iter().copied()));
|
||||
@@ -157,7 +195,7 @@ impl Raw {
|
||||
.collect::<std::result::Result<_, Failed>>()?;
|
||||
set.into_iter().collect()
|
||||
};
|
||||
edges[*at] = Some(EdgeProv { faces: bounds, origins });
|
||||
*edges.get_mut(at).ok_or(bad("the result's order is no permutation"))? = Some(EdgeProv { faces: bounds, origins });
|
||||
}
|
||||
let edges: Vec<EdgeProv> = edges.into_iter().collect::<Option<_>>().ok_or(bad("the result's order is no permutation"))?;
|
||||
Ok(History { operands: operands.len(), faces, edges })
|
||||
|
||||
@@ -60,9 +60,9 @@ fn renumbers_into_canonical_order() {
|
||||
let raw = Raw::decode(RECORDS).unwrap();
|
||||
// Operand 0's SMLib face 2 is its canonical face 5, edge 7 its edge 0; the result's faces
|
||||
// and edges are listed backwards.
|
||||
let a = Order { faces: vec![1, 2, 5, 0, 3, 4], edges: vec![1, 2, 3, 4, 5, 6, 7, 0] };
|
||||
let b = Order { faces: vec![0, 1, 2, 3, 4], edges: vec![0, 1, 2, 3] };
|
||||
let result = Order { faces: vec![2, 1, 0], edges: vec![2, 1, 0] };
|
||||
let a = Order { faces: vec![1, 2, 5, 0, 3, 4], edges: vec![1, 2, 3, 4, 5, 6, 7, 0], pieces: vec![] };
|
||||
let b = Order { faces: vec![0, 1, 2, 3, 4], edges: vec![0, 1, 2, 3], pieces: vec![] };
|
||||
let result = Order { faces: vec![2, 1, 0], edges: vec![2, 1, 0], pieces: vec![] };
|
||||
let h = raw.history(&[a, b], &result).unwrap();
|
||||
assert_eq!(h.faces[2].origins, vec![face(0, 5)]);
|
||||
assert_eq!(h.faces[0].origins, vec![face(0, 1), face(1, 0)]);
|
||||
@@ -79,10 +79,10 @@ fn bad_orders_are_errors() {
|
||||
// An origin on an operand that isn't there.
|
||||
assert!(raw.history(std::slice::from_ref(&ok), &ok).is_err());
|
||||
// An operand order too short for an origin.
|
||||
assert!(raw.history(&[Order { faces: vec![0], edges: vec![] }, ok.clone()], &ok).is_err());
|
||||
assert!(raw.history(&[Order { faces: vec![0], edges: vec![], pieces: vec![] }, ok.clone()], &ok).is_err());
|
||||
// A result order that isn't a permutation.
|
||||
assert!(raw.history(&[ok.clone(), ok.clone()], &Order { faces: vec![0, 0, 1], edges: vec![] }).is_err());
|
||||
assert!(raw.history(&[ok.clone(), ok.clone()], &Order { faces: vec![0, 1, 3], edges: vec![] }).is_err());
|
||||
assert!(raw.history(&[ok.clone(), ok.clone()], &Order { faces: vec![0, 0, 1], edges: vec![], pieces: vec![] }).is_err());
|
||||
assert!(raw.history(&[ok.clone(), ok.clone()], &Order { faces: vec![0, 1, 3], edges: vec![], pieces: vec![] }).is_err());
|
||||
}
|
||||
|
||||
/// A box with its edge 0 (between faces 4 and 5) filleted, as SMLib reports it: the fillet face
|
||||
|
||||
@@ -1,32 +1,13 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#1443",
|
||||
"tangency-labs/solidcraft#3060"
|
||||
"tangency-labs/solidcraft#3060",
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M5x0.7 thread in a 5 mm hole drawn at the thread's nominal size (was refused: it would cut 0.00 mm of the thread's depth)",
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 5 mm hole through a D14 x 4.2 disc, drawn at the thread's nominal size, takes a modelled M5x0.7: the hole is first filled to the tap drill (major - pitch = 4.3 mm, rho=2.15), then the groove is cut, the same thread as in a hole drilled at the tap drill. Whole length, both ends free (6 turns): V = pi 7^2 4.2 - pi 2.15^2 4.2 - 6 x V_turn(clipped at rho) = 646.5398 - 60.9925 - 6 x 1.45465 = 576.8194 mm3. The thin lips a tap leaves at each end are below 0.2% of the volume. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 576.8194,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-7,
|
||||
-7,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
7,
|
||||
7,
|
||||
4.2
|
||||
]
|
||||
},
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
2.1
|
||||
]
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5x0.7: tap drill = 5 - 0.7 = 4.3 mm; depth 5H/8 = 5/8 x 0.7 x sqrt3/2 = 0.379 mm; the 5 mm hole is at the major diameter, so nothing would be cut. Expected message: \"this 5 mm hole is too wide for a modelled M5x0.7 thread: it would cut 0.00 mm of the thread's 0.38 mm depth; drill 4.3 mm for M5x0.7, or thread this hole M6\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 5 mm hole is too wide for a modelled M5x0.7 thread: it would cut 0.00 mm of the thread's 0.38 mm depth; drill 4.3 mm for M5x0.7, or thread this hole M6"
|
||||
}
|
||||
|
||||
@@ -1,31 +1,12 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2152"
|
||||
"tangency-labs/solidcraft#2152",
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M3x0.2 thread in a 3 mm hole drawn at the thread's nominal size (was refused like any hole at the nominal size)",
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 3 mm hole through a D10 x 2 disc, drawn at the thread's nominal size, takes a modelled M3x0.2: the hole is first filled to the tap drill (major - pitch = 2.8 mm, rho=1.4), then the groove is cut, the same thread as in a hole drilled at the tap drill. Whole length, both ends free (10 turns): V = pi 5^2 2 - pi 1.4^2 2 - 10 x V_turn(clipped at rho) = 157.0796 - 12.3150 - 10 x 0.07477 = 144.0169 mm3. The thin lips a tap leaves at each end are below 0.2% of the volume. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 144.0169,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-5,
|
||||
-5,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
5,
|
||||
5,
|
||||
2
|
||||
]
|
||||
},
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
1.0
|
||||
]
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M3x0.2: tap drill = 3 - 0.2 = 2.8 mm; depth 5H/8 = 5/8 x 0.2 x sqrt3/2 = 0.108 mm; the 3 mm hole is at the major diameter. Expected message: \"this 3 mm hole is too wide for a modelled M3x0.2 thread: it would cut 0.00 mm of the thread's 0.11 mm depth; drill 2.8 mm for M3x0.2, or thread this hole M4\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 3 mm hole is too wide for a modelled M3x0.2 thread: it would cut 0.00 mm of the thread's 0.11 mm depth; drill 2.8 mm for M3x0.2, or thread this hole M4"
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2369",
|
||||
"tangency-labs/solidcraft#2688",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M8 thread in a hole narrower than the thread's minor diameter (6.3 mm, and 6 mm in #2688), refused as 'the face is too far from the thread's diameter'",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 6.3 mm hole through a D16 x 5 disc takes a modelled M8 (P=1.25). The hole is narrower than the thread's minor diameter 8 - 2 x 5H/8 = 6.6468 mm (ISO D1 = D - 1.0825 P), so a tap takes the extra material off first: the hole is bored out to the minor diameter (rho=3.3234) and the groove cut from there. Whole length (4 turns): V = pi 8^2 5 - pi rho^2 5 - 4 x V_turn(clipped at rho) = 1005.3096 - 173.4961 - 4 x 8.32555 = 798.5114 mm3. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 798.5114,
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
2.5
|
||||
],
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-8,
|
||||
-8,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
8,
|
||||
8,
|
||||
5
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2369",
|
||||
"tangency-labs/solidcraft#2688",
|
||||
"tangency-labs/solidcraft#2853",
|
||||
"tangency-labs/solidcraft#1018"
|
||||
],
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M8 (P 1.25): tap drill = 8 - 1.25 = 6.75 mm; basic minor diameter D1 = 8 - 2 x 5H/8 = 8 - 1.353 = 6.647 mm; a 6.3 mm hole is below the minor diameter, so the thread's teeth would fill part of the hole. Expected message: \"this 6.3 mm hole is too narrow for a modelled M8 thread (its teeth would fill the hole); drill 6.75 mm for M8\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 6.3 mm hole is too narrow for a modelled M8 thread (its teeth would fill the hole); drill 6.75 mm for M8"
|
||||
}
|
||||
-26
@@ -1,26 +0,0 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2705"
|
||||
],
|
||||
"what": "a modelled M14 thread on a 14.6 mm boss, slightly thicker than the thread (refused: the face is too far from the thread's diameter)",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 14.6 mm boss (R=7.3, 15 tall) on a 20x20x4 plate takes a modelled M14 (P=2) over 10 mm from its free top end. The boss is thicker than the major diameter, so a die turns it down to 14 mm over the threaded length first (ring pi (7.3^2 - 7^2) 10 = 134.7743) and the groove is cut from there (5 turns, 50.18900 each). V = 1600 + pi 7.3^2 15 - 134.7743 - 5 x 50.18900 = 3725.5127 mm3. The groove's last end may nick the unturned boss by well under 0.2 mm3. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 3725.5127,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-10,
|
||||
-10,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
10,
|
||||
10,
|
||||
19
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2705",
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled thread on a shaft that isn't the thread's size: refused with the size to use, never a silent change of the shaft",
|
||||
"source": "analytic",
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the shaft it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M14: an external thread's major diameter is 14 mm; a 14.6 mm shaft is above it, so the thread would have to turn the shaft down. Expected message: \"this 14.6 mm shaft is too thick for a modelled M14 thread; make the shaft 14 mm for M14\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 14.6 mm shaft is too thick for a modelled M14 thread; make the shaft 14 mm for M14"
|
||||
}
|
||||
@@ -1,31 +1,12 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#2969"
|
||||
"tangency-labs/solidcraft#2969",
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M48x0.75 internal thread in a 48 mm hole drawn at the thread's nominal size",
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 48 mm hole through a D54 x 3 disc, drawn at the thread's nominal size, takes a modelled M48x0.75: the hole is first filled to the tap drill (major - pitch = 47.25 mm, rho=23.625), then the groove is cut, the same thread as in a hole drilled at the tap drill. Whole length, both ends free (4 turns): V = pi 27^2 3 - pi 23.625^2 3 - 4 x V_turn(clipped at rho) = 6870.6631 - 5260.3515 - 4 x 17.37563 = 1540.8091 mm3. The thin lips a tap leaves at each end are below 0.2% of the volume. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 1540.8091,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-27,
|
||||
-27,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
27,
|
||||
27,
|
||||
3
|
||||
]
|
||||
},
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
1.5
|
||||
]
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M48x0.75: tap drill = 48 - 0.75 = 47.25 mm; depth 5H/8 = 5/8 x 0.75 x sqrt3/2 = 0.406 mm; the 48 mm hole is at the major diameter. Expected message: \"this 48 mm hole is too wide for a modelled M48x0.75 thread: it would cut 0.00 mm of the thread's 0.41 mm depth; drill 47.25 mm for M48x0.75, or thread this hole M56\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 48 mm hole is too wide for a modelled M48x0.75 thread: it would cut 0.00 mm of the thread's 0.41 mm depth; drill 47.25 mm for M48x0.75, or thread this hole M56"
|
||||
}
|
||||
|
||||
@@ -1,32 +1,13 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#3366",
|
||||
"tangency-labs/solidcraft#3367"
|
||||
"tangency-labs/solidcraft#3367",
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M20 internal thread in a 20 mm hole, made after the 20 mm cylinder's own thread",
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 20 mm hole through a D48 x 10 disc, drawn at the thread's nominal size, takes a modelled M20: the hole is first filled to the tap drill (major - pitch = 17.5 mm, rho=8.75), then the groove is cut, the same thread as in a hole drilled at the tap drill. Whole length, both ends free (4 turns): V = pi 24^2 10 - pi 8.75^2 10 - 4 x V_turn(clipped at rho) = 18095.5737 - 2405.2819 - 4 x 74.96751 = 15390.4218 mm3. The thin lips a tap leaves at each end are below 0.2% of the volume. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 15390.4218,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-24,
|
||||
-24,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
24,
|
||||
24,
|
||||
10
|
||||
]
|
||||
},
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
5.0
|
||||
]
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M20 (P 2.5): tap drill = 20 - 2.5 = 17.5 mm; depth 5H/8 = 5/8 x 2.5 x sqrt3/2 = 1.353 mm; the 20 mm hole is at the major diameter. Expected message: \"this 20 mm hole is too wide for a modelled M20 thread: it would cut 0.00 mm of the thread's 1.35 mm depth; drill 17.5 mm for M20, or thread this hole M22\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 20 mm hole is too wide for a modelled M20 thread: it would cut 0.00 mm of the thread's 1.35 mm depth; drill 17.5 mm for M20, or thread this hole M22"
|
||||
}
|
||||
|
||||
@@ -1,32 +1,12 @@
|
||||
{
|
||||
"sources": [
|
||||
"tangency-labs/solidcraft#995",
|
||||
"tangency-labs/solidcraft#1018"
|
||||
"tangency-labs/solidcraft#1018",
|
||||
"tangency-labs/solidcraft#2853"
|
||||
],
|
||||
"what": "a modelled M5 thread in a hole drawn at 5 mm, the thread's own size (nothing was cut: the wall only turned faceted)",
|
||||
"what": "a modelled thread on a hole that isn't the thread's size: refused with the size to use, never a silent change of the hole",
|
||||
"source": "analytic",
|
||||
"method": "ISO 68-1 basic profile: H = P sqrt3/2, basic depth 5H/8. External groove (the space between teeth): a trapezoid P/4 wide at the root radius d/2 - 5H/8, widening by 2 tan30 per unit of radius to 7P/8 at d/2. Internal groove: P/8 wide at the major radius d/2, widening to 3P/4 at the minor radius, cut only where there is material (r >= hole radius). Pappus: volume per turn = 2 pi A rc (A the trapezoid area, rc its centroid radius from the axis); a helical sweep of L/P turns removes exactly (L/P) x that, where each end of the thread is a free end or lies inside material. A 5 mm hole through a D14 x 4 disc, drawn at the thread's nominal size, takes a modelled M5: the hole is first filled to the tap drill (major - pitch = 4.2 mm, rho=2.1), then the groove is cut, the same thread as in a hole drilled at the tap drill. Whole length, both ends free (5 turns): V = pi 7^2 4 - pi 2.1^2 4 - 5 x V_turn(clipped at rho) = 615.7522 - 55.4177 - 5 x 1.87431 = 550.9629 mm3. The thin lips a tap leaves at each end are below 0.2% of the volume. Tolerance 1%: a modelled thread is a faceted helical solid (radial chord error up to 1% of the pitch on every wall, i.e. a volume deficit of about 4/3 x sag/R).",
|
||||
"outcome": "solid",
|
||||
"body_count": 1,
|
||||
"volume_mm3": 550.9629,
|
||||
"tolerance": {
|
||||
"rel": 0.01
|
||||
},
|
||||
"bbox": {
|
||||
"min": [
|
||||
-7,
|
||||
-7,
|
||||
0
|
||||
],
|
||||
"max": [
|
||||
7,
|
||||
7,
|
||||
4
|
||||
]
|
||||
},
|
||||
"center_of_mass": [
|
||||
0,
|
||||
0,
|
||||
2.0
|
||||
]
|
||||
"method": "Decision (#1018, #2853): a modelled thread never changes the size of the hole it is on; one that isn't the thread's size is refused, naming the size to use. A fill-to-tap-drill or turn-down option would be opt-in, off by default (see #3060), and get its own case. The refusal's numbers, from ISO 68-1 (H = P sqrt3/2, basic depth 5H/8): M5 (P 0.8): tap drill = 5 - 0.8 = 4.2 mm; basic depth 5H/8 = 5/8 x 0.8 x sqrt3/2 = 0.433 mm; a 5 mm hole is at the major diameter, so the internal thread (major d, minor d - 2 x 5H/8) cuts 0.00 mm. Expected message: \"this 5 mm hole is too wide for a modelled M5 thread: it would cut 0.00 mm of the thread's 0.43 mm depth; drill 4.2 mm for M5, or thread this hole M6\".",
|
||||
"outcome": "refused",
|
||||
"refusal": "this 5 mm hole is too wide for a modelled M5 thread: it would cut 0.00 mm of the thread's 0.43 mm depth; drill 4.2 mm for M5, or thread this hole M6"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user