A block, the box from (−6, −6, −8) to (36, 26, 0), with a groove cut into its top by a leaning bull-nose mill carried along a spline.
The curve is the cubic Bézier curve in the plane z = 0 whose control points are (0, 0, 0), (10, 0, 0), (20, 20, 0) and (30, 20, 0), run from its first end to its last.
A frame rides along the curve: at each point its origin is the curve's point, its x axis the curve's tangent there (pointing the way the curve runs), its z axis straight up and its y axis to the left, so that at the curve's start it is the world's own frame. The tool is drawn in that starting frame and carried rigidly by the frame as it runs the whole curve.
The mill, so drawn, is a solid of revolution about an axis leaning 30° from upright toward +x (the way the curve sets out), along a = (sin 30°, 0, cos 30°), through c = (0, 0, −1), the middle of its flat end, 1 below the block's top. Along its axis it runs from c up to c + 3a: a cylinder of radius 2 whose end corner is rounded to radius 0.5 (its flat end a disc of radius 1.5 about c, its side of radius 2 from c + 0.5a to c + 3a, and between them a quarter of a torus of tube radius 0.5 centered on the circle of radius 1.5 about c + 0.5a).
Cut from the block everything the mill passes through as the frame runs the whole curve.
The frame turns the mill as the curve turns, so no screw carries it: the curve along which the mill touches what it sweeps moves on the mill from instant to instant.
expected
closed form
volume
10507.58641
no closed form: cad-kernel and cadrs agree to 4e-10; the mean of their values
area
3968.625732
no closed form: cad-kernel and cadrs agree to 1e-9; the mean of their values
Drawing
TopIsometricFrontRight
Third-angle projection, the three views at one scale. Drawn from next.BREP'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.2 s; CPU time 38.7 s; peak memory 140.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.
Data
its STEP's
expected
rel. error
volume
10507.58642
10507.58641
1.8e-10
area
3968.625734
3968.625732
4.9e-10
agrees with
next.BREP, cadrs, springrep, geomsolver
mesh
37394 triangles, closed
centre of gravity
(14.983, 9.98937, -4.07459) its STEP's solid
inertia
about it, of unit density: Ixx 960177; Iyy 1.61613e+06; Izz 2.46688e+06; Ixy 14765.9; Iyz 349.112; Izx 561.994
//! A block, the box (−6, −6, −8)–(36, 26, 0), with a groove cut into its top by a leaning bull-nose//! mill carried by a frame riding the cubic Bézier curve (0, 0, 0), (10, 0, 0), (20, 20, 0),//! (30, 20, 0): its origin the curve's point, its x the curve's tangent, its z up, the world's own//! frame at the start. The mill, drawn in that frame, stands about the axis through c = (0, 0, −1)//! along a = (sin 30°, 0, cos 30°), from c to c + 3a: radius 2, its end corner rounded to 0.5.//!//! The motion turns the mill as the curve turns: no slide, turn or screw, nor a path of them, so a//! motion the kernel reads by evaluating it (`Trajectory::General`, its K2 road), the frame read//! off the kernel's own B-spline.usecrate::sketch::block;
use cad_kernel::build::{revolve, Profile, ProfileEdge};
use cad_kernel::geom::{tolerance, Frame, V};
use cad_kernel::nurbs::BSpline;
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Motion, Path, Stretch, Trajectory};
use cad_kernel::util::interval::Interval;
use cad_kernel::util::space::{add, cross, dot, norm, scale, sub};
use cad_kernel::KernelError;
use std::f64::consts::{FRAC_PI_2, TAU};
use std::sync::Arc;
constSTOCK_LO: V = [-6., -6., -8.];
constSTOCK_HI: V = [36., 26., 0.];
constCONTROL: [V; 4] = [[0., 0., 0.], [10., 0., 0.], [20., 20., 0.], [30., 20., 0.]];
/// The middle of the mill's flat end, and how far its axis leans from upright toward +x, in/// degrees.constEND: V = [0., 0., -1.];
constLEAN: f64 = 30.;
constRADIUS: f64 = 2.;
constCORNER: f64 = 0.5;
constLENGTH: f64 = 3.;
/// 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 bull-nose mill about the axis through `c` along the unit `a`, `e` a unit direction square/// to it: its meridian in the half-plane from the axis toward `e` — out along its flat end, round/// the quarter circle of its corner, up its side, back across its top and down its axis — turned/// once about the axis.fnmill(c: V, a: V, e: V) -> Result<Brep, String> {
let at = |r: f64, h: f64| add(add(c, scale(e, r)), scale(a, h));
let corner = Frame::new(at(RADIUS - CORNER, CORNER), cross(e, a), e);
let edges = vec![
ProfileEdge::Line { a: at(0., 0.), b: at(RADIUS - CORNER, 0.) },
ProfileEdge::Arc { frame: corner, r: CORNER, span: Some([-FRAC_PI_2, 0.]) },
ProfileEdge::Line { a: at(RADIUS, CORNER), b: at(RADIUS, LENGTH) },
ProfileEdge::Line { a: at(RADIUS, LENGTH), b: at(0., LENGTH) },
ProfileEdge::Line { a: at(0., LENGTH), b: at(0., 0.) },
];
let meridian = Profile { origin: c, normal: cross(a, e), loops: vec![edges],
names: Vec::new() };
revolve(&meridian, c, a, TAU)
}
/// The frame riding the curve: at `t` its origin the curve's point, its x the unit tangent, its z/// up and its y = z × x, and their rates — the tangent's the curve's acceleration square to it/// over its speed.#[derive(Debug)]structRiding(BSpline);
implPathforRiding {
fnat(&self, t: f64) -> Result<Motion, KernelError> {
let (point, rate, acceleration) = self.0.d2(t);
let speed = norm(rate);
if !(speed > 0.) { returnErr(format!("the curve stands still at {t}").into()) }
let x = scale(rate, 1. / speed);
let dx = scale(sub(acceleration, scale(x, dot(x, acceleration))), 1. / speed);
let up = [0., 0., 1.];
let (y, dy) = (cross(up, x), cross(up, dx));
// the turn's columns are the frame's axeslet r = [[x[0], y[0], up[0]], [x[1], y[1], up[1]], [x[2], y[2], up[2]]];
let dr = [[dx[0], dy[0], 0.], [dx[1], dy[1], 0.], [dx[2], dy[2], 0.]];
Ok(Motion::of_parts(r, dr, point, rate))
}
/// What the motion does over any stretch, enclosed, as the kernel's membership reads its speed/// bound: the frame's origin within the poles' box (a Bézier curve lies in its control/// polygon's hull); its turn's entries within ±1 but the upright's; its speed within the/// longest of the hodograph's poles; its spin, the tangent's turning rate `|B′ × B″| / |B′|²`,/// within the longest of the second hodograph's poles over the least the rate reaches along/// the hodograph poles' mean direction (each rate a weighted mean of them).fnstretch(&self, _: f64, _: f64) -> Option<Stretch> {
let h = hodograph();
let along = h.iter().fold([0.; 3], |s, &p| add(s, p));
let least = h.iter().map(|&p| dot(p, along) / norm(along)).fold(f64::INFINITY, f64::min);
if !(least > 0.) { returnNone }
let bend = (0..2).map(|i| norm(scale(sub(h[i + 1], h[i]), 2.))).fold(0., f64::max);
let speed = h.iter().map(|&p| norm(p)).fold(0., f64::max);
let (unit, zero, one) = (Interval::new(-1., 1.).ok()?, Interval::point(0.).ok()?,
Interval::point(1.).ok()?);
let turn = [[unit, unit, zero], [unit, unit, zero], [zero, zero, one]];
Some(Stretch { point: hull(&CONTROL)?, turn, speed, spin: bend / least, origin: [0.; 3] })
}
}
/// The box holding `points`, as intervals.fnhull(points: &[V]) -> Option<[Interval; 3]> {
let side = |k: usize| {
let (lo, hi) = points.iter().fold((f64::INFINITY, f64::NEG_INFINITY),
|(lo, hi), p| (lo.min(p[k]), hi.max(p[k])));
Interval::new(lo, hi).ok()
};
Some([side(0)?, side(1)?, side(2)?])
}
/// The Bézier curve's hodograph's poles, `3 (P[i+1] − P[i])`: its rate is a weighted mean of them.fnhodograph() -> [V; 3] {
std::array::from_fn(|i| scale(sub(CONTROL[i + 1], CONTROL[i]), 3.))
}
pubfnbuild() -> Result<Brep, String> {
let stock = block(STOCK_LO, STOCK_HI)?;
let (s, c) = LEAN.to_radians().sin_cos();
let tool = mill(END, [s, 0., c], [c, 0., -s])?;
// the curve as cad-kernel holds a Bézier segment: a cubic B-spline on clamped knotslet knots = vec![0., 0., 0., 0., 1., 1., 1., 1.];
let curve = BSpline::new(3, knots, CONTROL.to_vec())?;
let path = Trajectory::General(Arc::new(Riding(curve)));
// the kernel's closed swept solid cut from the block on one arrangement: the sheet each// instant's contact sweeps, fitted, and the mill where it starts and where it stopslet size = stock.size().max(tool.size());
cut_from(&stock, &tool, &path, [0., 1.], BAR, tolerance(size))
.map_err(|why| format!("the mill's sweep not built: {why:?}"))
}
occt left no solid to show.
Time
621 ms; CPU time 621 ms; peak memory 356.7 MB
Notes
refused occt has no sweep of a solid, and the curve along which the leaning mill touches what it sweeps moves over it as the curve's curvature changes, so no fixed split of its faces sweeps without folding; the groove's wall is the envelope of the mill, which occt cannot find
"""A leaning bull-nose mill carried along a spline. A block, the box from (−6, −6, −8) to (36, 26,
0), with a groove cut into its top by a leaning bull-nose mill carried along a spline.
The curve is the cubic Bézier curve in the plane z = 0 whose control points are (0, 0, 0), (10, 0,
0), (20, 20, 0) and (30, 20, 0), run from its first end to its last.
A frame rides along the curve: at each point its origin is the curve's point, its x axis the
curve's tangent there (pointing the way the curve runs), its z axis straight up and its y axis to
the left, so that at the curve's start it is the world's own frame. The tool is drawn in that
starting frame and carried rigidly by the frame as it runs the whole curve.
The mill, so drawn, is a solid of revolution about an axis leaning 30° from upright toward +x (the
way the curve sets out), along a = (sin 30°, 0, cos 30°), through c = (0, 0, −1), the middle of its
flat end, 1 below the block's top. Along its axis it runs from c up to c + 3a: a cylinder of radius
2 whose end corner is rounded to radius 0.5 (its flat end a disc of radius 1.5 about c, its side of
radius 2 from c + 0.5a to c + 3a, and between them a quarter of a torus of tube radius 0.5 centered
on the circle of radius 1.5 about c + 0.5a).
Cut from the block everything the mill passes through as the frame runs the whole curve.
The frame turns the mill as the curve turns, so no screw carries it: the curve along which the mill
touches what it sweeps moves on the mill from instant to instant."""from bench importRefuseddefbuild():
# The frame turns the leaning mill as the curve turns: at each instant the mill moves by a# slide along the curve's tangent and a turn about the upright line through the curve's# point, at the curve's curvature, which changes along the curve. The mill's axis leans# off that line, so the curve along which each of its faces touches what it sweeps depends# on the curvature: it moves over the mill from instant to instant. OCCT sweeps a face along# a path (BRepOffsetAPI_MakePipeShell) only whole, and a face swept whole that the motion# runs along inside folds; there is no fixed curve to split it along, and the wall is the# envelope of the mill, which occt has no operation to find.raiseRefused("occt has no sweep of a solid, and the curve along which the leaning mill ""touches what it sweeps moves over it as the curve's curvature changes, so no ""fixed split of its faces sweeps without folding; the groove's wall is the ""envelope of the mill, which occt cannot find")
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.
kentron left no solid to show.
Time
2.9 ms; CPU time 2.6 ms; peak memory 8.5 MB
Notes
refused invalid input: a motion under which where it grazes the tool moves over it: its envelope is no product of a curve and the motion
//! A block, the box from (−6, −6, −8) to (36, 26, 0), grooved by a leaning bull-nose mill carried//! along a spline: about the axis through c = (0, 0, −1) along (sin 30°, 0, cos 30°), from c up 3,//! a cylinder of radius 2 whose end corner is rounded to 0.5, in a frame carried along the cubic//! Bézier curve through (0, 0, 0), (10, 0, 0), (20, 20, 0) and (30, 20, 0), its x axis the//! curve's tangent and its z axis up.//!//! The motion is given by its places (`sweep::RigidMotion::Carried`) for kentron's sweep of a//! solid (`sweep::solid`), which refuses it: as the frame turns, the curves where the mill's//! round and side touch what it sweeps move over them, so the groove's walls are no product of a//! fixed curve and the motion, and kentron's sweep builds only those.usecrate::bench::{d, frame, p};
usecrate::shared::swept::{bezier_frame, bull_nose};
use kentron::math::{Axis, Transform, Vector};
use kentron::primitives::Cuboid;
use kentron::sweep::{self, Carriage, RigidMotion};
use kentron::topology::{Model, Shape};
use std::sync::Arc;
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let block = Cuboid::new(42.0, 32.0, 8.0).with_frame(frame(p(-6.0, -6.0, -8.0), d(0.0, 0.0, 1.0))).build(m)?;
let place = Transform::translation(Vector::new(0.0, 0.0, -1.0)) * Transform::rotation(Axis::Y, 30f64.to_radians());
let mill = bull_nose(m, &place)?;
let swept = sweep::solid(m, mill, &RigidMotion::Carried(Carriage(Arc::new(bezier_frame))))?;
kentron::boolean::difference(m, block, 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.
solidcraft left no solid to show.
Time
1.8 ms; CPU time 1.6 ms; peak memory 4.6 MB
Notes
refused no layer (solidcraft-kernel, solidcore-ops, solidcore) has a sweep of a solid or an envelope: the leaning mill turns with the curve, so the groove's walls are the envelope of its side and round over the motion, which no plane section of it swept along the curve makes
//! Refused. The bull-nose mill leans 30° from upright and is carried by a frame that turns with//! the curve's tangent, so it turns relative to its own axis as it goes: no screw or turn about//! its axis carries it, and the groove's walls are the envelope of the leaning mill's side and//! round over the motion, touching it along a curve that moves on it from instant to instant.//! solidcraft-kernel has no sweep of a solid and no envelope, and its sweeps of a profile carry a//! plane section along the path, none of which is that envelope; computed here it would be//! geometry made outside the kernel.usecrate::Refusal;
usecrate::solids::Body;
pubfnbuild() -> Result<Body, Refusal> {
Err("no layer (solidcraft-kernel, solidcore-ops, solidcore) has a sweep of a solid or an envelope: the leaning mill turns with the \
curve, so the groove's walls are the envelope of its side and round over the motion, \
which no plane section of it swept along the curve makes"
.into())
}
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
3.8 ms; CPU time 3.6 ms; peak memory 11.7 MB
Notes
refused popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly
// A leaning bull-nose mill carried along a spline.//// Refused: popkern has no sweep of a solid (its sweeps carry a profile along a path), and the// envelope this motion leaves is not one its extrudes, revolves and booleans make exactly: the// tool is not symmetric about the planes of its motion, or the motion is a screw or a curve.throw"popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly";
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
663 ms; CPU time 663 ms; peak memory 88.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.
Data
its STEP's
expected
rel. error
volume
10507.58641
10507.58641
5.2e-11
area
3968.625735
3968.625732
6.3e-10
agrees with
cad-kernel, cadrs, springrep, geomsolver
mesh
37474 triangles, closed
centre of gravity
(14.983, 9.98937, -4.07459) its STEP's solid
inertia
about it, of unit density: Ixx 960177; Iyy 1.61613e+06; Izz 2.46688e+06; Ixy 14765.9; Iyz 349.112; Izx 561.994
//! A block grooved by a leaning bull-nose mill carried along a spline.//!//! Through the kernel's whole sweep of a solid carried by a frame along a curve//! (`sweep_solid_along`): the curve is the cubic Bézier (0, 0, 0), (10, 0, 0), (20, 20, 0),//! (30, 20, 0), the frame's up the z axis; the mill, drawn in the frame at the curve's start, is a//! solid of revolution about the line through (0, 0, −1) along (sin 30°, 0, cos 30°), its meridian//! the flat end out to 1.5, the quarter circle of radius 0.5 about (1.5, 0.5), the side at 2 up to//! 3 and the flat top; cut from the block, the box from (−6, −6, −8) to (36, 26, 0).usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{
boolean_operation_nary, make_box_brep, sweep_solid_along, BooleanOperation, BrepSolid, FrameCurve, OutlinePiece, SolidTool,
};
use std::f64::consts::FRAC_PI_2;
pubfnbuild() -> Result<BrepSolid, Refusal> {
let block = make_box_brep(p(-6.0, -6.0, -8.0), 42.0, 32.0, 8.0)?;
let lean = 30f64.to_radians();
let mill = SolidTool::Revolved {
axis_origin: p(0.0, 0.0, -1.0),
axis_direction: p(lean.sin(), 0.0, lean.cos()),
radial: p(lean.cos(), 0.0, -lean.sin()),
meridian: vec![
OutlinePiece::Line { from: [0.0, 0.0], to: [1.5, 0.0] },
OutlinePiece::Arc { centre: [1.5, 0.5], radius: 0.5, start: -FRAC_PI_2, end: 0.0 },
OutlinePiece::Line { from: [2.0, 0.5], to: [2.0, 3.0] },
OutlinePiece::Line { from: [2.0, 3.0], to: [0.0, 3.0] },
OutlinePiece::Line { from: [0.0, 3.0], to: [0.0, 0.0] },
],
};
let path = FrameCurve {
control: [p(0.0, 0.0, 0.0), p(10.0, 0.0, 0.0), p(20.0, 20.0, 0.0), p(30.0, 20.0, 0.0)],
up: p(0.0, 0.0, 1.0),
};
let swept = sweep_solid_along(&mill, &path)?;
Ok(boolean_operation_nary(&[block, swept], BooleanOperation::Subtract)?)
}
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
148 ms; CPU time 456 ms; peak memory 12.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.
Data
its STEP's
expected
rel. error
volume
10507.58642
10507.58641
2.8e-10
area
3968.625734
3968.625732
5.7e-10
agrees with
cad-kernel, next.BREP, springrep, geomsolver
mesh
25230 triangles, closed
centre of gravity
(14.983, 9.98937, -4.07459) its STEP's solid
inertia
about it, of unit density: Ixx 960177; Iyy 1.61613e+06; Izz 2.46688e+06; Ixy 14765.9; Iyz 349.112; Izx 561.994
//! A block (the box from (−6, −6, −8) to (36, 26, 0)) grooved by a bull-nose mill leaning 30°//! toward +x (a cylinder of radius 2 along a = (sin 30°, 0, cos 30°) from c = (0, 0, −1) to c + 3a,//! its end corner rounded to radius 0.5, in the frame riding the curve) carried along the cubic//! Bézier curve on (0, 0, 0), (10, 0, 0), (20, 20, 0), (30, 20, 0) by a frame along its tangent,//! upright.//!//! The mill is its half section turned about its axis; what it passes through is cadrs's sweep of//! a solid along a path (exact: the four sheets of the mill's envelope, closed by the mill's own//! faces where it starts and stops), cut from the block.usecrate::bench::{block, cut, p3, v3};
usecrate::shared::geometry::Section;
usecrate::shared::swept::{bezier_path, carried};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel, Plane};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let b = block(k, p3(-6.0, -6.0, -8.0), p3(36.0, 26.0, 0.0))?;
let a = v3(30f64.to_radians().sin(), 0.0, 30f64.to_radians().cos());
let c = p3(0.0, 0.0, -1.0);
let radial = v3(1.0, 0.0, 0.0) - a * a.x;
let on = Plane::new(c, radial, radial.cross(&a));
let section = Section::on(on)
.line((0.0, 0.0), (1.5, 0.0))
.conic((1.5, 0.0), (2.0, 0.0), 2f64.sqrt() / 2.0, (2.0, 0.5))
.line((2.0, 0.5), (2.0, 3.0))
.line((2.0, 3.0), (0.0, 3.0))
.line((0.0, 3.0), (0.0, 0.0));
let mill = section.turned(k, c, a)?;
let path = bezier_path([(0.0, 0.0), (10.0, 0.0), (20.0, 20.0), (30.0, 20.0)]);
let swept = carried(k, mill, path)?;
cut(k, b, 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.51 s; CPU time 4.50 s; peak memory 171.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.
Data
its STEP's
expected
rel. error
volume
10507.58642
10507.58641
1.8e-10
area
3968.625734
3968.625732
4.8e-10
agrees with
cad-kernel, next.BREP, cadrs, geomsolver
mesh
30702 triangles, closed
centre of gravity
(14.983, 9.98937, -4.07459) its STEP's solid
inertia
about it, of unit density: Ixx 960177; Iyy 1.61613e+06; Izz 2.46688e+06; Ixy 14765.9; Iyz 349.112; Izx 561.994
//! The box (−6, −6, −8)–(36, 26, 0) less everything a bull-nose mill leaning 30° passes through//! as a frame riding a cubic Bézier curve carries it, turning with the curve's tangent.use std::f64::consts::PI;
use springrep::boolean::difference;
use springrep::profile::Profile;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{arc, boxed, carried, deg, line, outline, revolved, v3};
/// The bull-nose mill's half meridian, drawn out from its axis and along it from its flat end's/// middle: flat to 1.5, a round of radius 0.5, a side of radius 2 up to 3.fnbull_nose() -> Profile {
outline(vec![
line((0.0, 0.0), (1.5, 0.0), "end"),
arc((1.5, 0.5), 0.5, -PI / 2.0, PI / 2.0, "round"),
line((2.0, 0.5), (2.0, 3.0), "side"),
line((2.0, 3.0), (0.0, 3.0), "top"),
line((0.0, 3.0), (0.0, 0.0), "axis"),
])
}
pubfnbuild() -> Result<Brep, String> {
let stock = boxed([-6.0, -6.0, -8.0], [36.0, 26.0, 0.0], "block")?;
let (s, c) = deg(30.0).sin_cos();
let mill = revolved(
&bull_nose(),
v3(0.0, 0.0, -1.0),
v3(s, 0.0, c),
v3(c, 0.0, -s),
"mill",
)?;
let swept = solid(&mill, &carried()?, "carried").map_err(e)?;
difference(&stock, &swept).map_err(e)
}
Time
12.6 s; CPU time 17.2 s; peak memory 63.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.
Data
its STEP's
expected
rel. error
volume
10507.58642
10507.58641
2.0e-10
area
3968.625734
3968.625732
5.3e-10
agrees with
cad-kernel, next.BREP, cadrs, springrep
mesh
27674 triangles, closed
centre of gravity
(14.983, 9.98937, -4.07459) its STEP's solid
inertia
about it, of unit density: Ixx 960177; Iyy 1.61613e+06; Izz 2.46688e+06; Ixy 14765.9; Iyz 349.112; Izx 561.994
// A block, the box from (-6, -6, -8) to (36, 26, 0), its top in the top plane; a bull-nose mill// leaning 30 degrees toward +x, drawn where the cubic Bezier through (0, 0), (10, 0), (20, 20) and// (30, 20) starts, carried rigidly by a frame riding the curve (its x the tangent, its z upright),// and everything the mill passes through cut from the block. The mill is a turn of its// half-section, drawn in the plane through its axis: radius 2 from the middle of its flat end at// (0, 0, -1) up to 3 along the axis, the corner of its end rounded to 0.5.unit mm
use std
use std.solids
use std.solids (cut)
use std.stations
in std.top {
a := point
b := point hint((36, -6))
c := point hint((36, 26))
d := point hint((-6, 26))
outline := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((-6, -6)) a
a distance(42) b
b distance(32) c
k0 := point
k1 := point hint((10, 0))
k2 := point hint((20, 20))
k3 := point hint((30, 20))
fix((0, 0)) k0
fix((10, 0)) k1
fix((20, 20)) k2
fix((30, 20)) k3
route := spline(k0, k1, k2, k3)
}
part := solid(std.solids.Prism(outline, from: -8mm, to: 0mm))
// the mill's axis leans 30 degrees from upright, turned about y from z toward x; its section is// drawn in the plane through that axis and the x direction, square to y
axle := axis hint(dir: (0.5, 0, 0.866))
axle perpendicular std.y
std.z angle(30deg, about: std.y) axle
across := axis hint(dir: (0.866, 0, -0.5))
across perpendicular std.y
std.x angle(30deg, about: std.y) across
bench := plane(u: across, v: axle)
fix(origin == (0, 0, -1)) bench
in bench {
e0 := point
q := point hint((2, 0))
e2 := point hint((2, 3))
e3 := point hint((0, 3))
fix((0, 0)) e0
e0 distance(2) q
e0 distance(3) e3
// the side meets the flat end at q, the corner rounded to 0.5
section := 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(section, about: spindle))
along := std.stations.Along(route, up: std.z)
groove := solid({ p | some t in (0rad, 1rad): p in mill at(under: along.f) t })
groove cut part
anvilcad left no solid to show.
Time
1.4 ms; CPU time 1.2 ms; peak memory 3.4 MB
Notes
refused anvil-brep has no sweep of a solid, and no spline curve to carry anything along: its sweeps follow lines and arcs only
//! A leaning bull-nose mill carried along a spline.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid, and no spline curve to carry anything along: its sweeps follow lines and arcs only".into())
}