A plate, the box from (0, −5, 0) to (20, 5, 4), with a pocket cut into its underside by a bar pushed up aslant into it, stopping halfway through.
The bar is a prism of square section stood on a corner: everything with 6 ≤ x ≤ 14 and |y| + |z + 6| ≤ 1. Its section's corners are (y, z) = (0, −7), (1, −6), (0, −5) and (−1, −6).
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 it ends with its top edge at z = −5 + 8√0.91 ≈ 2.63, inside the plate. Cut from the plate everything the bar passes through.
The bar is convex, so what it passes through is the convex hull of the bar where it starts and the bar where it stops; the pocket is the part of that within the plate.
expected
closed form
volume
764.8696076
800 less the part within the plate of the convex hull of the bar where it starts and where it stops (a convex polyhedron, its measures exact: 35.130392369170131)
area
681.2450487
640 + that polyhedron's surface within the plate (74.502990500237274) − twice its face on z = 0 (16.628970902033146); every face a plane
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
157 ms; CPU time 328 ms; peak memory 37 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 bar — every//! point with 6 ≤ x ≤ 14 and |y| + |z + 6| ≤ 1, a square section stood on a corner — slid without//! turning by 8 along (0.3, 0, √(1 − 0.3²)), stopping inside the plate.usecrate::sketch::{block, polygon};
use cad_kernel::build::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 bar's section's corners (y, z) in the plane x = 6, and its length along x.constSECTION: [[f64; 2]; 4] = [[0., -7.], [1., -6.], [0., -5.], [-1., -6.]];
constSTART: f64 = 6.;
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.;
pubfnbuild() -> Result<Brep, String> {
let plate = block(PLATE_LO, PLATE_HI)?;
// the section walked counter-clockwise in (y, z), so that its normal is +x, swept 8 along itlet section = polygon(&SECTION.map(|[y, z]| [START, y, z]));
let bar = prism(§ion, 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: [0.; 3], axis: along, ratio: 0., advance: PUSH });
// the kernel's closed swept solid cut from the plate on one arrangement (a bar's flat faces// mesh exactly, at any bar)let size = plate.size().max(bar.size());
cut_from(&plate, &bar, &path, [0., TAU], size, tolerance(size))
.map_err(|why| format!("the bar's sweep not built: {why:?}"))
}
Time
645 ms; CPU time 644 ms; peak memory 368.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 bar 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 bar pushed up aslant into it, stopping halfway
through.
The bar is a prism of square section stood on a corner: everything with 6 ≤ x ≤ 14 and |y| + |z +
6| ≤ 1. Its section's corners are (y, z) = (0, −7), (1, −6), (0, −5) and (−1, −6).
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 it ends with its top edge at z = −5 + 8√0.91 ≈ 2.63, inside the plate.
Cut from the plate everything the bar passes through.
The bar is convex, so what it passes through is the convex hull of the bar where it starts and the
bar where it stops; the pocket is the part of that within the plate."""import math
fromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeFace, BRepBuilderAPI_MakePolygonfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakePrismfromOCP.gp import gp_Pnt, gp_Vec
from sweep import cut, slid
PLATE = ((0, -5, 0), (20, 5, 4))
BAR_START, BAR_LENGTH = 6, 8# along xSECTION = [(0, -7), (1, -6), (0, -5), (-1, -6)] # the square's corners, in (y, z)LEAN = 0.3# the push's x component, of a unit directionPUSH = 8defbuild():
corners = [gp_Pnt(BAR_START, y, z) for y, z inSECTION]
section = BRepBuilderAPI_MakeFace(BRepBuilderAPI_MakePolygon(*corners, True).Wire()).Face()
bar = BRepPrimAPI_MakePrism(section, gp_Vec(BAR_LENGTH, 0, 0)).Shape()
push = (PUSH * LEAN, 0, PUSH * math.sqrt(1 - LEAN ** 2))
# Every face of the bar is flat and none is parallel to the push, so each leads all over or# trails all over: none needs splitting.
swept = slid(bar, push)
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
8.2 ms; CPU time 7.9 ms; peak memory 10 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 bar pushed up aslant//! into it: the prism 6 ≤ x ≤ 14, |y| + |z + 6| ≤ 1 (a square stood on a corner), slid without//! turning by 8 along (0.3, 0, √0.91), stopping inside the plate. Everything the bar passes//! through, cut.//!//! The bar's sweep is kentron's sweep of a solid (`sweep::solid`, one slide), cut from the plate.usecrate::bench::{d, p, v};
use kentron::math::{Direction, Frame};
use kentron::primitives::Cuboid;
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)?;
// The bar: a √2 square along x from its lowest edge (y, z) = (0, −7), its sides along// (0, 1, 1) and (0, −1, 1).let bar = Cuboid::new(2f64.sqrt(), 2f64.sqrt(), 8.0).with_frame(Frame::new(p(6.0, 0.0, -7.0), Direction::X, d(0.0, 1.0, 1.0))).build(m)?;
let swept = sweep::solid(m, bar, &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
1.43 s; CPU time 1.43 s; peak memory 52.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.
//! A plate, the box from (0, −5, 0) to (20, 5, 4), with a pocket cut into its underside by a bar//! of square section stood on a corner (6 ≤ x ≤ 14 and |y| + |z + 6| ≤ 1) 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 slide is built, as in `box-slid-aslant`, from//! the bar and its faces by elementary geometry. A point the bar passes over that is outside the//! bar where it starts is reached first by a face it leads with, one whose outward normal points//! along the slide: its end x = 14 and the two faces of its section above its middle line, facing//! (0, ±1, 1). So the solid is the bar where it starts and those three faces each slid the whole//! way, a slanted prism apiece. The kernel's `sweep` along a straight path translates its profile.usecrate::solids::*;
use solidcraft_kernel::{PathSeg, sweep};
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 section, in (y, z), on the planes square to xlet section = polygon(&[(0.0, -7.0), (1.0, -6.0), (0.0, -5.0), (-1.0, -6.0)]);
let end = |x: f64| Plane { origin: v3(x, 0.0, 0.0), x: Vec3::Y, y: Vec3::Z };
letmut swept = extrude(&end(6.0), section.clone(), 0.0, 8.0)?;
// the leading faces: the end x = 14, and the upper faces of the section, each from its lower// corner (y = ±1, z = −6) up to the top corner (0, −5), along the bar's lengthlet up = |y: f64| v3(0.0, -y, 1.0) * (1.0 / 2f64.sqrt());
let faces = [
(end(14.0), section),
(Plane { origin: v3(6.0, 1.0, -6.0), x: Vec3::X, y: up(1.0) }, rect(0.0, 0.0, 8.0, 2f64.sqrt())),
(Plane { origin: v3(6.0, -1.0, -6.0), x: Vec3::X, y: up(-1.0) }, rect(0.0, 0.0, 8.0, 2f64.sqrt())),
];
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.
Time
42 ms; CPU time 44 ms; peak memory 25.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 plate from (0, -5, 0) to (20, 5, 4) less everything a square bar (6 ≤ x ≤ 14,// |y| + |z + 6| ≤ 1) passes through as it slides by 8 along (0.3, 0, √0.91).//// What the bar sweeps is the zonotope of its three edges and the slide, centred halfway along it.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 swept = m.tool(|m| zonotope(m, [10.0 + 1.2, 0.0, -6.0 + 4.0 * s],
[[8.0, 0.0, 0.0], [0.0, 1.0, 1.0], [0.0, 1.0, -1.0], [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(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
9.5 ms; CPU time 9.2 ms; peak memory 16.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.
//! The plate from (0, −5, 0) to (20, 5, 4), less everything a square bar stood on a corner//! (6 ≤ x ≤ 14, |y| + |z + 6| ≤ 1) passes through as it slides without turning by 8 along//! (0.3, 0, √0.91), stopping inside the plate.//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the bar as a convex polyhedron, its//! eight corners and six faces, slid by 8 along (0.3, 0, √0.91), and cut from the plate.usecrate::solids::p;
usecrate::solids::swept::{box_tool, less_all, slide_by};
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)?;
// the square on its corner at x = 6: from its lowest corner along its two lower sideslet bar = box_tool(p(6.0, 0.0, -7.0), p(8.0, 0.0, 0.0), p(0.0, 1.0, 1.0), p(0.0, -1.0, 1.0));
let slide = slide_by(p(0.3, 0.0, 0.91f64.sqrt()).scale(8.0));
less_all(plate, vec![sweep_solid(&bar, &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
5 ms; CPU time 8.9 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.
//! A plate (the box from (0, −5, 0) to (20, 5, 4)) pocketed from below by a bar of square section//! stood on a corner (6 ≤ x ≤ 14, |y| + |z + 6| ≤ 1) pushed 8 along (0.3, 0, √0.91).//!//! The bar is its section sketched on the plane x = 6 and extruded 8; what it passes through is//! cadrs's sweep of a solid (one slide: the bar where it starts, with what its leading faces//! sweep), cut from the plate.usecrate::bench::{block, cut, extrude, p3, v3};
usecrate::shared::swept::slid;
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel, Loop, Plane, Profile};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let plate = block(k, p3(0.0, -5.0, 0.0), p3(20.0, 5.0, 4.0))?;
// On the plane x = 6, sketch (y, z).let section = Loop::polygon(&[[0.0, -7.0], [1.0, -6.0], [0.0, -5.0], [-1.0, -6.0]]);
let bar = extrude(k, &Profile::of(Plane::yz(6.0), vec![section]), 8.0)?;
let lean = v3(0.3, 0.0, (1.0f64 - 0.09).sqrt());
let swept = slid(k, bar, 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
5.6 ms; CPU time 5.3 ms; peak memory 8.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.
//! The plate (0, −5, 0)–(20, 5, 4) less everything a square bar passes through as it slides by 8//! along (0.3, 0, √0.91): the prism 6 ≤ x ≤ 14, |y| + |z + 6| ≤ 1.use springrep::boolean::difference;
use springrep::sweep::{Motion, extrude, solid};
use springrep::topo::Brep;
usecrate::shared::swept::{boxed, polygon, 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")?;
// the section in (y, z), drawn on the plane x = 6 and carried 8 along xlet diamond = polygon(
&[(0.0, -7.0), (1.0, -6.0), (0.0, -5.0), (-1.0, -6.0)],
"side",
);
let start = frame([6.0, 0.0, 0.0], [1.0, 0.0, 0.0], [0.0, 1.0, 0.0])?;
let bar = extrude(&diamond, &start, 8.0, "bar").map_err(e)?;
let v = v3(0.3, 0.0, 0.91f64.sqrt()) * 8.0;
let pocket = solid(&bar, &Motion::Slide(v), "pocket").map_err(e)?;
difference(&plate, &pocket).map_err(e)
}
Time
180 ms; CPU time 337 ms; peak memory 53 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 bar of square// section stood on a corner, |y| + |z + 6| <= 1 from x = 6 to x = 14 (its section drawn in the side// plane through its corners, 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 {
c0 := point
c1 := point
c2 := point
c3 := point
fix((0, -7)) c0
fix((1, -6)) c1
fix((0, -5)) c2
fix((-1, -6)) c3
square := line(c0, c1) -> line(c1, c2) -> line(c2, c3) -> line(c3, c0) -> close
}
bar := solid(std.solids.Prism(square, 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 bar at(under: ram) t })
pocket cut part
Time
5.3 ms; CPU time 5.1 ms; peak memory 4.8 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 from (0, −5, 0) to (20, 5, 4) less what a square bar on its corner (6 ≤ x ≤ 14,//! |y| + |z + 6| ≤ 1) passes through, slid 8 along (0.3, 0, √0.91) into it.use anvil_brep::Solid;
usecrate::shared::{block, subtract, v3, zonotope};
pubfnbuild() -> Result<Solid, String> {
// anvil-brep has no sweep of a solid. The bar is a parallelepiped, its edges (8, 0, 0),// (0, 1, 1) and (0, −1, 1); slid along a line it fills the zonotope of those and the slidelet slide = v3(0.3, 0., 0.91f64.sqrt()) * 8.;
let center = v3(10., 0., -6.) + slide * 0.5;
let swept = zonotope(center, &[v3(8., 0., 0.), v3(0., 1., 1.), v3(0., -1., 1.), slide])?;
subtract(&block([0., -5., 0.], [20., 5., 4.])?, &swept)
}