A block, the box from (−10, −10, −10) to (40, 40, 0), with a groove cut into its top by a bull-nose mill run along a path made of a line, an arc and a line.
The mill is a solid of revolution about an upright axis: a cylinder of radius 2 from 1.5 below the block's top up to 5 above it, whose bottom corner is rounded to radius 0.5. Its flat bottom is a disc of radius 1.5 at z = −1.5, joined to its side (radius 2, from z = −1 up) by a quarter of a torus whose tube, of radius 0.5, is centered on the circle of radius 1.5 at z = −1.
Its axis starts on the vertical line through (0, 0) and moves, staying upright, in three pieces:
it slides along the x axis to (20, 0);
it turns a quarter turn about the vertical line through (20, 10), right-handed (from −y toward +x), carried rigidly, to (30, 10);
it slides along +y to (30, 30).
Cut from the block everything the mill passes through.
The path is tangent where its pieces meet, and its arc, of radius 10, is wider than the mill. The round's bottom circle stays in its plane, so the groove has a flat floor 3 wide.
expected
closed form
volume
24653.51672
50·50·10 − (A·L + V₀), L = 40 + 5π the path's length, A = ∫2R(z) dz the groove's section below the top, V₀ = ∫πR(z)² dz the mill below the top, R(z) = 1.5 + √(0.25 − (z + 1)²) below z = −1, 2 above (Pappus on the arc: the section is symmetric about the path)
area
7159.25541
7000 − (4L + 4π) (the opening) + (3L + 2.25π) (the floor) + 2L(0.5π/2 + 1) (the walls) + the mill's side and round below the top, 2π·0.5(1.5π/2 + 0.5) + 2π·2·1
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
30 ms; CPU time 52 ms; 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.
//! A block, the box (−10, −10, −10)–(40, 40, 0), with a groove cut into its top by a bull-nose//! mill — radius 2 from 1.5 below the top to 5 above it, its bottom corner rounded to 0.5 — whose//! upright axis runs from (0, 0) along x to (20, 0), a quarter turn about the vertical line through//! (20, 10) to (30, 10), carried rigidly, and along +y to (30, 30).//!//! Refused by the kernel, after about five minutes: the solid its arrangement selected disagrees//! with the sweep's definition at a witness point inside the bend, at the height of the mill's//! flat bottom (`Unbuilt::Wrong`), and it never returns a solid built wrong.usecrate::sketch::block;
use cad_kernel::build::{revolve, Profile, ProfileEdge};
use cad_kernel::geom::{tolerance, Frame, V};
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Piece, Pose, Screw, Trajectory};
use std::f64::consts::{FRAC_PI_2, TAU};
constSTOCK_LO: V = [-10., -10., -10.];
constSTOCK_HI: V = [40., 40., 0.];
/// The mill: the middle of its flat bottom, its radius, its corner's and its top.constFOOT: V = [0., 0., -1.5];
constRADIUS: f64 = 2.;
constCORNER: f64 = 0.5;
constTOP: f64 = 5.;
/// The path: the first run's length, the arc's centre and radius, the last run's length.constFIRST: f64 = 20.;
constARC_CENTRE: V = [20., 10., 0.];
constARC_RADIUS: f64 = 10.;
constLAST: f64 = 20.;
/// How closely the mill is meshed for the sweep's membership reads: a two-hundred-and-fiftieth of/// its corner's radius.constBAR: f64 = 0.002;
/// The mill about the vertical line through the origin: its meridian in the half-plane y = 0/// beyond the axis — out along its flat bottom, round its corner, up its side, back across its top/// and down its axis — turned once about the axis.fnmill() -> Result<Brep, String> {
let at = |x: f64, z: f64| [x, 0., z];
let [_, _, z0] = FOOT;
let corner = Frame::new(at(RADIUS - CORNER, z0 + CORNER), [0., -1., 0.], [1., 0., 0.]);
let edges = vec![
ProfileEdge::Line { a: at(0., z0), b: at(RADIUS - CORNER, z0) },
ProfileEdge::Arc { frame: corner, r: CORNER, span: Some([-FRAC_PI_2, 0.]) },
ProfileEdge::Line { a: at(RADIUS, z0 + CORNER), b: at(RADIUS, TOP) },
ProfileEdge::Line { a: at(RADIUS, TOP), b: at(0., TOP) },
ProfileEdge::Line { a: at(0., TOP), b: at(0., z0) },
];
let meridian = Profile { origin: FOOT, normal: [0., 1., 0.], loops: vec![edges],
names: Vec::new() };
revolve(&meridian, FOOT, [0., 0., 1.], TAU)
}
/// The constant twist `twist` taken up over the roll from `start` where the piece before it left/// the tool, `left`: placed so that at `start` it stands at `left` (`Placed` stands `at`, then/// `twist(t)`).fntaken_up(twist: Screw, left: Pose, start: f64) -> Trajectory {
Trajectory::Placed { twist, at: left.then(twist.pose(-start)) }
}
pubfnbuild() -> Result<Brep, String> {
let stock = block(STOCK_LO, STOCK_HI)?;
let tool = mill()?;
let up = [0., 0., 1.];
// the roll is the length along the axis's path, each piece a constant twist at unit speed:// a slide along x, a turn about the arc's centre of a radian per `ARC_RADIUS`, a slide along ylet along_x = Screw { origin: [0.; 3], axis: [1., 0., 0.], ratio: 0., advance: TAU };
let turn = Screw { origin: ARC_CENTRE, axis: up, ratio: 1. / ARC_RADIUS, advance: 0. };
let along_y = Screw { origin: [0.; 3], axis: [0., 1., 0.], ratio: 0., advance: TAU };
let bends = [FIRST, FIRST + FRAC_PI_2 * ARC_RADIUS];
let end = bends[1] + LAST;
let first = Trajectory::Twist(along_x);
let second = taken_up(turn, along_x.pose(bends[0]), bends[0]);
let left = second.pose(bends[1])?;
let third = taken_up(along_y, left, bends[1]);
let pieces = vec![Piece { over: [0., bends[0]], path: first },
Piece { over: bends, path: second },
Piece { over: [bends[1], end], path: third }];
// the kernel's path of pieces, checked to meet itself at each joinlet size = stock.size().max(tool.size());
let path = Trajectory::pieces(pieces, tolerance(size), size)?;
// the kernel's closed swept solid cut from the block on one arrangement, its pieces' sweeps// united: under each slide square to the mill's axis its round's top and bottom rings and its// meridians square to the slide, under the turn about an axis along its own its meridians in// the plane through both axescut_from(&stock, &tool, &path, [0., end], BAR, tolerance(size))
.map_err(|why| format!("the mill's sweep not built: {why:?}"))
}
Time
1.07 s; CPU time 1.07 s; peak memory 375.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 bull-nose mill run along a line, an arc and a line. A block, the box from (−10, −10, −10) to
(40, 40, 0), with a groove cut into its top by a bull-nose mill run along a path made of a line, an
arc and a line.
The mill is a solid of revolution about an upright axis: a cylinder of radius 2 from 1.5 below the
block's top up to 5 above it, whose bottom corner is rounded to radius 0.5. Its flat bottom is a
disc of radius 1.5 at z = −1.5, joined to its side (radius 2, from z = −1 up) by a quarter of a
torus whose tube, of radius 0.5, is centered on the circle of radius 1.5 at z = −1.
Its axis starts on the vertical line through (0, 0) and moves, staying upright, in three pieces:
- it slides along the x axis to (20, 0);
- it turns a quarter turn about the vertical line through (20, 10), right-handed (from −y toward
+x), carried rigidly, to (30, 10);
- it slides along +y to (30, 30).
Cut from the block everything the mill passes through.
The path is tangent where its pieces meet, and its arc, of radius 10, is wider than the mill. The
round's bottom circle stays in its plane, so the groove has a flat floor 3 wide."""fromOCP.BRepBuilderAPIimport (BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeFace,
BRepBuilderAPI_MakeWire)
fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeRevolfromOCP.GCimportGC_MakeArcOfCirclefromOCP.gp import gp, gp_Ax1, gp_Pnt
from sweep import cut, plane, shift, slid, turned
BLOCK = ((-10, -10, -10), (40, 40, 0))
RADIUS, ROUND = 2, 0.5BOTTOM, TOP = -1.5, 5FIRST = (20, 0, 0) # the first slidePIVOT = (20, 10) # the quarter turn is about the vertical line through this pointLAST = (0, 20, 0) # the last slidedefmill():
"""The mill about the z axis: its half-section beside the axis, in the plane y = 0, turned
about it. A flat bottom of radius 1.5, the quarter circle of radius 0.5 rounding its corner,
its side and its flat top."""
flat = RADIUS - ROUND
p = [gp_Pnt(0, 0, BOTTOM), gp_Pnt(flat, 0, BOTTOM), gp_Pnt(RADIUS, 0, BOTTOM + ROUND),
gp_Pnt(RADIUS, 0, TOP), gp_Pnt(0, 0, TOP)]
middle = gp_Pnt(flat + ROUND * 0.5 ** 0.5, 0, BOTTOM + ROUND - ROUND * 0.5 ** 0.5)
wire = BRepBuilderAPI_MakeWire()
wire.Add(BRepBuilderAPI_MakeEdge(p[0], p[1]).Edge())
wire.Add(BRepBuilderAPI_MakeEdge(GC_MakeArcOfCircle(p[1], middle, p[2]).Value()).Edge())
for a, b in ((2, 3), (3, 4), (4, 0)):
wire.Add(BRepBuilderAPI_MakeEdge(p[a], p[b]).Edge())
half = BRepBuilderAPI_MakeFace(wire.Wire()).Face()
returnBRepPrimAPI_MakeRevol(half, gp.OZ_s()).Shape()
defbuild():
tool = mill()
# A surface of revolution about the mill's upright axis meets a level slide square-on where# its normal lies in the plane through the axis square to the slide, and a turn about a# parallel axis where its normal lies in the plane through both axes: those planes cut the# mill's side and round along their contact. Its flat ends move in their own planes.
swept = slid(tool, FIRST, [plane((0, 0, 0), (1, 0, 0))])
at_turn = shift(tool, FIRST)
pivot = gp_Ax1(gp_Pnt(*PIVOT, 0), gp.DZ_s())
swept += turned(at_turn, pivot, 90, [plane(FIRST, (1, 0, 0))])
at_last = shift(tool, (PIVOT[0] + 10, PIVOT[1], 0))
swept += slid(at_last, LAST, [plane((PIVOT[0] + 10, PIVOT[1], 0), (0, 1, 0))])
returncut(BRepPrimAPI_MakeBox(gp_Pnt(*BLOCK[0]), gp_Pnt(*BLOCK[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
132 ms; CPU time 160 ms; peak memory 25.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 block, the box from (−10, −10, −10) to (40, 40, 0), grooved by a bull-nose mill run along a//! line, an arc and a line: upright, a cylinder of radius 2 from z = −1.5 to 5 whose bottom corner//! is rounded to 0.5, its axis carried from the vertical line through (0, 0) along x to (20, 0),//! a quarter turn about the vertical line through (20, 10) to (30, 10), and along y to (30, 30).//! Everything the mill passes through, cut.//!//! The mill is its half section revolved about its axis. Each of its three moves is kentron's//! sweep of a solid (`sweep::solid`): a slide, a turn and a slide, each from where the move//! before left the mill. Each is cut from the block in turn.usecrate::bench::{p, v};
usecrate::shared::parts::xz_plane;
usecrate::shared::swept::cut_each;
use kentron::math::{Axis, Direction};
use kentron::modify::{self, TransformOptions};
use kentron::primitives::Cuboid;
use kentron::sketch::{self, Outcome, Step};
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
use std::f64::consts::{FRAC_PI_2, TAU};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
useStep::{Arc, Start, To};
let block = Cuboid::from_corners(p(-10.0, -10.0, -10.0), p(40.0, 40.0, 0.0)).build(m)?;
// The mill: its half section, out from its axis (the flat bottom to 1.5, the round's quarter// circle about (1.5, −1), the side up to the top), turned whole about it.let half = [Start(0.0, -1.5), To(1.5, -1.5), Arc { radius: 0.5, angle: 90.0 }, To(2.0, 5.0), To(0.0, 5.0)];
let half = sketch::profile(m, xz_plane(0.0), &half, Outcome::Face)?;
letmut mill = sweep::revolve(m, half, Axis::Z, TAU)?.shape;
let moves = [
RigidMotion::Slide { by: v(20.0, 0.0, 0.0) },
RigidMotion::Turn { axis: Axis::new(p(20.0, 10.0, 0.0), Direction::Z), from: 0.0, to: FRAC_PI_2 },
RigidMotion::Slide { by: v(0.0, 20.0, 0.0) },
];
letmut sweeps = Vec::new();
for motion in &moves {
sweeps.push(sweep::solid(m, mill, motion)?);
mill = modify::transform(m, mill, &motion.at(1.0), TransformOptions::default())?;
}
cut_each(m, block, &sweeps)
}
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
798 ms; CPU time 798 ms; peak memory 56 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 block, the box from (−10, −10, −10) to (40, 40, 0), with a groove cut into its top by a//! bull-nose mill whose upright axis runs along x from (0, 0) to (20, 0), a quarter turn about the//! vertical line through (20, 10) to (30, 10), and along y to (30, 30). The mill is a cylinder of//! radius 2 from z = −1.5 to z = 5, its bottom corner rounded to radius 0.5.//!//! solidcraft-kernel has no sweep of a solid, so the mill's sweep is built by elementary geometry.//! The mill is a solid of revolution about its upright axis, so carried rigidly or slid it fills//! the same places, and at each height z it is a disc of radius R(z) whose centre runs along the//! path: it fills every point within R(z) of the path. A point within R(z) of the path whose//! nearest point on it is inside the path lies on the path's normal there, within R(z); one whose//! nearest point is an end lies in the half of the disc there beyond that end. So the sweep is the//! mill's section through its axis, square to the path, swept along the path (the kernel's//! `sweep`, which turns it with the path, keeping it upright along this flat path) with the half//! mill beyond each end.usecrate::solids::*;
use solidcore_record::Seg2;
use solidcraft_kernel::{PathSeg, sweep};
use std::f64::consts::{FRAC_PI_2, PI, TAU};
/// The mill's section through its axis, in (w, z): w across the axis, z up from the block's top.pubfnsection() -> Region2 {
let segs = vec![
Seg2::Line { a: v2(-1.5, -1.5), b: v2(1.5, -1.5) },
Seg2::Arc { center: v2(1.5, -1.0), radius: 0.5, start: -FRAC_PI_2, sweep: FRAC_PI_2 },
Seg2::Line { a: v2(2.0, -1.0), b: v2(2.0, 5.0) },
Seg2::Line { a: v2(2.0, 5.0), b: v2(-2.0, 5.0) },
Seg2::Line { a: v2(-2.0, 5.0), b: v2(-2.0, -1.0) },
Seg2::Arc { center: v2(-1.5, -1.0), radius: 0.5, start: PI, sweep: FRAC_PI_2 },
];
Region2 { outer: Loop2 { segs }, holes: vec![] }
}
/// The half of the mill whose axis is the vertical line through `foot` (on the block's top) on/// the side `outward` points to: its half section revolved about the axis, then halved.pubfnhalf_mill(foot: Vec3, outward: Vec3) -> R<Body> {
let half = Region2 {
outer: Loop2 {
segs: vec![
Seg2::Line { a: v2(0.0, -1.5), b: v2(1.5, -1.5) },
Seg2::Arc { center: v2(1.5, -1.0), radius: 0.5, start: -FRAC_PI_2, sweep: FRAC_PI_2 },
Seg2::Line { a: v2(2.0, -1.0), b: v2(2.0, 5.0) },
Seg2::Line { a: v2(2.0, 5.0), b: v2(0.0, 5.0) },
Seg2::Line { a: v2(0.0, 5.0), b: v2(0.0, -1.5) },
],
},
holes: vec![],
};
let plane = Plane { origin: foot, x: Vec3::X, y: Vec3::Z };
let mill = one(solidcraft_kernel::revolve(&plane, &[half], Vec2::ZERO, Vec2::Y, TAU)?)?;
let cap = Plane::from_normal(foot, outward)
.ok_or_else(|| KernelError::Invalid("the half mill's direction".into()))?;
solidcraft_kernel::half_space(&mill, &cap, true)?
.0
.ok_or_else(|| KernelError::Failed("the half mill is empty".into()))
}
pubfnbuild() -> R<Body> {
let stock = block((-10.0, -10.0, -10.0), (40.0, 40.0, 0.0))?;
let path = [
PathSeg::Line { a: v3(0.0, 0.0, 0.0), b: v3(20.0, 0.0, 0.0) },
// a quarter turn about +z, from −y toward +x of (20, 10)PathSeg::Arc { a: v3(20.0, 0.0, 0.0), center: v3(20.0, 10.0, 0.0), axis: Vec3::Z, angle: FRAC_PI_2 },
PathSeg::Line { a: v3(30.0, 10.0, 0.0), b: v3(30.0, 30.0, 0.0) },
];
// the section where the path starts, square to it (it leaves along +x), w along +ylet start = Plane { origin: Vec3::ZERO, x: Vec3::Y, y: Vec3::Z };
letmut swept = sweep(&start, §ion(), &path)?;
// the path leaves (0, 0) along +x and reaches (30, 30) along +yfor (foot, outward) in [(v3(0.0, 0.0, 0.0), -Vec3::X), (v3(30.0, 30.0, 0.0), Vec3::Y)] {
swept = union(&swept, &half_mill(foot, outward)?)?;
}
cut(&stock, &swept)
}
// A block from (-10, -10, -10) to (40, 40, 0) less everything a bull-nose mill (radius 2, its// bottom corner rounded to 0.5, from z = -1.5 up to 5, upright) passes through as its axis runs// from (0, 0) along x to (20, 0), a quarter turn about the vertical through (20, 10) to (30, 10),// and along y to (30, 30).//// The mill is a convex solid of revolution about its upright axis. Slid along a line it sweeps its// section through the axis square to the line, carried along it; turned about a parallel line it// sweeps that section in the half-plane through the turn's axis, revolved. And itself at each end.let m = model();
let k = 0.5 * sqrt(0.5);
fnsection(m, plane, c) {
m.profile(plane).path(c - 1.5, -1.5).line_to(c + 1.5, -1.5).arc_to([c + 1.5 + 0.5 * sqrt(0.5), -1.0 - 0.5 * sqrt(0.5)], [c + 2.0, -1.0])
.line_to(c + 2.0, 5.0).line_to(c - 2.0, 5.0).line_to(c - 2.0, -1.0)
.arc_to([c - 1.5 - 0.5 * sqrt(0.5), -1.0 - 0.5 * sqrt(0.5)], [c - 1.5, -1.5]).close()
}
fnmill(m, x, y) {
m.profile(xz()).path(0.0, -1.5).line_to(1.5, -1.5).arc_to([1.5 + 0.5 * sqrt(0.5), -1.0 - 0.5 * sqrt(0.5)], [2.0, -1.0])
.line_to(2.0, 5.0).line_to(0.0, 5.0).close().sketch("mill")
.revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), full_circle()).translate(x, y, 0.0)
}
let b = m.box(50.0, 50.0, 10.0, #{ at: [-10.0, -10.0, -10.0] });
b = b.subtract(m.tool(|m| section(m, yz(), 0.0).sketch("first").extrude(blind(20.0))));
// the turn's half-plane through (20, 10) toward -y holds the section about 10 out from it
b = b.subtract(m.tool(|m| section(m, xz(), 10.0).sketch("turn").revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), blind(90.0))
.rotate(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), -90.0).translate(20.0, 10.0, 0.0)));
b = b.subtract(m.tool(|m| section(m, xz_at(10.0), 30.0).sketch("last").extrude(blind(-20.0))));
for p in [[0.0, 0.0], [20.0, 0.0], [30.0, 10.0], [30.0, 30.0]] {
b = b.subtract(m.tool(|m| mill(m, p[0], p[1])));
}
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
145 ms; CPU time 145 ms; peak memory 23.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.
//! The block from (−10, −10, −10) to (40, 40, 0), less everything a bull-nose mill passes through//! as its upright axis slides from (0, 0) to (20, 0), turns a quarter turn about the upright line//! through (20, 10) to (30, 10), and slides on to (30, 30). The mill, about its axis: a flat bottom//! of radius 1.5 at z = −1.5, a quarter torus of tube radius 0.5 about the circle of radius 1.5 at//! z = −1, and a side of radius 2 up to z = 5.//!//! next.BREP's sweep of a solid builds a turn of a solid of revolution only where its ends stay//! clear of the region asked for, and takes no slide of one, nor a path of several pieces. What a//! path of pieces sweeps is the union of what each piece sweeps, and each follows by elementary//! geometry: an upright solid of revolution slid along a level line sweeps the tool at each end and//! its section through its axis, square to the slide, slid between them//! (`solids::swept::upright_slid`); turned about a parallel upright line it sweeps the tool at each//! end and its section by the half plane through both axes turned between them//! (`solids::swept::upright_turned`, here about (20, 10) from −90° to 0°). All of it is cut from//! the block.usecrate::solids::p;
usecrate::solids::sweep::moved;
usecrate::solids::swept::{slide, upright_slid, upright_turned, Meridian, Piece};
usecrate::Refusal;
use brep_kernel::{make_box_brep, BrepSolid};
use std::f64::consts::FRAC_PI_2;
pubfnbuild() -> Result<BrepSolid, Refusal> {
let block = make_box_brep(p(-10.0, -10.0, -10.0), 50.0, 50.0, 10.0)?;
let mill = Meridian(vec![
Piece::Line { from: [0.0, -1.5], to: [1.5, -1.5] },
Piece::Arc { centre: [1.5, -1.0], radius: 0.5, start: -FRAC_PI_2, end: 0.0 },
Piece::Line { from: [2.0, -1.0], to: [2.0, 5.0] },
Piece::Line { from: [2.0, 5.0], to: [0.0, 5.0] },
]);
// each piece's sweep; the tool where one piece stops and the next starts is kept onceletmut operands = upright_slid(&mill, p(0.0, 0.0, 0.0), p(20.0, 0.0, 0.0))?;
let turned = upright_turned(&mill, 10.0, -FRAC_PI_2, 0.0)?;
operands.push(moved(&turned[1], slide(p(20.0, 10.0, 0.0))?)?);
operands.extend(upright_slid(&mill, p(30.0, 10.0, 0.0), p(0.0, 20.0, 0.0))?);
letmut left = block;
for piece in &operands {
left = crate::solids::fillet::subtract(&left, piece)?;
}
Ok(left)
}
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
25 ms; CPU time 41 ms; peak memory 12.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 block (the box from (−10, −10, −10) to (40, 40, 0)) grooved by an upright bull-nose mill (a//! cylinder of radius 2 from z = −1.5 to 5, its bottom corner rounded to radius 0.5) run along a//! line from (0, 0) to (20, 0), a quarter turn about (20, 10) to (30, 10), and a line to (30, 30).//!//! An upright solid of revolution moved across in its own planes fills, at each height, the//! region within its radius there of the path: its section through its axis square to the path,//! carried along it upright (cadrs's Sweep along the path, the profile's plane kept holding the//! z axis), with the mill's halves beyond the path's ends (its half section turned half a turn,//! cadrs's Revolve). The groove is the block less the three.usecrate::bench::{arc, cut, p2, p3, revolve, v3};
usecrate::shared::geometry::Section;
usecrate::Refusal;
use cadrs_kernel::{Axis, BodyId, BodyKind, Curve2, DefaultKernel, Kernel, Loop, PathCurve, Plane, SweepControl, SweepSpec};
/// The mill's axial section in the plane through `foot` (on its axis at the block's top) square to/// `across` (horizontal): sketch x along `across`, sketch y up.fnsection(foot: crate::bench::P3, across: crate::bench::V3) -> Section {
let on = Plane::new(foot, across, across.cross(&v3(0.0, 0.0, 1.0)));
let w = 2f64.sqrt() / 2.0;
Section::on(on)
.line((-1.5, -1.5), (1.5, -1.5))
.conic((1.5, -1.5), (2.0, -1.5), w, (2.0, -1.0))
.line((2.0, -1.0), (2.0, 5.0))
.line((2.0, 5.0), (-2.0, 5.0))
.line((-2.0, 5.0), (-2.0, -1.0))
.conic((-2.0, -1.0), (-2.0, -1.5), w, (-1.5, -1.5))
}
/// The mill about the upright through `foot`, its half on the side of the plane through `foot`/// square to `ahead` that `ahead` points to: its half section turned half a turn about the/// upright (cadrs's Revolve), from the side square to `ahead` round through `ahead`.fnhalf_mill(k: &mutDefaultKernel, foot: crate::bench::P3, ahead: crate::bench::V3) -> Result<BodyId, Refusal> {
let up = v3(0.0, 0.0, 1.0);
// Sketch x out to the side (a quarter turn about the upright before `ahead`), sketch y up.let side = ahead.cross(&up);
let on = Plane::new(foot, side, side.cross(&up));
let w = 2f64.sqrt() / 2.0;
let half = Section::on(on)
.line((0.0, -1.5), (1.5, -1.5))
.conic((1.5, -1.5), (2.0, -1.5), w, (2.0, -1.0))
.line((2.0, -1.0), (2.0, 5.0))
.line((2.0, 5.0), (0.0, 5.0))
.line((0.0, 5.0), (0.0, -1.5));
revolve(k, &half.sketch(), Axis::new(foot, up), Some(180.0))
}
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let b = crate::bench::block(k, p3(-10.0, -10.0, -10.0), p3(40.0, 40.0, 0.0))?;
let path = Loop::new(vec![
Curve2::line(p2(0.0, 0.0), p2(20.0, 0.0)),
arc(p2(20.0, 10.0), 10.0, -90.0, 90.0),
Curve2::line(p2(30.0, 10.0), p2(30.0, 30.0)),
]);
let path: Vec<PathCurve> =
path.curves.into_iter().map(|c| PathCurve::Sketch { plane: Plane::xy(0.0), curve: c }).collect();
// The section square to the path where it starts (along +x): across it is +y.let profile = section(p3(0.0, 0.0, 0.0), v3(0.0, 1.0, 0.0)).sketch();
let spec = SweepSpec {
body: BodyKind::Solid,
path,
control: SweepControl::LockDirection(crate::bench::unit(v3(0.0, 0.0, 1.0))),
corners: Default::default(),
faces: vec![],
};
let swept = k.sweep_with(&profile, &spec)?.first()?;
let start = half_mill(k, p3(0.0, 0.0, 0.0), v3(-1.0, 0.0, 0.0))?;
let end = half_mill(k, p3(30.0, 30.0, 0.0), v3(0.0, 1.0, 0.0))?;
let b = cut(k, b, swept)?;
let b = cut(k, b, start)?;
cut(k, b, end)
}
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
73 ms; CPU time 72 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.
//! The box (−10, −10, −10)–(40, 40, 0) less everything a bull-nose mill passes through as its//! upright axis runs from (0, 0) along x to (20, 0), a quarter turn about the upright line through//! (20, 10) to (30, 10), and along y to (30, 30): a cylinder of radius 2 from z = −1.5 to 5, its//! bottom corner rounded to 0.5.use std::f64::consts::FRAC_PI_2;
use springrep::boolean::difference;
use springrep::math::Vec3;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{arc, boxed, line, outline, unite, upright, v3};
pubfnbuild() -> Result<Brep, String> {
let block = boxed([-10.0, -10.0, -10.0], [40.0, 40.0, 0.0], "block")?;
let meridian = outline(vec![
line((0.0, -1.5), (1.5, -1.5), "bottom"),
arc((1.5, -1.0), 0.5, -FRAC_PI_2, FRAC_PI_2, "round"),
line((2.0, -1.0), (2.0, 5.0), "side"),
line((2.0, 5.0), (0.0, 5.0), "top"),
line((0.0, 5.0), (0.0, -1.5), "axis"),
]);
// The path is three pieces, each swept on its own from where the mill stands as it starts.let first = upright(&meridian, 0.0, 0.0, "mill")?;
let second = upright(&meridian, 20.0, 0.0, "mill")?;
let third = upright(&meridian, 30.0, 10.0, "mill")?;
let bend = Motion::Turn {
origin: v3(20.0, 10.0, 0.0),
axis: Vec3::Z,
from: 0.0,
to: FRAC_PI_2,
};
let groove = unite(&[
&solid(&first, &Motion::Slide(v3(20.0, 0.0, 0.0)), "groove").map_err(e)?,
&solid(&second, &bend, "groove").map_err(e)?,
&solid(&third, &Motion::Slide(v3(0.0, 20.0, 0.0)), "groove").map_err(e)?,
])?;
difference(&block, &groove).map_err(e)
}
geomsolver left no solid to show.
Time
16.3 s; CPU time 24.8 s; peak memory 51.4 MB
Notes
refused error[E080]: `part`: less `straight_out` (C3: every cell the sweep's candidate faces split the blank into is read in or out of the sweep at a point clear of its boundary): the kernel could not build it: edge 82 near [31.5, 30.0, -0.5]: faces 108 and 104 (a cylinder and a torus) coincide along it
Workaround † no motion along a path of pieces: three sweeps, slid, turned and slid, each cut in turn
// A block, the box from (-10, -10, -10) to (40, 40, 0), its top in the top plane; an upright// bull-nose mill, its axis on the vertical line through (0, 0): radius 2 from its flat bottom at// z = -1.5 up to z = 5, the corner of its bottom rounded to 0.5, a turn of its half-section in the// front plane. Its axis moves, staying upright, along a path of three pieces in the top face,// tangent where they meet: it slides along the line from (0, 0) to (20, 0), turns a quarter turn// about the upright line through (20, 10) to (30, 10), and slides on along the line to (30, 30);// everything the mill passes through in each piece is cut from the block.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (slides, turns)
in std.top {
a := point
b := point hint((40, -10))
c := point hint((40, 40))
d := point hint((-10, 40))
outline := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((-10, -10)) a
a distance(50) b
b distance(50) c
// the path, a line, an arc and a line, each tangent to the next
p0 := point
p1 := point hint((20, 0))
k := point
p2 := point hint((30, 10))
p3 := point hint((30, 30))
fix((0, 0)) p0
fix((20, 10)) k
p0 distance(20) p1
p2 distance(20) p3
route := horizontal (run_in := line(p0, p1)) -> tangent
(bend := arc(center: k, start: p1, end: p2)) -> tangent
vertical (run_out := line(p2, p3))
radius(10) bend
}
part := solid(std.solids.Prism(outline, from: -10mm, to: 0mm))
in std.front {
e0 := point
q := point hint((2, -1.5))
e2 := point hint((2, 5))
e3 := point hint((0, 5))
fix((0, -1.5)) e0
e0 distance(2) q
fix((0, 5)) e3
// the side meets the flat bottom at q, the corner rounded to 0.5
half := horizontal line(e0, q) -> round(r: 0.5mm) vertical line(q, e2) ->
horizontal line(e2, e3) -> vertical (spindle := line(e3, e0)) -> close
}
mill := solid(std.solids.Revolution(half, about: spindle))
// the motion in its three pieces, each carrying the mill on from where the last left it: a slide// along the first line, a quarter turn about the upright line through the arc's centre, a slide// along the last line
k_above := point
fix((20, 10, 1)) k_above
pivot := line(k, k_above)
first := frame
first slides(20mm) run_in
turn := frame
turn turns(1) pivot
last := frame
last slides(20mm) run_out
at_bend := mill at(under: first) 360deg
past_bend := at_bend at(under: turn) 90deg
straight_in := solid({ p | some t in (0deg, 360deg): p in mill at(under: first) t })
round_bend := solid({ p | some t in (0deg, 90deg): p in at_bend at(under: turn) t })
straight_out := solid({ p | some t in (0deg, 360deg): p in past_bend at(under: last) t })
straight_in cut part
round_bend cut part
straight_out cut part
anvilcad left no solid to show.
Time
281 ms; CPU time 280 ms; peak memory 5.7 MB
Notes
refused boolean operation failed: the result is not a closed solid (edge DVec3(32.0, 30.0, -0.9999999999999999) -> DVec3(31.5, 30.0, -1.5) used 1/0 by ["s0f17"])
//! A block from (−10, −10, −10) to (40, 40, 0) less what an upright bull-nose mill (radius 2, its//! corner rounded 0.5, its flat end at z = −1.5) passes through, its axis moved from (0, 0) along//! x to (20, 0), a quarter turn about (20, 10) to (30, 10), and along y to (30, 30).use std::f64::consts::{FRAC_PI_2, PI};
use anvil_brep::profile::{Loop2, Segment};
use anvil_brep::sweep::{PathSegment, sweep};
use anvil_brep::Solid;
usecrate::shared::{block, cut_all, e, frame, line, one, region, revolved, v2, v3};
pubfnbuild() -> Result<Solid, String> {
// the mill: its half section turned about its axislet mill = |x: f64, y: f64| -> Result<Solid, String> {
let m = revolved(vec![
line(v2(0., -1.5), v2(1.5, -1.5)),
Segment::Arc { center: v2(1.5, -1.), radius: 0.5, start: -FRAC_PI_2, sweep: FRAC_PI_2 },
line(v2(2., -1.), v2(2., 5.)),
line(v2(2., 5.), v2(0., 5.)),
line(v2(0., 5.), v2(0., -1.5)),
])?;
Ok(m.transformed(&crate::shared::at([x, y, 0.])))
};
// anvil-brep has no sweep of a solid. Upright and moving level along a path that turns no// tighter than its radius, the mill sweeps its own section carried square to the path, and// itself where it starts and stopslet path = [
PathSegment::Line { a: v3(0., 0., 0.), b: v3(20., 0., 0.) },
PathSegment::Arc { center: v3(20., 10., 0.), axis: v3(0., 0., 1.), start: v3(20., 0., 0.), angle: FRAC_PI_2 },
PathSegment::Line { a: v3(30., 10., 0.), b: v3(30., 30., 0.) },
];
// the section square to the path at its start, which runs along +x: its sketch x along world y// and its sketch y along world zlet start = frame([0., 0., 0.], [1., 0., 0.], [0., 1., 0.])?;
let section = Loop2::new(vec![
line(v2(-2., 5.), v2(-2., -1.)),
Segment::Arc { center: v2(-1.5, -1.), radius: 0.5, start: PI, sweep: FRAC_PI_2 },
line(v2(-1.5, -1.5), v2(1.5, -1.5)),
Segment::Arc { center: v2(1.5, -1.), radius: 0.5, start: -FRAC_PI_2, sweep: FRAC_PI_2 },
line(v2(2., -1.), v2(2., 5.)),
line(v2(2., 5.), v2(-2., 5.)),
]);
let groove = one(sweep(&start, ®ion(&[section])?, &path).map_err(e)?)?;
cut_all(block([-10., -10., -10.], [40., 40., 0.])?, [Ok(groove), mill(0., 0.), mill(30., 30.)])
}