A plate, the box from (−15, −15, 0) to (15, 15, 4), with a hole punched through it by a tilted box pushed aslant wholly through it.
The box is 4 × 3 × 2, its edges along the orthonormal directions e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3 and e₃ = (1, 2, −2)/3: everything (−2, −1, −8) + a e₁ + b e₂ + c e₃ with |a| ≤ 2, |b| ≤ 1.5 and |c| ≤ 1. As placed it is wholly below the plate.
It slides without turning along the vector (4, 2, 18), ending centered on (2, 1, 10), wholly above the plate. Cut from the plate everything the box passes through.
No face or edge of the box is level or upright: where it passes, its silhouette turns at its corners. Each level of the plate loses the box's whole shadow along the push, a hexagon, so the hole is an oblique hexagonal prism.
expected
closed form
volume
3546.37037
3600 − 4·H, H the box's shadow along the push on a level plane, a hexagon: every level of the plate loses the same hexagon (each level of the box passes it), its area exact
area
2309.917226
2280 − 2H + Σ over the hexagon's six edges e of |e × (4/18, 2/18, 1)·4|: the hole is an oblique prism on 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
221 ms; CPU time 446 ms; peak memory 51.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 (−15, −15, 0)–(15, 15, 4), with a hole punched through it by a tilted box —//! everything (−2, −1, −8) + a e₁ + b e₂ + c e₃, |a| ≤ 2, |b| ≤ 1.5, |c| ≤ 1, along//! e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3, e₃ = (1, 2, −2)/3 — slid without//! turning along (4, 2, 18), wholly through it.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 cad_kernel::util::space::{add, norm, scale, unit};
use std::f64::consts::TAU;
constCENTRE: V = [-2., -1., -8.];
constE1: V = [2. / 3., 1. / 3., 2. / 3.];
constE2: V = [-2. / 3., 2. / 3., 1. / 3.];
/// The box's half-extents along e₁, e₂ and e₃.constHALF: [f64; 3] = [2., 1.5, 1.];
constPUSH: V = [4., 2., 18.];
pubfnbuild() -> Result<Brep, String> {
let plate = block([-15., -15., 0.], [15., 15., 4.])?;
// the box's middle section, the rectangle across e₁ and e₂ through its centre, swept 1 each// way along its normal (±e₃)let at = |a: f64, b: f64| add(CENTRE, add(scale(E1, a * HALF[0]), scale(E2, b * HALF[1])));
let section = polygon(&[at(-1., -1.), at(1., -1.), at(1., 1.), at(-1., 1.)]);
let tool = prism(§ion, -HALF[2], HALF[2])?;
// the push along (4, 2, 18): a screw that does not turn, advancing its whole length over a// roll of τlet path = Trajectory::Twist(Screw {
origin: CENTRE, axis: unit(PUSH), ratio: 0., advance: norm(PUSH),
});
// the kernel's swept solid cut from the plate on one arrangement (a box's flat faces mesh// exactly, at any bar)let size = plate.size().max(tool.size());
cut_from(&plate, &tool, &path, [0., TAU], tool.size(), tolerance(size))
.map_err(|why| format!("the box's sweep not built: {why:?}"))
}
Time
670 ms; CPU time 669 ms; peak memory 368.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 tilted box pushed aslant wholly through a plate. A plate, the box from (−15, −15, 0) to (15,
15, 4), with a hole punched through it by a tilted box pushed aslant wholly through it.
The box is 4 × 3 × 2, its edges along the orthonormal directions e₁ = (2, 1, 2)/3, e₂ = (−2, 2,
1)/3 and e₃ = (1, 2, −2)/3: everything (−2, −1, −8) + a e₁ + b e₂ + c e₃ with |a| ≤ 2, |b| ≤ 1.5
and |c| ≤ 1. As placed it is wholly below the plate.
It slides without turning along the vector (4, 2, 18), ending centered on (2, 1, 10), wholly above
the plate. Cut from the plate everything the box passes through.
No face or edge of the box is level or upright: where it passes, its silhouette turns at its
corners. Each level of the plate loses the box's whole shadow along the push, a hexagon, so the
hole is an oblique hexagonal prism."""fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBoxfromOCP.gp import gp_Ax2, gp_Dir, gp_Pnt
from sweep import cut, slid
PLATE = ((-15, -15, 0), (15, 15, 4))
CENTRE = (-2, -1, -8)
E1, E2, E3 = (2 / 3, 1 / 3, 2 / 3), (-2 / 3, 2 / 3, 1 / 3), (1 / 3, 2 / 3, -2 / 3)
HALF = (2, 1.5, 1) # half the box's size along e₁, e₂ and e₃PUSH = (4, 2, 18)
defbuild():
# e₁ × e₂ = −e₃, so the box's frame is e₁, e₂, −e₃, with its corner at the centre less half# of each side
corner = [c - HALF[0] * a - HALF[1] * b + HALF[2] * d
for c, a, b, d inzip(CENTRE, E1, E2, E3)]
frame = gp_Ax2(gp_Pnt(*corner), gp_Dir(*(-d for d inE3)), gp_Dir(*E1))
box = BRepPrimAPI_MakeBox(frame, 2 * HALF[0], 2 * HALF[1], 2 * HALF[2]).Shape()
# Every face is flat and none is parallel to the push: none needs splitting.
swept = slid(box, 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.6 ms; CPU time 8.3 ms; peak memory 10.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, the box from (−15, −15, 0) to (15, 15, 4), with a hole punched by a tilted box pushed//! aslant wholly through it: the 4 × 3 × 2 box (−2, −1, −8) + a e₁ + b e₂ + c e₃, |a| ≤ 2, |b| ≤//! 1.5, |c| ≤ 1, its edges along e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3 and e₃ = (1, 2, −2)/3, slid//! without turning along (4, 2, 18), from wholly below the plate to wholly above it. Everything the//! box passes through, cut.//!//! The box'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::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(-15.0, -15.0, 0.0), p(15.0, 15.0, 4.0)).build(m)?;
// The box's frame: x along e₁, y along e₂ and z along e₁ × e₂ = −e₃, at its lowest corner.let (e1, e2, e3) = (v(2.0, 1.0, 2.0) / 3.0, v(-2.0, 2.0, 1.0) / 3.0, v(1.0, 2.0, -2.0) / 3.0);
let corner = p(-2.0, -1.0, -8.0) - e1 * 2.0 - e2 * 1.5 + e3;
let tilted = Cuboid::new(4.0, 3.0, 2.0).with_frame(Frame::new(corner, d(-e3.x, -e3.y, -e3.z), d(e1.x, e1.y, e1.z))).build(m)?;
let swept = sweep::solid(m, tilted, &RigidMotion::Slide { by: v(4.0, 2.0, 18.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
3.70 s; CPU time 3.70 s; peak memory 53 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 (−15, −15, 0) to (15, 15, 4), with a hole punched through it by a tilted//! box: everything (−2, −1, −8) + a e₁ + b e₂ + c e₃ with |a| ≤ 2, |b| ≤ 1.5 and |c| ≤ 1, its//! edges along e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3 and e₃ = (1, 2, −2)/3, slid without turning//! along (4, 2, 18).//!//! solidcraft-kernel has no sweep of a solid, so the slide is built, as in `box-slid-aslant`, from//! the box and its faces by elementary geometry: a point the box passes over that is outside it//! where it starts is reached first by a face it leads with, one whose outward normal points along//! the slide. The slide makes 46/3 with e₁, 14/3 with e₂ and −28/3 with e₃, so those are the faces//! a = 2, b = 1.5 and c = −1; the solid is the box where it starts and those three faces each slid//! the whole way. The box is drawn on planes along its own edges, so it is placed by them.usecrate::solids::*;
use solidcraft_kernel::{PathSeg, sweep};
pubfnbuild() -> R<Body> {
let plate = block((-15.0, -15.0, 0.0), (15.0, 15.0, 4.0))?;
let slide = v3(4.0, 2.0, 18.0);
let centre = v3(-2.0, -1.0, -8.0);
let e1 = v3(2.0, 1.0, 2.0) * (1.0 / 3.0);
let e2 = v3(-2.0, 2.0, 1.0) * (1.0 / 3.0);
// −e₃ = e₁ × e₂, so (e₁, e₂, −e₃) is a right-handed frame; the box's face c = −1 faces −e₃let f3 = e1.cross(e2);
// the box: its section in (a, b) extruded from c = 1 to c = −1 (along −e₃)letmut swept = extrude(&Plane { origin: centre, x: e1, y: e2 }, rect(-2.0, -1.5, 2.0, 1.5), -1.0, 1.0)?;
// the leading faces, each drawn about its centre along the box's other two edgeslet faces = [
(Plane { origin: centre + e1 * 2.0, x: e2, y: f3 }, rect(-1.5, -1.0, 1.5, 1.0)),
(Plane { origin: centre + e2 * 1.5, x: f3, y: e1 }, rect(-1.0, -2.0, 1.0, 2.0)),
(Plane { origin: centre + f3, x: e1, y: e2 }, rect(-2.0, -1.5, 2.0, 1.5)),
];
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
25 ms; CPU time 27 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 (-15, -15, 0) to (15, 15, 4) less everything a tilted box (4 by 3 by 2 along// e1 = (2, 1, 2)/3, e2 = (-2, 2, 1)/3, e3 = (1, 2, -2)/3, centred at (-2, -1, -8)) passes through// as it slides along (4, 2, 18), wholly through the plate.//// What the box 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 e1 = [2.0 / 3.0, 1.0 / 3.0, 2.0 / 3.0];
let e2 = [-2.0 / 3.0, 2.0 / 3.0, 1.0 / 3.0];
let e3 = [1.0 / 3.0, 2.0 / 3.0, -2.0 / 3.0];
let g = [[4.0 * e1[0], 4.0 * e1[1], 4.0 * e1[2]], [3.0 * e2[0], 3.0 * e2[1], 3.0 * e2[2]],
[2.0 * e3[0], 2.0 * e3[1], 2.0 * e3[2]], [4.0, 2.0, 18.0]];
let swept = m.tool(|m| zonotope(m, [0.0, 0.0, 1.0], g));
let plate = m.box(30.0, 30.0, 4.0, #{ at: [-15.0, -15.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.2 ms; CPU time 8.8 ms; peak memory 17 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 (−15, −15, 0) to (15, 15, 4), less everything a tilted box passes through as it//! slides without turning along (4, 2, 18): the box (−2, −1, −8) + a e₁ + b e₂ + c e₃, |a| ≤ 2,//! |b| ≤ 1.5, |c| ≤ 1, e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3, e₃ = (1, 2, −2)/3.//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the box as a convex polyhedron, its//! eight corners and six faces, slid by (4, 2, 18), 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(-15.0, -15.0, 0.0), 30.0, 30.0, 4.0)?;
let third = |x: f64, y: f64, z: f64| p(x, y, z).scale(1.0 / 3.0);
let (e1, e2, e3) = (third(2.0, 1.0, 2.0), third(-2.0, 2.0, 1.0), third(1.0, 2.0, -2.0));
let corner = p(-2.0, -1.0, -8.0).add(e1.scale(-2.0)).add(e2.scale(-1.5)).add(e3.scale(-1.0));
let tool = box_tool(corner, e1.scale(4.0), e2.scale(3.0), e3.scale(2.0));
less_all(plate, vec![sweep_solid(&tool, &slide_by(p(4.0, 2.0, 18.0)))?])
}
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.8 ms; CPU time 10 ms; peak memory 9.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 plate (the box from (−15, −15, 0) to (15, 15, 4)) holed by a tilted box (4 × 3 × 2 along//! e₁ = (2, 1, 2)/3, e₂ = (−2, 2, 1)/3 and e₃ = (1, 2, −2)/3, centered at (−2, −1, −8)) pushed along//! (4, 2, 18), wholly through it.//!//! The box is a block about the origin carried by the rotation whose columns are e₁, e₂, e₃ and//! moved to its center (cadrs's affine transform); what it passes through is cadrs's sweep of a//! solid (one slide), cut from the plate.usecrate::bench::{block, cut, p3, v3};
usecrate::shared::swept::slid;
use cadrs_kernel::Kernel;
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let plate = block(k, p3(-15.0, -15.0, 0.0), p3(15.0, 15.0, 4.0))?;
let local = block(k, p3(-2.0, -1.5, -1.0), p3(2.0, 1.5, 1.0))?;
let m = nalgebra::Matrix3::from_columns(&[
v3(2.0, 1.0, 2.0) / 3.0,
v3(-2.0, 2.0, 1.0) / 3.0,
v3(1.0, 2.0, -2.0) / 3.0,
]);
let tilted = k.transform_affine(local, m, v3(-2.0, -1.0, -8.0))?.first()?;
let swept = slid(k, tilted, v3(4.0, 2.0, 18.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
9.1 ms; CPU time 8.9 ms; peak memory 8.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.
//! The plate (−15, −15, 0)–(15, 15, 4) less everything a tilted box passes through as it slides//! along (4, 2, 18): the box about (−2, −1, −8) reaching 2, 1.5 and 1 along e₁ = (2, 1, 2)/3,//! e₂ = (−2, 2, 1)/3 and e₃ = (1, 2, −2)/3.use springrep::boolean::difference;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, cuboid, v3};
pubfnbuild() -> Result<Brep, String> {
let plate = boxed([-15.0, -15.0, 0.0], [15.0, 15.0, 4.0], "plate")?;
let axes = [
v3(2.0, 1.0, 2.0) * (1.0 / 3.0),
v3(-2.0, 2.0, 1.0) * (1.0 / 3.0),
v3(1.0, 2.0, -2.0) * (1.0 / 3.0),
];
let tilted = cuboid(v3(-2.0, -1.0, -8.0), axes, [2.0, 1.5, 1.0], "box")?;
let hole = solid(&tilted, &Motion::Slide(v3(4.0, 2.0, 18.0)), "hole").map_err(e)?;
difference(&plate, &hole).map_err(e)
}
Time
314 ms; CPU time 478 ms; peak memory 41.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 plate, the box from (-15, -15, 0) to (15, 15, 4), with a hole punched by a tilted box pushed// aslant wholly through it. The box is 4 x 3 x 2 about (-2, -1, -8), its edges along// e1 = (2, 1, 2)/3, e2 = (-2, 2, 1)/3 and e3 = (1, 2, -2)/3: its 4 x 3 face drawn in the plane// through its centre spanned by e1 and e2, and the prism over it 1 either side. It slides without// turning along (4, 2, 18), and the kernel's sweep of it under that slide is cut from the plate.unit mm
use std
use std.solids (cut)
use std.shapes
use std.motion (slides)
in std.top {
private mid := point
fix((0, 0)) mid
private outline := std.shapes.CenteredRectangle(mid, w: 30mm, h: 30mm)
}
part := solid(std.solids.Prism(outline.loop, from: 0mm, to: 4mm))
// the box, about its centre in the plane of its first two edgesprivate e1 := axis
fix(dir == (2, 1, 2)) e1
private e2 := axis
fix(dir == (-2, 2, 1)) e2
bench := plane(u: e1, v: e2)
fix(origin == (-2, -1, -8)) bench
in bench {
private c := point
fix((0, 0)) c
private section := std.shapes.CenteredRectangle(c, w: 4mm, h: 3mm)
}
construction box := solid(std.solids.Prism(section.loop, from: -1mm, to: 1mm))
// the push: along (4, 2, 18) from the box's centre, its whole length over the roll's one turnprivate push := axis
fix(dir == (4, 2, 18)) push
c coincident push
ram := frame
ram slides(sqrt(4^2 + 2^2 + 18^2) * 1mm) push
construction hole := solid({ p | some t in (0deg, 360deg): p in box at(under: ram) t })
hole cut part
Time
6.7 ms; CPU time 6.5 ms; peak memory 4.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 plate from (−15, −15, 0) to (15, 15, 4) less what a tilted 4 × 3 × 2 box passes through as it//! slides along (4, 2, 18) from below the plate to above it.use anvil_brep::Solid;
usecrate::shared::{block, subtract, v3, zonotope};
pubfnbuild() -> Result<Solid, String> {
// anvil-brep has no sweep of a solid. A box slid along a line fills the zonotope of its three// edges and the slide, centered halfway alonglet (e1, e2, e3) = (v3(2., 1., 2.) / 3., v3(-2., 2., 1.) / 3., v3(1., 2., -2.) / 3.);
let slide = v3(4., 2., 18.);
let center = v3(-2., -1., -8.) + slide * 0.5;
let swept = zonotope(center, &[e1 * 4., e2 * 3., e3 * 2., slide])?;
subtract(&block([-15., -15., 0.], [15., 15., 4.])?, &swept)
}