A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut partway up it by a bar carried along a screw, stopping inside the rod as a lathe's thread stops short of a shoulder.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its flat tip (the face x = 4) 1 inside the rod, and it is 2 wide along the axis.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 6 for every whole turn, rigidly. It runs from a turn of −120° (the bar lowered 2, wholly below the rod) to a turn of +600° (raised 10), where it stops with its middle halfway up the rod. Cut from the rod everything the bar passes through.
The groove is square-bar-screwed-through-rod's up to where the bar stops, and ends there in the bar's own faces.
expected
closed form
volume
1431.585742
no closed form: cad-kernel, OCCT and cadrs agree to 3e-11; the mean of their values
area
806.9351761
no closed form: cad-kernel, OCCT and cadrs agree to 4e-11; the mean of their values
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
4.99 s; CPU time 17.2 s; peak memory 54.6 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.
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, threaded partway up by the bar//! 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1 screwed about z — right-handed, rising 6 a turn — from a turn//! of −120° to +600°, where it stops inside the rod.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 = 6.;
constROLL: [f64; 2] = [-120f64.to_radians(), 600f64.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., -8., -1.], [12., 8., 1.])?;
// 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, and its faces where it stops// (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
1.23 s; CPU time 1.23 s; peak memory 384.9 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.
"""A thread stopped short: a bar screwed partway up a rod. A rod, the cylinder of radius 5 about
the z axis from z = 0 to z = 20, with a thread cut partway up it by a bar carried along a screw,
stopping inside the rod as a lathe's thread stops short of a shoulder.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its
flat tip (the face x = 4) 1 inside the rod, and it is 2 wide along the axis.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 6
for every whole turn, rigidly. It runs from a turn of −120° (the bar lowered 2, wholly below the
rod) to a turn of +600° (raised 10), where it stops with its middle halfway up the rod. Cut from
the rod everything the bar passes through.
The groove is `square-bar-screwed-through-rod`'s up to where the bar stops, and ends there in the
bar's own faces."""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, -8, -1), (12, 8, 1))
LEAD = 6# rise per whole turnSTART, STOP = -120, 600# 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 = 6defbuild():
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.# 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), 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
2.05 s; CPU time 3.72 s; peak memory 52.3 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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut//! partway up it by a bar, the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1, carried along a screw about//! the z axis rising 6 a turn, from a turn of −120° (wholly below the rod) to 600°, where it stops//! inside the rod. 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.0, -8.0, -1.0), p(12.0, 8.0, 1.0)).build(m)?;
let screw = RigidMotion::Screw { axis: Axis::Z, lead: 6.0, from: (-120f64).to_radians(), to: 600f64.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.
Time
14.5 s; CPU time 14.5 s; peak memory 66.7 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
1431.585608
1431.585742
9.4e-08
area
806.9353592
806.9351761
2.3e-07
agrees with
no other kernel
mesh
25294 triangles, closed
centre of gravity
(0.0384632, -0.0344869, 10.4694) its STEP's solid
inertia
about it, of unit density: Ixx 55929; Iyy 55890; Izz 16741; Ixy 52.9158; Iyz -450.81; Izx -36.1906
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut//! partway up it by the bar 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1 carried along the screw about the//! z axis that rises 6 a turn, from a turn of −120° to one of 600°, where it stops inside the rod.//!//! 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 where it starts and where it ends, with the//! screw sweeps of its section by y = 0, its faces z = ±1 and its back, 12 from the axis. It//! starts wholly below the rod, but ends inside it, so the bar where it stops is cut as well.usesuper::square_bar_screwed_through_rod::{bar_cut, screwed};
usecrate::solids::*;
pubfnbuild() -> R<Body> {
let rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
let grooved = bar_cut(rod, (4.0, -8.0, -1.0), (12.0, 8.0, 1.0), 6.0, -120.0, 600.0)?;
// the bar where it stops: its face z = 1 carried to the turn of 600°, extruded down by 2let top = Plane { origin: v3(0.0, 0.0, 1.0), x: Vec3::X, y: Vec3::Y };
let stop = extrude(&screwed(&top, 6.0, 600.0), rect(4.0, -8.0, 12.0, 8.0), -2.0, 0.0)?;
cut(&grooved, &stop)
}
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
3.6 ms; CPU time 3.4 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 stopped short: a bar screwed partway up a rod.//// 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
198 ms; CPU time 198 ms; peak memory 60.8 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.
//! A rod threaded partway up by a bar carried along a screw that stops inside it.//!//! Through the kernel's sweep of a solid within a region (`sweep_solid_clipped`): the bar, the box//! 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1, as a convex polyhedron, along the screw about the z axis that rises//! 6 a turn, from −120° to +600°, asked for within 5.2 of the z axis from z = −0.4 to 20.4, which//! holds the rod (the screw maps that cylinder onto itself, so the kernel may sweep only the bar's//! part that reaches it); cut from the rod.usecrate::solids::p;
usecrate::Refusal;
#[allow(unused_imports)]use brep_kernel::{
boolean_operation_nary, make_box_brep, make_cylinder_brep, revolve_profile_brep,
sweep_solid_clipped, sweep_solid_within, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SolidTool, 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 = SolidTool::Polyhedron {
vertices: (0..8)
.map(|i| p(if i & 1 != 0 { 12.0 } else { 4.0 }, if i & 2 != 0 { 8.0 } else { -8.0 }, if i & 4 != 0 { 1.0 } else { -1.0 }))
.collect(),
faces: vec![vec![0, 2, 3, 1], vec![4, 5, 7, 6], vec![0, 1, 5, 4], vec![2, 6, 7, 3], vec![0, 4, 6, 2], vec![1, 3, 7, 5]],
};
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: 6.0 / TAU },
],
from: (-120.0f64).to_radians(),
to: 600.0f64.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.4, 20.4],
angle: None,
};
operands.push(sweep_solid_clipped(&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
90 ms; CPU time 193 ms; peak memory 14.3 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.
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) with a thread cut partway//! up it by a bar (the box 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1) screwed about the z axis, rising 6 a turn,//! from a turn of −120° to +600°.//!//! What the bar passes through is cadrs's sweep of a solid (a turn and a slide along its axis at//! once: a screw), cut from the rod; 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, cut, p3};
usecrate::shared::swept::{near_axis, rod, screwed, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let bar = block(k, p3(4.0, -8.0, -1.0), p3(12.0, 8.0, 1.0))?;
let bar = near_axis(k, bar, 5.5)?;
let swept = screwed(k, bar, z_axis(), 6.0, -120.0, 600.0)?;
let r = rod(k)?;
cut(k, r, swept)
}
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
1.40 s; CPU time 1.40 s; peak memory 15.1 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.
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything the bar//! 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1 passes through as it is screwed about the z axis, rising 6 a turn,//! from a turn of −120° to one of 600°, where it stops inside the rod.use springrep::boolean::difference;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, rod, screwing};
pubfnbuild() -> Result<Brep, String> {
let bar = boxed([4.0, -8.0, -1.0], [12.0, 8.0, 1.0], "bar")?;
let swept = solid(&bar, &screwing(6.0, deg(-120.0), deg(600.0)), "screw").map_err(e)?;
difference(&rod()?, &swept).map_err(e)
}
Time
2.84 s; CPU time 7.88 s; peak memory 114.4 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.
// A rod threaded partway up by a square bar carried along a screw, stopping inside it. The rod is// the cylinder of radius 5 about the z axis from z = 0 to 20. The bar is the box 4 <= x <= 12,// -8 <= y <= 8, -1 <= z <= 1: its section drawn in the front plane (x, z), dimensioned from the// rod's axis, and the prism over it 8 either side. The screw is about z, right-handed, rising 6 a// turn; the kernel's sweep of the bar from a turn of -120 to 600 degrees, where its middle stands// halfway up the rod, is cut from the rod.unit mm
use std
use std.solids (cut)
use std.place (coords, above)
use std.motion (screws)
in std.top {
private o := point
fix((0, 0)) o
private rim := circle(center: o) hint(r: 5)
radius(5mm) rim
}
part := solid(std.solids.Prism(face(rim), from: 0mm, to: 20mm))
in std.front {
// the rod's axis, up from its foot at the originconstruction centerline ax := line(std.origin)
ax.p2 above(d: 20mm) std.origin
// the bar's section, from the axis: 4 to 12 out along x, 1 either side of z = 0private b0 := point
private b1 := point
private b2 := point
private b3 := point
b0 coords(du: 4mm, dv: -1mm) std.front
b1 coords(du: 12mm, dv: -1mm) std.front
b2 coords(du: 12mm, dv: 1mm) std.front
b3 coords(du: 4mm, dv: 1mm) std.front
private lower := line(b0, b1)
private end := line(b1, b2)
private upper := line(b2, b3)
private nose := line(b3, b0)
}
construction bar := solid(std.solids.Prism(face(lower, end, upper, nose), from: -8mm, to: 8mm))
// the screw about the rod's axis, carrying the bar from below the rod to halfway up it
feed := frame
feed screws(6mm) ax
construction thread := solid({ p | some t in (-120deg, 600deg): p in bar at(under: feed) t })
thread cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1 ms; peak memory 3.5 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 stopped short: a bar screwed partway up a rod.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())
}