A plate, the box from (−10, −10, 0) to (10, 10, 4), with an annular cut made right through it by a core drill pushed along its own leaning axis.
The drill is a tube: everything between 1.5 and 2.5 from its axis, which is the line through (0, 0, 2) along the direction u = (sin 30°, 0, cos 30°), leaning 30° from upright toward +x. As placed, the tube runs along its axis from 18 to 6 before (0, 0, 2), its ends square to its axis, wholly below the plate.
It slides along u by 24, to run from 6 to 18 past (0, 0, 2), wholly above the plate. Cut from the plate everything the tube passes through.
The tube's shadow along the push is an annulus, so it sweeps two oblique cylinders through the plate. The core inside the inner one is cut free of the plate and stays: the result is two separate solids, the plate with its oblique hole and the core, an oblique cylinder of radius 1.5 cut by the planes z = 0 and z = 4.
expected
closed form
volume
1541.95842
1600 − 4·π(2.5² − 1.5²)/cos 30°: each level loses the annulus between two ellipses
† 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
258 ms; CPU time 336 ms; peak memory 18.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 (−10, −10, 0)–(10, 10, 4), cut right through by a core drill: the tube between//! 1.5 and 2.5 from the line through (0, 0, 2) along u = (sin 30°, 0, cos 30°), running along it//! from 18 to 6 before (0, 0, 2), its ends square to it, slid along u by 24. The core inside it is//! cut free and stays: two solids.usecrate::sketch::block;
use cad_kernel::build::{disc, prism, Profile};
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, scale};
use std::f64::consts::TAU;
constPLATE_LO: V = [-10., -10., 0.];
constPLATE_HI: V = [10., 10., 4.];
/// The point of the drill's axis it is placed about, and how far the axis leans toward +x.constCENTRE: V = [0., 0., 2.];
constLEAN: f64 = 30.;
constRADII: [f64; 2] = [1.5, 2.5];
/// Where the tube starts along its axis from the centre, its length and the push.constSTART: f64 = -18.;
constLENGTH: f64 = 12.;
constPUSH: f64 = 24.;
/// How closely the tube is meshed for the sweep's membership reads.constBAR: f64 = 0.002;
pubfnbuild() -> Result<Brep, String> {
let plate = block(PLATE_LO, PLATE_HI)?;
let lean = LEAN.to_radians();
let u = [lean.sin(), 0., lean.cos()];
// the tube: the annulus between its radii square to u, its outer circle and its hole, swept 12// along ulet foot = add(CENTRE, scale(u, START));
let [inner, outer] = RADII;
let loops = vec![disc(foot, u, outer).loops.remove(0), disc(foot, u, inner).loops.remove(0)];
let tube = prism(&Profile { origin: foot, normal: u, loops, names: Vec::new() }, 0., LENGTH)?;
// the slide along u: a screw that does not turn, advancing its whole length over a roll of τlet path = Trajectory::Twist(Screw { origin: CENTRE, axis: u, ratio: 0., advance: PUSH });
// the kernel's closed swept solid cut from the plate on one arrangement: each of the tube's// cylinders along the slide swept along itself, its flat ends at both end poseslet size = plate.size().max(tube.size());
cut_from(&plate, &tube, &path, [0., TAU], BAR, tolerance(size))
.map_err(|why| format!("the drill's sweep not built: {why:?}"))
}
Time
639 ms; CPU time 638 ms; peak memory 368.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 core drill pushed along its leaning axis through a plate. A plate, the box from (−10, −10, 0)
to (10, 10, 4), with an annular cut made right through it by a core drill pushed along its own
leaning axis.
The drill is a tube: everything between 1.5 and 2.5 from its axis, which is the line through (0, 0,
2) along the direction u = (sin 30°, 0, cos 30°), leaning 30° from upright toward +x. As placed,
the tube runs along its axis from 18 to 6 before (0, 0, 2), its ends square to its axis, wholly
below the plate.
It slides along u by 24, to run from 6 to 18 past (0, 0, 2), wholly above the plate. Cut from the
plate everything the tube passes through.
The tube's shadow along the push is an annulus, so it sweeps two oblique cylinders through the
plate. The core inside the inner one is cut free of the plate and stays: the result is two separate
solids, the plate with its oblique hole and the core, an oblique cylinder of radius 1.5 cut by the
planes z = 0 and z = 4."""import math
fromOCP.BRepAlgoAPIimportBRepAlgoAPI_CutfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp_Ax2, gp_Dir, gp_Pnt
from bench importRefusedfrom sweep import cut, slid
PLATE = ((-10, -10, 0), (10, 10, 4))
CENTRE = (0, 0, 2)
LEAN = 30# degrees from upright, toward +xOUTER, INNER = 2.5, 1.5FROM, TO = -18, -6# where the tube starts and ends along its axis, past CENTREPUSH = 24defbuild():
u = (math.sin(math.radians(LEAN)), 0, math.cos(math.radians(LEAN)))
foot = gp_Pnt(*(c + FROM * d for c, d inzip(CENTRE, u)))
axis = gp_Ax2(foot, gp_Dir(*u))
outer = BRepPrimAPI_MakeCylinder(axis, OUTER, TO - FROM).Shape()
inner = BRepPrimAPI_MakeCylinder(axis, INNER, TO - FROM).Shape()
tube = BRepAlgoAPI_Cut(outer, inner)
ifnot tube.IsDone():
raiseRefused("BRepAlgoAPI_Cut declined the tube's bore")
# Pushed along its own axis, the tube's two cylinders slide along themselves; its flat ends,# square to the push, lead or trail all over.
swept = slid(tube.Shape(), tuple(PUSH * d for d in u))
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
10 ms; CPU time 10 ms; peak memory 11.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.
//! A plate, the box from (−10, −10, 0) to (10, 10, 4), cut right through by a core drill pushed//! along its own leaning axis: the tube between radii 1.5 and 2.5 about the line through (0, 0, 2)//! along u = (sin 30°, 0, cos 30°), running from 18 to 6 before (0, 0, 2), slid along u by 24 to//! run from 6 to 18 past it. The core inside the tube is cut free and stays: two solids.//!//! The tube is a cylinder less a narrower one; its sweep is kentron's sweep of a solid//! (`sweep::solid`, one slide), cut from the plate. kentron refuses it: following where the slide//! grazes the tube's faces (all along its two cylinders, which slide along themselves), a point//! does not settle on the curve.usecrate::bench::{frame, p, v};
use kentron::boolean;
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(-10.0, -10.0, 0.0), p(10.0, 10.0, 4.0)).build(m)?;
let (sin, cos) = (30f64.to_radians().sin(), 30f64.to_radians().cos());
let start = frame(p(-18.0 * sin, 0.0, 2.0 - 18.0 * cos), Direction::new(sin, 0.0, cos));
let outer = Cylinder::new(2.5, 12.0).with_frame(start).build(m)?;
let inner = Cylinder::new(1.5, 12.0).with_frame(start).build(m)?;
let tube = boolean::difference(m, outer, inner)?;
let swept = sweep::solid(m, tube, &RigidMotion::Slide { by: v(sin, 0.0, cos) * 24.0 })?;
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
89 ms; CPU time 89 ms; peak memory 48.6 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 (−10, −10, 0) to (10, 10, 4), cut right through by a core drill: the tube//! between 1.5 and 2.5 from the line through (0, 0, 2) along u = (sin 30°, 0, cos 30°), running//! from 18 to 6 before (0, 0, 2), slid along u by 24.//!//! solidcraft-kernel has no sweep of a solid, so the tube's sweep is built by elementary geometry://! a prism slid along its own axis sweeps the same prism lengthened by the slide, here the tube//! from 18 before (0, 0, 2) to 18 past it, its annulus extruded along u. The core it leaves is a//! separate solid of the result.usecrate::solids::*;
pubfnbuild() -> R<Body> {
let plate = block((-10.0, -10.0, 0.0), (10.0, 10.0, 4.0))?;
let a = 30f64.to_radians();
let u = v3(a.sin(), 0.0, a.cos());
let start = Plane::from_normal(v3(0.0, 0.0, 2.0) - u * 18.0, u)
.ok_or_else(|| KernelError::Invalid("the tube's axis".into()))?;
let annulus = Region2 {
outer: Loop2::circle(Vec2::ZERO, 2.5),
holes: vec![Loop2::circle(Vec2::ZERO, 1.5)],
};
cut(&plate, &extrude(&start, annulus, 0.0, 36.0)?)
}
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
144 ms; CPU time 153 ms; peak memory 26.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 from (-10, -10, 0) to (10, 10, 4) less everything a core drill passes through as it// slides 24 along its own leaning axis (through (0, 0, 2) along (sin 30°, 0, cos 30°)): a tube// between radii 1.5 and 2.5.//// Sliding along its own axis, the tube sweeps itself lengthened, from 18 before (0, 0, 2) to 18// past it. The core inside it is cut free and stays.let m = model();
let pi = 3.141592653589793;
let u = [sin(pi / 6.0), 0.0, cos(pi / 6.0)];
let start = [-18.0 * u[0], 0.0, 2.0 - 18.0 * u[2]];
let tube = m.tool(|m| m.cylinder(2.5, 36.0, #{ at: start, axis: u, ref: [0.0, 1.0, 0.0] })
.subtract(m.tool(|m| m.cylinder(1.5, 36.0, #{ at: start, axis: u, ref: [0.0, 1.0, 0.0] }))));
let plate = m.box(20.0, 20.0, 4.0, #{ at: [-10.0, -10.0, 0.0] });
plate = plate.subtract(tube);
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
61 ms; CPU time 61 ms; peak memory 23.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.
//! The plate from (−10, −10, 0) to (10, 10, 4), less everything a core drill passes through as it//! slides by 24 along its own leaning axis u = (sin 30°, 0, cos 30°) through (0, 0, 2): the tube//! between 1.5 and 2.5 from that axis, from 18 to 6 before (0, 0, 2) where it starts.//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the core drill, a solid of//! revolution about its leaning axis whose meridian is the rectangle between 1.5 and 2.5 from the//! axis, from 18 to 6 before (0, 0, 2), slid by 24 along that axis, 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 lean = 30f64.to_radians();
let (u, out) = (p(lean.sin(), 0.0, lean.cos()), p(lean.cos(), 0.0, -lean.sin()));
let plate = make_box_brep(p(-10.0, -10.0, 0.0), 20.0, 20.0, 4.0)?;
let drill = revolved_tool(p(0.0, 0.0, 2.0), u, out, &[
Piece::Line { from: [1.5, -18.0], to: [2.5, -18.0] },
Piece::Line { from: [2.5, -18.0], to: [2.5, -6.0] },
Piece::Line { from: [2.5, -6.0], to: [1.5, -6.0] },
Piece::Line { from: [1.5, -6.0], to: [1.5, -18.0] },
]);
less_all(plate, vec![sweep_solid(&drill, &slide_by(u.scale(24.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
8.2 ms; CPU time 14 ms; peak memory 9.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 (−10, −10, 0) to (10, 10, 4)) cut right through by a core drill (the tube//! between 1.5 and 2.5 from the line through (0, 0, 2) along u = (sin 30°, 0, cos 30°), from 18 to 6//! before (0, 0, 2)) pushed 24 along u: the plate with an oblique annular hole, and its core cut//! free.//!//! The tube is its annulus sketched square to u and extruded 12; what it passes through is cadrs's//! sweep of a solid (one slide), cut from the plate (two solids).usecrate::bench::{block, cut, extrude, p3, v3, P3};
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(-10.0, -10.0, 0.0), p3(10.0, 10.0, 4.0))?;
let u = v3(30f64.to_radians().sin(), 0.0, 30f64.to_radians().cos());
let from = P3::new(0.0, 0.0, 2.0) - u * 18.0;
let ring = Profile::with_holes(Plane::square_to(from, u), Loop::circle([0.0, 0.0], 2.5), vec![Loop::circle([0.0, 0.0], 1.5)]);
let tube = extrude(k, &ring, 12.0)?;
let swept = slid(k, tube, u * 24.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
4.8 ms; CPU time 4.5 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 (−10, −10, 0)–(10, 10, 4) less everything a core drill passes through as it slides//! along its own axis by 24: the tube between radii 1.5 and 2.5 about the line through (0, 0, 2)//! along u = (sin 30°, 0, cos 30°), from 18 to 6 before that point.use springrep::boolean::difference;
use springrep::math::Vec2;
use springrep::profile::Profile;
use springrep::sweep::{Motion, extrude, solid};
use springrep::topo::Brep;
usecrate::shared::swept::{boxed, deg, v3};
usecrate::shared::{e, frame};
pubfnbuild() -> Result<Brep, String> {
let plate = boxed([-10.0, -10.0, 0.0], [10.0, 10.0, 4.0], "plate")?;
let (s, c) = deg(30.0).sin_cos();
let start = [-18.0 * s, 0.0, 2.0 - 18.0 * c];
let annulus =
Profile::circle(Vec2::ZERO, 5.0).with_holes(Profile::circle(Vec2::ZERO, 3.0).loops);
let base = frame(start, [s, 0.0, c], [0.0, 1.0, 0.0])?;
let drill = extrude(&annulus, &base, 12.0, "drill").map_err(e)?;
let cut = solid(&drill, &Motion::Slide(v3(s, 0.0, c) * 24.0), "cut").map_err(e)?;
difference(&plate, &cut).map_err(e)
}
Time
280 ms; CPU time 454 ms; peak memory 41.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 (-10, -10, 0) to (10, 10, 4), its footprint in the top plane; a core drill,// the tube between radii 1.5 and 2.5 about the line through (0, 0, 2) along u = (sin 30, 0, cos 30)// (z turned 30 degrees about y), running from 18 to 6 before that point: its annulus drawn in the// plane through (0, 0, 2) square to u and carried along u. It slides 24 along u, from wholly below// the plate to wholly above it, and everything it passes through is cut from the plate; the core// inside it stays, cut free.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (slides)
in std.top {
a := point
b := point hint((10, -10))
c := point hint((10, 10))
d := point hint((-10, 10))
outline := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((-10, -10)) a
a distance(20) b
b distance(20) c
}
part := solid(std.solids.Prism(outline, from: 0mm, to: 4mm))
// the drill's axis, and the plane square to it through (0, 0, 2)
lean := axis hint(dir: (0.5, 0, 0.87))
lean perpendicular std.y
std.z angle(30deg, about: std.y) lean
across := axis hint(dir: (0.87, 0, -0.5))
across perpendicular std.y
std.x angle(30deg, about: std.y) across
along := axis hint(dir: (0, 1, 0))
along parallel(sense: same) std.y
square := plane(u: across, v: along)
fix(origin == (0, 0, 2)) square
in square {
o := point
fix((0, 0)) o
wall := circle(center: o) hint(r: 2.5)
bore := circle(center: o) hint(r: 1.5)
radius(2.5) wall
radius(1.5) bore
}
drill := solid(std.solids.Prism(face(wall, holes: bore), from: -18mm, to: -6mm))
// the push, 24 along the drill's own axis over the roll
ram := frame
ram slides(24mm) lean
hole := solid({ p | some t in (0deg, 360deg): p in drill at(under: ram) t })
hole cut part
Time
121 ms; CPU time 121 ms; peak memory 5.2 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 (−10, −10, 0) to (10, 10, 4) less what a core drill (a tube from 1.5 to 2.5 about//! the line through (0, 0, 2) along (sin 30°, 0, cos 30°)) passes through, pushed 24 along its//! axis from below the plate to above it: the plate and the core it cuts free.use anvil_brep::Solid;
use anvil_brep::boolean::{BoolOp, boolean};
use anvil_brep::extrude;
usecrate::shared::{block, circle, e, frame, region};
pubfnbuild() -> Result<Vec<Solid>, String> {
// anvil-brep has no sweep of a solid. Pushed along its own axis the tube fills itself// lengthened by the push: from 18 before (0, 0, 2) to 18 past itlet (s, c) = 30f64.to_radians().sin_cos();
let axis = frame([0., 0., 2.], [s, 0., c], [0., 1., 0.])?;
let ring = region(&[circle((0., 0.), 2.5), circle((0., 0.), 1.5)])?;
let tube = extrude::extrude(&axis, &ring, -18., 18.).map_err(e)?;
boolean(&block([-10., -10., 0.], [10., 10., 4.])?, &tube, BoolOp::Subtract).map_err(e)
}