A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, threaded by a bar carried along a screw so fine that the turns of the groove meet: the rod's own surface is cut away everywhere, and what is left between neighbouring turns is a thread whose crest is a sharp helical edge.
The bar, as placed, is the box 4.5 ≤ x ≤ 12, −8 ≤ y ≤ 8, −0.45 ≤ z ≤ 0.45: it points at the rod's axis, its flat tip (the face x = 4.5) 0.5 inside the rod, and it is 0.9 wide along the axis.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 1 for every whole turn, rigidly. It runs from a turn of −180° (the bar lowered 0.5, wholly below the rod) to a turn of 7380° (raised 20.5, wholly above it). Cut from the rod everything the bar passes through.
At distance ρ from the axis the groove is 0.9 + acos(4.5/ρ)/π wide along it (its walls are where the tip's long edges pass). That reaches the whole lead, 1, at ρ = 4.5/cos 18° ≈ 4.7316: there the walls of neighbouring turns meet in the crest, and beyond it nothing of the rod is left. Each turn of the thread is about 0.23 deep, 0.1 wide at its root and sharp at its crest.
expected
closed form
volume
1276.702999
π ρf²·20 − 20·2π∫ ρ w(ρ) dρ from 4.5 to ρf, w(ρ) = 0.9 + acos(4.5/ρ)/π, ρf = 4.5/cos(π/10) where w = 1 (beyond it the rod is wholly cut away)
area
916.1203965
the root 2π·4.5·20·0.9 + two ends 2(π ρf² − 2π∫ ρ w dρ) + two helicoidal walls 2(20/c)·½[√(U(U + c²)) + c² ln((√U + √(U + c²))/c)], c = 1/2π, U = ρf² − 4.5²
Drawing
TopIsometricFrontRight
Third-angle projection, the three views at one scale. Drawn from occt's result, which passed.
† works around a missing feature. Pick an entry to see its solid, its measures and its code.
Drag to turn, scroll or pinch to zoom, right-drag to move. The solid as its STEP file has it, meshed in the browser by Open CASCADE (occt-import-js): each face colored by the kind of its surface, and the edges that bound each face drawn between them.
Drag to turn, scroll or pinch to zoom, right-drag to move. Black lines are where the surface turns sharply; red ones, seen through the solid, are open edges, where the mesh is not closed.
Time
31.5 s; CPU time 104.7 s; peak memory 257.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Data
measured
expected
rel. error
volume
1276.702999
1276.702999
3.7e-15
area
916.1203965
916.1203965
1.7e-15
agrees with
kentron, next.BREP, cadrs, springrep
faces
22 cylinder, 2 other, 2 plane
mesh
128042 triangles, closed
centre of gravity
(-3.62743e-06, 3.04532e-07, 10) its triangles
inertia
about it, of unit density: Ixx 49025.5; Iyy 49025.5; Izz 12964.9; Ixy 0.00061456; Iyz -3.21591; Izx 0.0136975
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, threaded by the bar 4.5 ≤ x ≤ 12,//! −8 ≤ y ≤ 8, −0.45 ≤ z ≤ 0.45 screwed about z, right-handed and rising 1 a turn, from a turn of//! −180° to 7380°: the groove's turns meet, leaving a thread with sharp crests.//!//! Built by the kernel's closed sweep cut from the rod: `cut_from` takes the bar (its edges run//! along the screw's axis or square to it) and meets them with its helicoidal sheets, which the//! lead of 1 packs 21 turns of, a hair apart at the sharp crests.usecrate::sketch::block;
use cad_kernel::build::{disc, prism};
use cad_kernel::geom::tolerance;
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
constLEAD: f64 = 1.;
constROLL: [f64; 2] = [-180f64.to_radians(), 7380f64.to_radians()];
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0., 0., 0.], up, ROD_RADIUS), 0., ROD_LENGTH)?;
let bar = block([4.5, -8., -0.45], [12., 8., 0.45])?;
// the screw about z: a radian a radian of the roll, rising the lead a turnlet path = Trajectory::Twist(Screw {
origin: [0., 0., 0.], axis: up, ratio: 1., advance: LEAD,
});
// the kernel's swept solid cut from the rod on one arrangement: the bar's edges along the axis// and square to it, screwed into cylinders and helicoidal sheets (a box's flat faces mesh// exactly, at any bar)let size = rod.size().max(bar.size());
cut_from(&rod, &bar, &path, ROLL, bar.size(), tolerance(size))
.map_err(|why| format!("the bar's sweep not built: {why:?}"))
}
Time
13.2 s; CPU time 13.2 s; peak memory 396.3 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a solid
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1276.703
1276.702999
3.9e-10
area
916.1204057
916.1203965
1.0e-08
agrees with
no other kernel
mesh
515188 triangles, closed
centre of gravity
(-1.93007e-09, -1.56065e-10, 10) its STEP's solid
inertia
about it, of unit density: Ixx 49043.5; Iyy 49043.5; Izz 12973.5; Ixy 7.0376e-07; Iyz -3.15429; Izx 8.45029e-07
"""A thread so fine its crests are sharp. A rod, the cylinder of radius 5 about the z axis from z =
0 to z = 20, threaded by a bar carried along a screw so fine that the turns of the groove meet: the
rod's own surface is cut away everywhere, and what is left between neighbouring turns is a thread
whose crest is a sharp helical edge.
The bar, as placed, is the box 4.5 ≤ x ≤ 12, −8 ≤ y ≤ 8, −0.45 ≤ z ≤ 0.45: it points at the rod's
axis, its flat tip (the face x = 4.5) 0.5 inside the rod, and it is 0.9 wide along the axis.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 1
for every whole turn, rigidly. It runs from a turn of −180° (the bar lowered 0.5, wholly below the
rod) to a turn of 7380° (raised 20.5, wholly above it). Cut from the rod everything the bar passes
through.
At distance ρ from the axis the groove is 0.9 + acos(4.5/ρ)/π wide along it (its walls are where
the tip's long edges pass). That reaches the whole lead, 1, at ρ = 4.5/cos 18° ≈ 4.7316: there the
walls of neighbouring turns meet in the crest, and beyond it nothing of the rod is left. Each turn
of the thread is about 0.23 deep, 0.1 wide at its root and sharp at its crest."""fromOCP.BRepAlgoAPIimportBRepAlgoAPI_CommonfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Ax2, gp_Pnt
from bench importRefusedfrom sweep import cut, flat_contacts_screwed, screw, screwed
ROD_RADIUS, ROD_LENGTH = 5, 20BAR = ((4.5, -8, -0.45), (12, 8, 0.45))
LEAD = 1# rise per whole turnSTART, STOP = -180, 7380# degrees# A screw about the rod's axis keeps every point's distance from it, so only the part of the bar# within the rod's radius ever enters the rod; the bar is cut down to the part within this.REACH = 5.01defbuild():
bar = BRepPrimAPI_MakeBox(gp_Pnt(*BAR[0]), gp_Pnt(*BAR[1])).Shape()
within = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, -10), gp.DZ_s()), REACH, 20).Shape()
near = BRepAlgoAPI_Common(bar, within)
ifnot near.IsDone():
raiseRefused("BRepAlgoAPI_Common declined the bar's part near the rod")
tool = screw(near.Shape(), LEAD, START)
# Of the faces left, the cylinder of radius 6 is carried along itself; the flat ones are# cut along their contact: the tip along its middle, through the axis, the sides square to# it nowhere; the level faces rise or sink all over.# Swept 270° at a time: a span overlaps itself only once it comes round to within the# bar's own width of where it began, past 360° − 2 acos(4.5/5.01) ≈ 308°.# Every circle about the axis meets the bar, cut down to within REACH of it, in one arc, so# no point is entered twice in a pass, and the leading faces of each span are swept whole.
pieces = screwed(tool, LEAD, START, STOP, flat_contacts_screwed(tool, LEAD), span=270,
whole=True)
rod = BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape()
returncut(rod, pieces)
arris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
12.6 s; CPU time 23.4 s; peak memory 137.2 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1276.702999
1276.702999
6.2e-11
area
916.120396
916.1203965
5.1e-10
agrees with
cad-kernel, next.BREP, cadrs, springrep
mesh
700716 triangles, closed
centre of gravity
(5.67511e-14, -3.1381e-14, 10) its STEP's solid
inertia
about it, of unit density: Ixx 49043.5; Iyy 49043.5; Izz 12973.5; Ixy -5.6593e-11; Iyz -3.15428; Izx -2.00667e-11
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, threaded by a bar//! carried along a fine screw: the box 4.5 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 0.45, screwed about the z axis,//! right-handed, rising 1 a turn, from a turn of −180° to +7380°. Everything the bar passes//! through, cut.//!//! The bar's sweep is kentron's sweep of a solid (`sweep::solid`, one screw), cut from the rod.usecrate::bench::p;
use kentron::math::Axis;
use kentron::primitives::{Cuboid, Cylinder};
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let rod = Cylinder::new(5.0, 20.0).build(m)?;
let bar = Cuboid::from_corners(p(4.5, -8.0, -0.45), p(12.0, 8.0, 0.45)).build(m)?;
let screw = RigidMotion::Screw { axis: Axis::Z, lead: 1.0, from: (-180f64).to_radians(), to: 7380f64.to_radians() };
let swept = sweep::solid(m, bar, &screw)?;
kentron::boolean::difference(m, rod, swept)
}
vcad left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
solidcraft left no solid to show.
Time
79.0 s; CPU time 79.0 s; peak memory 129 MB
Notes
refused the operation failed: SMLib boolean: operation: solidcore: SmApiBoolean: topology::proto_topology::p3::split_intersecting_proto_edges: two proto edges overlap along less than their definitions can split
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, threaded by the bar//! 4.5 ≤ x ≤ 12, −8 ≤ y ≤ 8, −0.45 ≤ z ≤ 0.45 carried along the screw about the z axis that//! rises 1 a turn, from a turn of −180° to one of 7380°, so fine that the groove's turns meet.//!//! solidcraft-kernel has no sweep of a solid, so the bar's sweep is built as//! `square-bar-screwed-through-rod`'s is: the bar at its ends, below and above the rod, with the//! screw sweeps of its section by y = 0, its faces z = ±0.45 and its back, 12 from the axis. Each//! of the three sweeps clears itself from turn to turn (the section is 0.9 of the lead); where//! the groove's turns meet, their sweeps overlap.usesuper::square_bar_screwed_through_rod::bar_cut;
usecrate::solids::*;
pubfnbuild() -> R<Body> {
let rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
bar_cut(rod, (4.5, -8.0, -0.45), (12.0, 8.0, 0.45), 1.0, -180.0, 7380.0)
}
brepkit left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
popkern left no solid to show.
Time
4 ms; CPU time 3.7 ms; peak memory 11.4 MB
Notes
refused popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly
// A thread so fine its crests are sharp.//// Refused: popkern has no sweep of a solid (its sweeps carry a profile along a path), and the// envelope this motion leaves is not one its extrudes, revolves and booleans make exactly: the// tool is not symmetric about the planes of its motion, or the motion is a screw or a curve.throw"popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly";
aetheris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
294 ms; CPU time 294 ms; peak memory 27.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1276.702999
1276.702999
4.4e-10
area
916.1203964
916.1203965
9.3e-11
agrees with
cad-kernel, kentron, cadrs, springrep
centre of gravity
(-1.84575e-15, -2.23916e-15, 10) its STEP's solid
inertia
about it, of unit density: Ixx 49043.5; Iyy 49043.5; Izz 12973.5; Ixy 1.17197e-12; Iyz -3.15428; Izx -1.03264e-11
STEP
B-rep advanced faces, each on a surface AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF
//! A rod threaded by a bar carried along a screw so fine that the groove's turns meet.//!//! Through the kernel's sweep of a solid (`sweep_solid_within`), asked for the bar as a prism (its//! rectangle 4.5 ≤ x ≤ 12, |y| ≤ 8 from z = −0.45 to 0.45) along the screw about the z axis that//! rises 1 a turn, from −180° to +7380°, within 5.2 of the z axis from z = −0.02 to 20.02 (which//! holds the rod and which neither end position reaches); cut from the rod. Where the kernel builds the//! rod less the sweep directly (`sweep_clip_less`, the rod as clip), that body instead. The kernel's sweep//! carries a solid of revolution along a screw and a prism only along a planar motion, so it may//! refuse.usecrate::solids::p;
usecrate::Refusal;
#[allow(unused_imports)]use brep_kernel::{
boolean_operation_nary, make_box_brep, make_cylinder_brep, revolve_profile_brep,
sweep_clip_less, sweep_solid_within, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SweepClip, SweptTool, Vec3,
};
#[allow(unused_imports)]use std::f64::consts::{FRAC_PI_2, PI, TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), p(0.0, 0.0, 1.0), 5.0, 20.0)?;
letmut operands = vec![rod];
let tool0 = SweptTool::Prism {
origin: p(0.0, 0.0, 0.0),
normal: p(0.0, 0.0, 1.0),
x_axis: p(1.0, 0.0, 0.0),
outline: vec![
OutlinePiece::Line { from: [4.5, -8.0], to: [12.0, -8.0] },
OutlinePiece::Line { from: [12.0, -8.0], to: [12.0, 8.0] },
OutlinePiece::Line { from: [12.0, 8.0], to: [4.5, 8.0] },
OutlinePiece::Line { from: [4.5, 8.0], to: [4.5, -8.0] },
],
from: -0.45,
to: 0.45,
};
let motion0 = SolidMotion {
steps: vec![
ScrewStep { axis_origin: p(0.0, 0.0, 0.0), axis_direction: p(0.0, 0.0, 1.0), turn: 1.0, advance: 1.0 / TAU },
],
from: (-180f64).to_radians(),
to: 7380f64.to_radians(),
};
let clip0 = SweepClip {
axis_origin: p(0.0, 0.0, 0.0),
axis_direction: p(0.0, 0.0, 1.0),
reference: p(1.0, 0.0, 0.0),
radius: [0.0, 5.2],
axial: [-0.02, 20.02],
angle: None,
};
// The rod less the sweep directly where the kernel builds it (the rod as clip); else subtract.let rod_clip = SweepClip { radius: [0.0, 5.0], axial: [0.0, 20.0], ..clip0.clone() };
ifletSome(mut bodies) = sweep_clip_less(&tool0, &motion0, &rod_clip)? {
if bodies.len() == 1 {
returnOk(bodies.remove(0));
}
}
operands.extend(sweep_solid_within(&tool0, &motion0, &clip0)?);
Ok(boolean_operation_nary(&operands, BooleanOperation::Subtract)?)
}
geop left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
371 ms; CPU time 869 ms; peak memory 29 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1276.703
1276.702999
7.7e-10
area
916.1203961
916.1203965
4.3e-10
agrees with
cad-kernel, kentron, next.BREP, springrep
mesh
567312 triangles, closed
centre of gravity
(-1.28187e-09, -1.02377e-14, 10) its STEP's solid
inertia
about it, of unit density: Ixx 49043.5; Iyy 49043.5; Izz 12973.5; Ixy 1.26177e-07; Iyz -3.15428; Izx 1.46743e-09
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) threaded by a bar (the//! box 4.5 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 0.45) screwed about the z axis, rising 1 a turn, from a turn of//! −180° to 7380°: the groove's turns meet in sharp crests.//!//! cadrs's cut by a swept solid: the screw (a turn and a slide along its axis at once) in pieces of//! half a turn, each swept exactly and cut from the rod in turn (a whole turn's sweep would overlap//! itself, the groove being wider than the lead out past the crests); of the bar, its part within//! 5.5 of the axis (the screw maps the cylinder about its axis onto itself, so only that part//! reaches the rod).usecrate::bench::{block, p3};
usecrate::shared::swept::{cut_swept, near_axis, rod, screw, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let bar = block(k, p3(4.5, -8.0, -0.45), p3(12.0, 8.0, 0.45))?;
let bar = near_axis(k, bar, 5.5)?;
let r = rod(k)?;
cut_swept(k, r, bar, &screw(z_axis(), 1.0, -180.0, 7380.0))
}
smlib left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
5.37 s; CPU time 5.37 s; peak memory 77.5 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a whole tool: the tool is cut to the rod's reach before the sweep
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1276.702999
1276.702999
1.8e-13
area
916.1203964
916.1203965
4.3e-11
agrees with
cad-kernel, kentron, next.BREP, cadrs
centre of gravity
(3.36304e-13, 1.51056e-16, 10) its STEP's solid
inertia
about it, of unit density: Ixx 49043.5; Iyy 49043.5; Izz 12973.5; Ixy -2.62819e-13; Iyz -3.15428; Izx -1.15697e-09
STEP
B-rep advanced faces, each on a surface AUTOMOTIVE_DESIGN
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything the bar//! 4.5 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 0.45 passes through as it is screwed about the z axis, rising 1 a//! turn, from a turn of −180° to one of 7380°: a thread whose crests are sharp.use springrep::boolean::difference;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, rod, screwing, within};
pubfnbuild() -> Result<Brep, String> {
let bar = boxed([4.5, -8.0, -0.45], [12.0, 8.0, 0.45], "bar")?;
// No sweep of the whole tool: a screw keeps each point's distance from the z axis, so only the// tool within 5.5 of it reaches the rod, and only that part is swept.let tip = within(&bar, 5.5)?;
let swept = solid(&tip, &screwing(1.0, deg(-180.0), deg(7380.0)), "screw").map_err(e)?;
difference(&rod()?, &swept).map_err(e)
}
// A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20; a bar, the box// 4.5 <= x <= 12, |y| <= 8, |z| <= 0.45, carried by a screw about the z axis that turns// right-handed (from +x toward +y) and rises 1 a turn, from a turn of -180 degrees to one of 7380,// and everything it passes through cut from the rod: a thread so fine its crests are sharp.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (screws)
in std.top {
centreline := point
fix((0, 0)) centreline
skin := circle(center: centreline) hint(r: 5)
radius(5) skin
}
part := solid(std.solids.Prism(face(skin), from: 0mm, to: 20mm))
in std.top {
e := point
f := point hint((12, -8))
g := point hint((12, 8))
h := point hint((4.5, 8))
footprint := horizontal line(e, f) -> vertical line(f, g) ->
horizontal line(g, h) -> vertical line(h, e) -> close
fix((4.5, -8)) e
e distance(7.5) f
f distance(16) g
}
bar := solid(std.solids.Prism(footprint, from: -0.45mm, to: 0.45mm))
climb := frame
climb screws(1mm) std.z
thread := solid({ p | some t in (-180deg, 7380deg): p in bar at(under: climb) t })
thread cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1000 µs; peak memory 3.4 MB
Notes
refused anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps
//! A thread so fine its crests are sharp.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps".into())
}