A plate, the box from (0, −5, 0) to (20, 5, 4), with a pocket cut into its underside by a drum pushed up aslant into it, stopping inside.
The drum is a solid cylinder of radius 2 lying on its side: its axis is the line y = 0, z = −5, and it runs from x = 6 to x = 14, its ends flat.
It slides without turning by 8 along the direction (0.3, 0, √(1 − 0.3²)), leaning 0.3 toward +x from straight up, so that its axis ends at height −5 + 8√0.91 ≈ 2.63, inside the plate. Cut from the plate everything the drum passes through.
Pushed aslant, the drum's flat ends lean to the push: each rim sweeps an oblique elliptic cylinder, the side's lines at y = ±2 sweep the planes tangent along them, and the pocket ends in the drum's own side where it stops.
expected
closed form
volume
665.412934
no closed form: next.BREP and cad-kernel agree to 3e-11; the mean of their values
area
680.6777202
no closed form: next.BREP and cad-kernel agree to 4e-12; 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
331 ms; CPU time 501 ms; peak memory 17.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.
//! A plate, the box (0, −5, 0)–(20, 5, 4), with a pocket cut into its underside by a drum — the//! cylinder of radius 2 about the line y = 0, z = −5 from x = 6 to 14, its ends flat — slid without//! turning by 8 along (0.3, 0, √(1 − 0.3²)), stopping inside the plate.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;
constPLATE_LO: V = [0., -5., 0.];
constPLATE_HI: V = [20., 5., 4.];
/// The middle of the drum's near end, its radius and its length along x.constEND: V = [6., 0., -5.];
constRADIUS: f64 = 2.;
constLENGTH: f64 = 8.;
/// The push's lean toward +x from straight up (its direction's x), and its length.constLEAN: f64 = 0.3;
constPUSH: f64 = 8.;
/// How closely the drum is meshed for the sweep's membership reads: a thousandth of its radius.constBAR: f64 = 0.002;
pubfnbuild() -> Result<Brep, String> {
let plate = block(PLATE_LO, PLATE_HI)?;
let drum = prism(&disc(END, [1., 0., 0.], RADIUS), 0., LENGTH)?;
// the slide: a screw that does not turn, advancing its whole length over a roll of τlet along = [LEAN, 0., (1. - LEAN * LEAN).sqrt()];
let path = Trajectory::Twist(Screw { origin: END, axis: along, ratio: 0., advance: PUSH });
// the kernel's closed swept solid cut from the plate on one arrangement: the side's rulings// at y = ±2 swept into the planes tangent along them, each rim, leaning to the push, into an// oblique cylinder, the drum at its last pose ending the pocketlet size = plate.size().max(drum.size());
cut_from(&plate, &drum, &path, [0., TAU], BAR, tolerance(size))
.map_err(|why| format!("the drum's sweep not built: {why:?}"))
}
Time
762 ms; CPU time 761 ms; peak memory 372.1 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 drum plunged aslant into a plate, stopping inside. A plate, the box from (0, −5, 0) to (20, 5,
4), with a pocket cut into its underside by a drum pushed up aslant into it, stopping inside.
The drum is a solid cylinder of radius 2 lying on its side: its axis is the line y = 0, z = −5, and
it runs from x = 6 to x = 14, its ends flat.
It slides without turning by 8 along the direction (0.3, 0, √(1 − 0.3²)), leaning 0.3 toward +x
from straight up, so that its axis ends at height −5 + 8√0.91 ≈ 2.63, inside the plate. Cut from
the plate everything the drum passes through.
Pushed aslant, the drum's flat ends lean to the push: each rim sweeps an oblique elliptic cylinder,
the side's lines at y = ±2 sweep the planes tangent along them, and the pocket ends in the drum's
own side where it stops."""import math
fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Ax2, gp_Pnt
from sweep import cut, plane, slid
PLATE = ((0, -5, 0), (20, 5, 4))
DRUM_START = (6, 0, -5) # the middle of the drum's end at x = 6, on its axisDRUM_RADIUS, DRUM_LENGTH = 2, 8LEAN = 0.3# the push's x component, of a unit directionPUSH = 8defbuild():
drum = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(*DRUM_START), gp.DX_s()), DRUM_RADIUS,
DRUM_LENGTH).Shape()
push = (PUSH * LEAN, 0, PUSH * math.sqrt(1 - LEAN ** 2))
# The drum's side, at (x, 2 cos t, −5 + 2 sin t), has normal (0, cos t, sin t), square to the# push where sin t = 0: its two lines at y = ±2, where the plane z = −5 through its axis cuts# it. Its flat ends lean to the push and lead or trail all over.
swept = slid(drum, push, [plane(DRUM_START, (0, 0, 1))])
returncut(BRepPrimAPI_MakeBox(gp_Pnt(*PLATE[0]), gp_Pnt(*PLATE[1])).Shape(), swept)
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
21 ms; CPU time 21 ms; peak memory 14.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 plate, the box from (0, −5, 0) to (20, 5, 4), pocketed from below by a drum pushed up aslant//! into it: the solid cylinder of radius 2 about the line y = 0, z = −5, from x = 6 to 14, slid//! without turning by 8 along (0.3, 0, √0.91), stopping inside the plate. Everything the drum//! passes through, cut.//!//! The drum's sweep is kentron's sweep of a solid (`sweep::solid`, one slide), cut from the plate.usecrate::bench::{frame, p, v};
use kentron::math::Direction;
use kentron::primitives::{Cuboid, Cylinder};
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let plate = Cuboid::from_corners(p(0.0, -5.0, 0.0), p(20.0, 5.0, 4.0)).build(m)?;
let drum = Cylinder::new(2.0, 8.0).with_frame(frame(p(6.0, 0.0, -5.0), Direction::X)).build(m)?;
let swept = sweep::solid(m, drum, &RigidMotion::Slide { by: v(0.3, 0.0, 0.91f64.sqrt()) * 8.0 })?;
kentron::boolean::difference(m, plate, 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
790 ms; CPU time 790 ms; peak memory 55.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.
//! A plate, the box from (0, −5, 0) to (20, 5, 4), with a pocket cut into its underside by a drum,//! the solid cylinder of radius 2 about the line y = 0, z = −5 from x = 6 to x = 14, slid without//! turning by 8 along (0.3, 0, √0.91), stopping inside the plate.//!//! solidcraft-kernel has no sweep of a solid, so the drum's sweep is built by elementary geometry,//! from its halves either side of the plane z = −5 through its axis. A solid slid sweeps itself//! where it starts and its faces that lead the slide (outward normal along it) slid the whole//! way; or, as well, itself where it stops and its faces that trail the slide, slid. The lower//! half's curved side trails, so it sweeps itself and its leading faces, the rectangle on z = −5//! and its half end on x = 14; the upper half's curved side leads, so it sweeps itself where it//! stops and its trailing faces, the same rectangle and its half end on x = 6. All three faces are//! flat, and the kernel's `sweep` along a straight path translates each. The lower half where the//! drum starts lies below z = −5, clear of the plate; the rest is what the sweep takes from it.usecrate::solids::*;
use solidcore_record::Seg2;
use solidcraft_kernel::{PathSeg, sweep};
use std::f64::consts::PI;
/// The half of the disc of radius 2 about the origin from angle `start` (radians) round half a/// turn, closed by its diameter.fnhalf_disc(start: f64) -> Region2 {
let arc = Seg2::Arc { center: Vec2::ZERO, radius: 2.0, start, sweep: PI };
let diameter = Seg2::Line { a: arc.end(), b: arc.start() };
Region2 { outer: Loop2 { segs: vec![arc, diameter] }, holes: vec![] }
}
pubfnbuild() -> R<Body> {
let plate = block((0.0, -5.0, 0.0), (20.0, 5.0, 4.0))?;
let slide = v3(0.3, 0.0, 0.91f64.sqrt()) * 8.0;
// the upper half of the drum where it stopslet axis = v3(6.0, 0.0, -5.0) + slide;
let drum = solidcraft_kernel::cylinder(axis, Vec3::X, 2.0, 8.0)?;
let up = Plane::from_normal(axis, Vec3::Z).ok_or_else(|| KernelError::Invalid("up".into()))?;
letmut swept = solidcraft_kernel::half_space(&drum, &up, true)?
.0
.ok_or_else(|| KernelError::Failed("the half drum is empty".into()))?;
// the faces slid: the rectangle through the axis, the lower half end on x = 14 and the upper// half end on x = 6, each end drawn in (y, z) about the axislet end = |x: f64| Plane { origin: v3(x, 0.0, -5.0), x: Vec3::Y, y: Vec3::Z };
let faces = [
(Plane { origin: v3(6.0, -2.0, -5.0), x: Vec3::X, y: Vec3::Y }, rect(0.0, 0.0, 8.0, 4.0)),
(end(14.0), half_disc(PI)),
(end(6.0), half_disc(0.0)),
];
for (plane, face) in &faces {
let path = [PathSeg::Line { a: plane.origin, b: plane.origin + slide }];
swept = union(&swept, &sweep(plane, face, &path)?)?;
}
cut(&plate, &swept)
}
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
7.41 s; CPU time 8.67 s; peak memory 52.6 MB
Notes
refused FeatureFailed at drum_plunged_aslant_into_plate.rhai:38:19: feature 'boolean-6' (boolean) failed: result validation failed: cellular result invalid: Half-edge HalfEdgeHandle(60v1) in loop LoopHandle(9v1) ends at VertexHandle(18v1) but its successor HalfEdgeHandle(51v1) starts at VertexHandle(17v1)
// A plate from (0, -5, 0) to (20, 5, 4) less everything a drum (radius 2 about y = 0, z = -5,// x = 6 to 14) passes through as it slides by 8 along (0.3, 0, √0.91).//// The drum is its end disc slid 8 along x; what it sweeps is that disc slid along the// parallelogram P of x and the slide: P widened 2 either side in y, the drum where it starts and// stops (P's edges along x), and its two end discs slid along the slide, oblique cylinders (P's// edges along the slide), each a loft between two equal circles.fncross(a, b) { [a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]] }
fndot(a, b) { a[0] * b[0] + a[1] * b[1] + a[2] * b[2] }
// The zonotope centred at `c` with generators `g` (the sum of the segments from -g/2 to g/2): the// solid common to one slab for each pair of generators, square to both, as thick as the// generators reach across it. A box slid along a vector is one.fnzonotope(m, c, g) {
let body = ();
let first = true;
for i in0..g.len() { for j in (i + 1)..g.len() {
let n = cross(g[i], g[j]);
let l = sqrt(dot(n, n));
if l < 1e-9 { continue; }
n = [n[0] / l, n[1] / l, n[2] / l];
let reach = 0.0;
for k in g { reach += abs(dot(k, n)); }
let r = cross(n, ifabs(n[0]) < 0.9 { [1.0, 0.0, 0.0] } else { [0.0, 1.0, 0.0] });
let slab = m.box(500.0, 500.0, reach, #{ at: c, axis: n, ref: r, centred: true });
if first { body = slab; first = false; } else { body = body.intersect(m.tool(|m| slab)); }
} }
body
}
let m = model();
let s = sqrt(0.91);
let v = [2.4, 0.0, 8.0 * s];
let plate = m.box(20.0, 10.0, 4.0, #{ at: [0.0, -5.0, 0.0] });
plate = plate.subtract(m.tool(|m| zonotope(m, [10.0 + 1.2, 0.0, -5.0 + 4.0 * s], [[8.0, 0.0, 0.0], [0.0, 4.0, 0.0], v])));
for t in [0.0, 1.0] {
plate = plate.subtract(m.tool(|m| m.cylinder(2.0, 8.0, #{ at: [6.0 + t * v[0], 0.0, -5.0 + t * v[2]], axis: [1.0, 0.0, 0.0], ref: [0.0, 1.0, 0.0] })));
}
for x in [6.0, 14.0] {
plate = plate.subtract(m.tool(|m| {
let a = m.profile(yz_at(x)).circle(2.0).at(0.0, -5.0).sketch("end");
let b = m.profile(yz_at(x + v[0])).circle(2.0).at(0.0, -5.0 + v[2]).sketch("end_slid");
m.loft([a, b], #{ label: "end_swept" })
}));
}
m
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
29 ms; CPU time 22 ms; peak memory 18.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.
//! A plate pocketed from below by a drum lying on its side, pushed up aslant and stopping inside://! the plate from (0, −5, 0) to (20, 5, 4), less everything the drum (radius 2, its axis the line//! y = 0, z = −5 from x = 6 to x = 14, its ends flat) passes through as it slides without turning//! by v = 8·(0.3, 0, √(1 − 0.3²)).//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the drum, a solid of revolution//! about the line y = 0, z = −5 whose meridian is the rectangle out to radius 2 from x = 6 to x =//! 14, slid by v, and cut from the plate.usecrate::solids::p;
usecrate::solids::swept::{less_all, revolved_tool, slide_by, Piece};
usecrate::Refusal;
use brep_kernel::{make_box_brep, sweep_solid, BrepSolid};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let plate = make_box_brep(p(0.0, -5.0, 0.0), 20.0, 10.0, 4.0)?;
let drum = revolved_tool(p(6.0, 0.0, -5.0), p(1.0, 0.0, 0.0), p(0.0, 0.0, 1.0), &[
Piece::Line { from: [0.0, 0.0], to: [2.0, 0.0] },
Piece::Line { from: [2.0, 0.0], to: [2.0, 8.0] },
Piece::Line { from: [2.0, 8.0], to: [0.0, 8.0] },
Piece::Line { from: [0.0, 8.0], to: [0.0, 0.0] },
]);
let slide = slide_by(p(0.3, 0.0, (1.0 - 0.3f64 * 0.3).sqrt()).scale(8.0));
less_all(plate, vec![sweep_solid(&drum, &slide)?])
}
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
9.8 ms; CPU time 19 ms; peak memory 10.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 plate (the box from (0, −5, 0) to (20, 5, 4)) pocketed from below by a drum (radius 2 about the//! line y = 0, z = −5, from x = 6 to 14) pushed 8 along (0.3, 0, √0.91), stopping inside it.//!//! The drum is a circle extruded; what it passes through is cadrs's sweep of a solid (one slide),//! cut from the plate.usecrate::bench::{block, cut, cylinder, p3, v3};
usecrate::shared::swept::slid;
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let plate = block(k, p3(0.0, -5.0, 0.0), p3(20.0, 5.0, 4.0))?;
let drum = cylinder(k, p3(6.0, 0.0, -5.0), v3(1.0, 0.0, 0.0), 2.0, 8.0)?;
let lean = v3(0.3, 0.0, (1.0f64 - 0.09).sqrt());
let swept = slid(k, drum, lean * 8.0)?;
cut(k, plate, 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
33 ms; CPU time 32 ms; peak memory 9.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.
//! The plate (0, −5, 0)–(20, 5, 4) less everything a drum passes through as it slides by 8 along//! (0.3, 0, √0.91): the cylinder of radius 2 about the line y = 0, z = −5, from x = 6 to 14.use springrep::boolean::difference;
use springrep::primitive::cylinder;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::swept::{boxed, v3};
usecrate::shared::{e, frame};
pubfnbuild() -> Result<Brep, String> {
let plate = boxed([0.0, -5.0, 0.0], [20.0, 5.0, 4.0], "plate")?;
let axis = frame([6.0, 0.0, -5.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0])?;
let drum = cylinder(&axis, 2.0, 8.0, "drum").map_err(e)?;
let v = v3(0.3, 0.0, 0.91f64.sqrt()) * 8.0;
let pocket = solid(&drum, &Motion::Slide(v), "pocket").map_err(e)?;
difference(&plate, &pocket).map_err(e)
}
Time
373 ms; CPU time 459 ms; peak memory 33.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.
// A plate, the box from (0, -5, 0) to (20, 5, 4), its footprint in the top plane; a drum lying on// its side, the cylinder of radius 2 about the line y = 0, z = -5 from x = 6 to x = 14 (its end// circle drawn in the side plane, carried along x), slid without turning 8 along the direction// (0.3, 0, sqrt(1 - 0.3^2)), stopping inside the plate, and everything it passes through cut from// the plate.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (slides)
in std.top {
a := point
b := point hint((20, -5))
c := point hint((20, 5))
d := point hint((0, 5))
outline := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((0, -5)) a
a distance(20) b
b distance(10) c
}
part := solid(std.solids.Prism(outline, from: 0mm, to: 4mm))
in std.side {
o := point
fix((0, -5)) o
rim := circle(center: o) hint(r: 2)
radius(2) rim
}
drum := solid(std.solids.Prism(face(rim), from: 6mm, to: 14mm))
// the push, 8 up a line leaning 0.3 toward x over the roll
aslant := axis hint(dir: (0.3, 0, 0.95))
fix(dir == (0.3, 0, sqrt(1 - 0.3^2))) aslant
ram := frame
ram slides(8mm) aslant
pocket := solid({ p | some t in (0deg, 360deg): p in drum at(under: ram) t })
pocket cut part
anvilcad left no solid to show.
Time
1.1 ms; CPU time 940 µs; peak memory 3.5 MB
Notes
refused anvil-brep has no sweep of a solid, and what this motion sweeps is bounded by envelopes of the body's surfaces under it (a rim or a face leaning to the motion) that follow from no elementary construction, which it would have to compute itself
//! A drum plunged aslant into a plate, stopping inside.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid, and what this motion sweeps is bounded by envelopes of the body's surfaces under it (a rim or a face leaning to the motion) that follow from no elementary construction, which it would have to compute itself".into())
}