A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a sealed helical tunnel inside it: everything a small box passes through as it is carried along a screw wholly within the rod.
The box, as placed, is 2.5 ≤ x ≤ 3.5, −0.5 ≤ y ≤ 0.5, 2 ≤ z ≤ 3.
The screw is about the z axis: the box turns right-handed about it (from +x toward +y) and rises 4 for every whole turn, rigidly, from a turn of 0° to one of 720°, ending as the box 2.5 ≤ x ≤ 3.5, −0.5 ≤ y ≤ 0.5, 10 ≤ z ≤ 11. Cut from the rod everything the box passes through.
The box stays inside the rod all the way, so the result is the rod with a closed helical cavity two turns long, square in section and ended by the box's own faces: two shells. The box's level faces sweep helicoidal sheets and its upright faces cylinders and ruled sheets, meeting along its edges' helices.
expected
closed form
volume
1522.316219
no closed form: cad-kernel and OCCT agree to 4e-11; the mean of their values (cadrs is 1.2e-8 from it)
area
961.1374882
no closed form: cad-kernel and OCCT agree to 7e-11; the mean of their values (cadrs is 1.2e-8 from it)
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
6.95 s; CPU time 21.9 s; peak memory 446.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, with a sealed helical tunnel: what the//! box 2.5 ≤ x ≤ 3.5, −0.5 ≤ y ≤ 0.5, 2 ≤ z ≤ 3 passes through as it is screwed about z,//! right-handed and rising 4 a turn, from a turn of 0° to 720°, wholly inside the rod.usecrate::sketch::block;
use cad_kernel::build::{disc, prism};
use cad_kernel::geom::{tolerance, V};
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
use std::f64::consts::TAU;
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
constBOX_LO: V = [2.5, -0.5, 2.];
constBOX_HI: V = [3.5, 0.5, 3.];
/// How far the screw rises a whole turn, and how many turns it makes.constRISE: f64 = 4.;
constTURNS: f64 = 2.;
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0.; 3], up, ROD_RADIUS), 0., ROD_LENGTH)?;
let tool = block(BOX_LO, BOX_HI)?;
// the screw about z: a radian a radian of the roll, rising `RISE` a turnlet path = Trajectory::Twist(Screw { origin: [0.; 3], axis: up, ratio: 1., advance: RISE });
// the kernel's closed swept solid cut from the rod on one arrangement: the box's edges along// the axis and square to it, its level edges screwed into helicoidal sheets and its upright// faces' contact lines into coaxial cylinders (a box's flat faces mesh exactly, at any bar)let size = rod.size();
cut_from(&rod, &tool, &path, [0., TURNS * TAU], size, tolerance(size))
.map_err(|why| format!("the box's sweep not built: {why:?}"))
}
Time
11.4 s; CPU time 11.4 s; peak memory 422.5 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 sealed helical tunnel: a box screwed inside a rod. A rod, the cylinder of radius 5 about the z
axis from z = 0 to z = 20, with a sealed helical tunnel inside it: everything a small box passes
through as it is carried along a screw wholly within the rod.
The box, as placed, is 2.5 ≤ x ≤ 3.5, −0.5 ≤ y ≤ 0.5, 2 ≤ z ≤ 3.
The screw is about the z axis: the box turns right-handed about it (from +x toward +y) and rises 4
for every whole turn, rigidly, from a turn of 0° to one of 720°, ending as the box 2.5 ≤ x ≤ 3.5,
−0.5 ≤ y ≤ 0.5, 10 ≤ z ≤ 11. Cut from the rod everything the box passes through.
The box stays inside the rod all the way, so the result is the rod with a closed helical cavity two
turns long, square in section and ended by the box's own faces: two shells. The box's level faces
sweep helicoidal sheets and its upright faces cylinders and ruled sheets, meeting along its edges'
helices."""fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Pnt
from sweep import cut, flat_contacts_screwed, screwed
ROD_RADIUS, ROD_LENGTH = 5, 20BOX = ((2.5, -0.5, 2), (3.5, 0.5, 3))
LEAD = 4# rise per whole turnSTART, STOP = 0, 720# degreesdefbuild():
box = BRepPrimAPI_MakeBox(gp_Pnt(*BOX[0]), gp_Pnt(*BOX[1])).Shape()
# Each flat face is cut along its contact: the faces x = 2.5 and x = 3.5 along their middles,# y = 0, through the axis; the faces y = ±0.5 square to it nowhere on them; the level faces# rise or sink all over.
pieces = screwed(box, LEAD, START, STOP, flat_contacts_screwed(box, LEAD))
returncut(BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape(), 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
655 ms; CPU time 1.08 s; peak memory 38.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 the z axis from z = 0 to z = 20, with a sealed helical//! tunnel inside it: everything the box 2.5 ≤ x ≤ 3.5, |y| ≤ 0.5, 2 ≤ z ≤ 3 passes through as it is//! carried along the screw about the z axis, right-handed, rising 4 a turn, from a turn of 0° to//! 720°, cut.//!//! The box'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};
use std::f64::consts::TAU;
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let rod = Cylinder::new(5.0, 20.0).build(m)?;
let block = Cuboid::from_corners(p(2.5, -0.5, 2.0), p(3.5, 0.5, 3.0)).build(m)?;
let screw = RigidMotion::Screw { axis: Axis::Z, lead: 4.0, from: 0.0, to: 2.0 * TAU };
let swept = sweep::solid(m, block, &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
7.01 s; CPU time 7.01 s; peak memory 77.6 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, with a sealed helical//! tunnel: what the box 2.5 ≤ x ≤ 3.5, −0.5 ≤ y ≤ 0.5, 2 ≤ z ≤ 3 passes through as the screw about//! the z axis that rises 4 a turn carries it from a turn of 0° to one of 720°.//!//! solidcraft-kernel has no sweep of a solid, so the box's sweep is built by elementary geometry//! from the kernel's helical sweep of planar regions (`sweep_helix`). On each cylinder about the//! axis the screw slides the cylinder along itself, and unrolled, the box's trace there is one//! rectangle or two, each from z = 2 to z = 3 between two angles. A rectangle slid along a line//! passes over itself at each end and over what is swept by any path across it from its top edge//! down to its bottom edge, joined to both edges. Here those are the box's faces z = 2 and z = 3,//! and its sections by half-planes through the axis: the one at angle 0 crosses the box's trace//! out to radius 3.5, and those through the box's outer upright edges, at ±atan(0.5/3.5), cross//! each of the two rectangles beyond it. Every one of them crosses the screw's motion, never//! moving along itself, so its screw sweep is what it passes through. With the box where it//! starts and where it ends, these are the tunnel.usesuper::square_bar_screwed_through_rod::{screw, screwed};
usecrate::solids::*;
pubfnbuild() -> R<Body> {
rod(1.0)
}
/// The rod and its tunnel with every length `s` times as long.pubfnrod(s: f64) -> R<Body> {
placed_rod(s, &|piece| Ok(piece))
}
/// The rod and its tunnel with every length `s` times as long, each piece (the rod, the box at/// either end, each sweep) moved by `place` as it is made, before the cuts.pubfnplaced_rod(s: f64, place: &dynFn(Body) -> R<Body>) -> R<Body> {
let (lead, start, stop) = (4.0 * s, 0.0, 720.0);
letmut tunnel = vec![
place(block((2.5 * s, -0.5 * s, 2.0 * s), (3.5 * s, 0.5 * s, 3.0 * s))?)?,
place(block((2.5 * s, -0.5 * s, 10.0 * s), (3.5 * s, 0.5 * s, 11.0 * s))?)?,
];
for z in [2.0 * s, 3.0 * s] {
let level = Plane { origin: v3(0.0, 0.0, z), x: Vec3::X, y: Vec3::Y };
tunnel.push(place(screw(&level, &rect(2.5 * s, -0.5 * s, 3.5 * s, 0.5 * s), lead, start, stop)?)?);
}
tunnel.push(place(screw(&xz(), &rect(2.5 * s, 2.0 * s, 3.5 * s, 3.0 * s), lead, start, stop)?)?);
// the half-planes through the corner edges (3.5, ±0.5), from the face x = 2.5 to the cornerlet corner = ((3.5 * s) * (3.5 * s) + (0.5 * s) * (0.5 * s)).sqrt();
let angle = (0.5f64 / 3.5).atan().to_degrees();
for side in [-1.0, 1.0] {
let half = screwed(&xz(), 0.0, side * angle);
let inner = 2.5 * s * corner / (3.5 * s);
tunnel.push(place(screw(&half, &rect(inner, 2.0 * s, corner, 3.0 * s), lead, start, stop)?)?);
}
letmut rod = place(zcyl(0.0, 0.0, 5.0 * s, 0.0, 20.0 * s)?)?;
for piece in &tunnel {
rod = cut(&rod, piece)?;
}
Ok(rod)
}
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.2 ms; CPU time 3 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 sealed helical tunnel: a box screwed inside 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
5.41 s; CPU time 5.41 s; peak memory 134.7 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 with a sealed helical tunnel: everything a small box passes through along a screw inside//! it.//!//! Through the kernel's sweep of a solid in parts (`sweep_solid_parts`): the box 2.5 ≤ x ≤ 3.5,//! |y| ≤ 0.5, 2 ≤ z ≤ 3 as a convex polyhedron, along the screw about the z axis that rises 4 a//! turn, from 0° to 720°. Its outer face grazes along a line inside it, past which the sweep would//! fold over itself, so the kernel sweeps the box's halves either side of the plane through the//! axis and that line; the rod is cut by both.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_parts, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SolidTool, 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 { 3.5 } else { 2.5 }, if i & 2 != 0 { 0.5 } else { -0.5 }, if i & 4 != 0 { 3.0 } else { 2.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: 4.0 / TAU },
],
from: 0.0,
to: (4.0 * PI),
};
operands.extend(sweep_solid_parts(&tool0, &motion0)?);
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
2.10 s; CPU time 5.20 s; peak memory 81.5 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 sealed helical//! tunnel: what a box (2.5 ≤ x ≤ 3.5, |y| ≤ 0.5, 2 ≤ z ≤ 3) passes through screwed about the z//! axis, rising 4 a turn, from a turn of 0° to 720°.//!//! cadrs's sweep of a solid (a turn and a slide along its axis at once: a screw), cut from the rod.usecrate::bench::{block, cut, p3};
usecrate::shared::swept::{rod, screwed, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let tool = block(k, p3(2.5, -0.5, 2.0), p3(3.5, 0.5, 3.0))?;
let swept = screwed(k, tool, z_axis(), 4.0, 0.0, 720.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.67 s; CPU time 1.67 s; peak memory 14.5 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 box//! 2.5 ≤ x ≤ 3.5, |y| ≤ 0.5, 2 ≤ z ≤ 3 passes through as it is screwed about the z axis, rising 4//! a turn, from a turn of 0° to one of 720°: a sealed helical tunnel.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([2.5, -0.5, 2.0], [3.5, 0.5, 3.0], "bar")?;
let swept = solid(&bar, &screwing(4.0, 0.0, deg(720.0)), "screw").map_err(e)?;
difference(&rod()?, &swept).map_err(e)
}
Time
5.99 s; CPU time 18.4 s; peak memory 493.7 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; a small box,// 2.5 <= x <= 3.5, |y| <= 0.5, 2 <= z <= 3, carried by a screw about the z axis that turns// right-handed (from +x toward +y) and rises 4 a turn, for two whole turns wholly inside the rod,// and everything it passes through cut from the rod: a sealed helical tunnel.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((3.5, -0.5))
g := point hint((3.5, 0.5))
h := point hint((2.5, 0.5))
footprint := horizontal line(e, f) -> vertical line(f, g) ->
horizontal line(g, h) -> vertical line(h, e) -> close
fix((2.5, -0.5)) e
e distance(1) f
f distance(1) g
}
box := solid(std.solids.Prism(footprint, from: 2mm, to: 3mm))
climb := frame
climb screws(4mm) std.z
tunnel := solid({ p | some t in (0deg, 720deg): p in box at(under: climb) t })
tunnel cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1 ms; 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 sealed helical tunnel: a box screwed inside 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())
}