A block, the box from (−6, −6, −8) to (36, 26, 0), with a groove cut into its top by a square key 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 key, so drawn, is the box from (−1.5, −0.8, −1.5) to (1.5, 0.8, 2.5): 3 long along the curve, 1.6 across it, its bottom 1.5 below the block's top.
Cut from the block everything the key passes through as the frame runs the whole curve.
The key turns as the curve turns, so no screw carries it, and it is no solid of revolution: its contact changes from face to face and edge to edge along the way, and its corners dig past its sides where the curve bends.
expected
closed form
volume
10652.87999
no closed form: OCCT and cadrs give the same volume to the twelve figures the board publishes
area
3996.725031
no closed form: OCCT and cadrs agree to 2e-11; the mean of their values
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
446 ms; CPU time 910 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.
Data
its STEP's
expected
rel. error
volume
10652.87999
10652.87999
2.0e-12
area
3996.725031
3996.725031
2.6e-12
agrees with
occt, next.BREP, cadrs, springrep
mesh
129924 triangles, closed
centre of gravity
(15, 10, -4.03024) its STEP's solid
inertia
about it, of unit density: Ixx 968787; Iyy 1.62863e+06; Izz 2.48488e+06; Ixy 6304.18; Iyz 7.31034e-12; Izx 6.61192e-11
//! A block, the box (−6, −6, −8)–(36, 26, 0), with a groove cut into its top by a square key, the//! box (−1.5, −0.8, −1.5)–(1.5, 0.8, 2.5) drawn in a frame that rides along the cubic Bézier curve//! (0, 0, 0), (10, 0, 0), (20, 20, 0), (30, 20, 0) — its x axis the curve's tangent, its z axis up//! — and carried rigidly by it over the whole curve.//!//! The riding frame is the kernel's own frame carried along a curve (`trajectory::Along`, the//! rotation-minimising one: along a curve in the plane z = 0 it keeps z up and its x axis the//! tangent, which at the curve's start is the world's x). The motion keeps the plane z = 0, so//! `swept::closed::cut_from` takes the planar road (`swept::planar_solid`) and cuts the key's//! sweep from the block.usecrate::sketch::block;
use cad_kernel::geom::{tolerance, V};
use cad_kernel::nurbs::BSpline;
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Along, Trajectory};
use std::sync::Arc;
constCONTROL: [V; 4] = [[0., 0., 0.], [10., 0., 0.], [20., 20., 0.], [30., 20., 0.]];
pubfnbuild() -> Result<Brep, String> {
let stock = block([-6., -6., -8.], [36., 26., 0.])?;
let key = block([-1.5, -0.8, -1.5], [1.5, 0.8, 2.5])?;
// the curve as cad-kernel holds a Bézier segment: a cubic B-spline on clamped knots, run over// [0, 1]; the frame's home is its start, where the riding frame is the world's ownlet curve = BSpline::new(3, vec![0., 0., 0., 0., 1., 1., 1., 1.], CONTROL.to_vec())?;
let path = Trajectory::General(Arc::new(Along::new(curve)?));
let size = stock.size().max(key.size());
cut_from(&stock, &key, &path, [0., 1.], key.size(), tolerance(size))
.map_err(|why| format!("the key's sweep not built: {why:?}"))
}
Time
1.65 s; CPU time 1.65 s; peak memory 380.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.
Data
its STEP's
expected
rel. error
volume
10652.87999
10652.87999
4.7e-12
area
3996.725031
3996.725031
9.1e-11
agrees with
cad-kernel, next.BREP, cadrs, springrep
mesh
798 triangles, closed
centre of gravity
(15, 10, -4.03024) its STEP's solid
inertia
about it, of unit density: Ixx 968787; Iyy 1.62863e+06; Izz 2.48488e+06; Ixy 6304.18; Iyz -1.70384e-07; Izx -1.32797e-06
"""A square key 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 square key 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 key, so drawn, is the box from (−1.5, −0.8, −1.5) to (1.5, 0.8, 2.5): 3 long along the curve,
1.6 across it, its bottom 1.5 below the block's top.
Cut from the block everything the key passes through as the frame runs the whole curve.
The key turns as the curve turns, so no screw carries it, and it is no solid of revolution: its
contact changes from face to face and edge to edge along the way, and its corners dig past its
sides where the curve bends."""fromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWirefromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBoxfromOCP.GeomimportGeom_BezierCurvefromOCP.Geom2dimportGeom2d_BezierCurvefromOCP.GeomLPropimportGeomLProp_CurAndInf2dfromOCP.collections importArray1_gp_Pnt, Array1_gp_Pnt2dfromOCP.gp import gp, gp_Ax3, gp_Dir, gp_Pnt, gp_Pnt2d, gp_Trsf, gp_Vec
from bench importRefusedfrom sweep import cut, leads, moved, piped, plane, split, united
BLOCK = ((-6, -6, -8), (36, 26, 0))
CONTROL = [(0, 0), (10, 0), (20, 20), (30, 20)] # in the plane z = 0KEY = ((-1.5, -0.8, -1.5), (1.5, 0.8, 2.5)) # in the frame where the curve startsdefbezier(points):
poles = Array1_gp_Pnt(1, len(points))
for i, (x, y) inenumerate(points):
poles.SetValue(i + 1, gp_Pnt(x, y, 0))
returnGeom_BezierCurve(poles)
defframe(curve, t):
"""The frame riding the curve at parameter t, as the motion that carries the start's frame
(the world's) to it: its origin the curve's point, x along the tangent, z up."""
p, d = gp_Pnt(), gp_Vec()
curve.D1(t, p, d)
trsf = gp_Trsf()
trsf.SetDisplacement(gp_Ax3(gp.XOY_s()), gp_Ax3(p, gp.DZ_s(), gp_Dir(d)))
return trsf, p, d
defbuild():
curve = bezier(CONTROL)
# The curve turns left and then right: where it inflects, the frame stops turning one way# and starts turning the other (OCCT finds the parameter, GeomLProp_CurAndInf2d).
poles = Array1_gp_Pnt2d(1, len(CONTROL))
for i, p inenumerate(CONTROL):
poles.SetValue(i + 1, gp_Pnt2d(*p))
inflections = GeomLProp_CurAndInf2d()
inflections.PerformInf(Geom2d_BezierCurve(poles))
ifnot inflections.IsDone():
raiseRefused("GeomLProp_CurAndInf2d could not find where the curve inflects")
knots = [0] + sorted(inflections.Parameter(i + 1)
for i inrange(inflections.NbPoints())) + [1]
key = BRepPrimAPI_MakeBox(gp_Pnt(*KEY[0]), gp_Pnt(*KEY[1])).Shape()
pieces = [key]
for t0, t1 inzip(knots, knots[1:]):
# A point at q in the frame moves, in the frame, with velocity v x̂ + ω ẑ × q, v the# curve's speed and ω the rate the frame turns. On the faces x = ±1.5 that is# ±(v − ω q_y), never zero: the curve never turns tighter than about 7.5, far more than# the key's half-width 0.8, so they lead and trail all over. On the faces y = ±0.8 it is# ±ω q_x: zero along the line x = 0, the plane through the curve's point square to its# tangent, and leading on the side the frame turns towards; between inflections ω keeps# its sign, so each span between them has one leading half of each. The level faces# slide and turn in their own planes.
to_t0, at, along = frame(curve, t0)
to_t1, _, _ = frame(curve, t1)
start = moved(key, to_t0)
p, d1, d2 = gp_Pnt(), gp_Vec(), gp_Vec()
curve.D2((t0 + t1) / 2, p, d1, d2)
turning = d1.Crossed(d2).Z() / d1.SquareMagnitude() # ω per unit of the parameterdefvelocity(q, at=at, along=along, turning=turning):
return along.Added(gp_Vec(0, 0, turning).Crossed(gp_Vec(at, q)))
faces = [f for f insplit(start, [plane(at.Coord(), along.Coord())])
ifleads(f, velocity) > 0]
span = Geom_BezierCurve(curve.Poles())
span.Segment(t0, t1)
spine = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(span).Edge()).Wire()
onward = to_t1.Multiplied(to_t0.Inverted()) # from where the span starts to its end
sheets = [piped(spine, [f], [moved(f, onward)]) for f in faces]
pieces.append(united(sheets, "the key's faces' sweeps along a span"))
returncut(BRepPrimAPI_MakeBox(gp_Pnt(*BLOCK[0]), gp_Pnt(*BLOCK[1])).Shape(), pieces)
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
508 ms; CPU time 960 ms; peak memory 9.6 MB
Notes
refused operation failed: the section's boundary does not close: a piece ends at (31.499892849, 20.000000000) and none starts there
//! A block, the box from (−6, −6, −8) to (36, 26, 0), grooved by a square key, the box from//! (−1.5, −0.8, −1.5) to (1.5, 0.8, 2.5) in a frame carried along the cubic Bézier curve through//! control points (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: the key's top and bottom faces are carried along//! their own planes while the frame turns, beside faces it carries out, and their edges sweep//! regions of those planes over one another, which kentron's sweep does not resolve.usecrate::bench::{d, frame, p};
usecrate::shared::swept::bezier_frame;
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 key = Cuboid::new(3.0, 1.6, 4.0).with_frame(frame(p(-1.5, -0.8, -1.5), d(0.0, 0.0, 1.0))).build(m)?;
let swept = sweep::solid(m, key, &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.4 ms; CPU time 1.2 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 key turns with the curve and its corners dig past its sides where it bends, so the groove's walls are its corners' paths and its faces' envelopes, which no plane section swept along the curve makes
//! Refused. The key is carried by a frame that turns with the curve's tangent, and it reaches 1.5//! ahead of and behind the frame's origin, so where the curve bends its corners dig past its//! sides: the groove's walls are made by the paths of its corners and the envelopes of its faces//! over the motion, changing from face to face and edge to edge. solidcraft-kernel has no sweep//! of a solid and no envelope, and its sweeps of a profile carry a plane section along the path,//! which makes none of those walls; computed here they 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 key turns with the curve and \
its corners dig past its sides where it bends, so the groove's walls are its corners' \
paths and its faces' envelopes, which no plane section 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.5 ms; CPU time 3.3 ms; peak memory 11.5 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 square key 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
105 ms; CPU time 105 ms; peak memory 36.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.
Data
its STEP's
expected
rel. error
volume
10652.87999
10652.87999
2.1e-12
area
3996.725031
3996.725031
2.6e-12
agrees with
cad-kernel, occt, cadrs, springrep
mesh
108874 triangles, closed
centre of gravity
(15, 10, -4.03024) its STEP's solid
inertia
about it, of unit density: Ixx 968787; Iyy 1.62863e+06; Izz 2.48488e+06; Ixy 6304.18; Iyz 7.15325e-12; Izx 2.43081e-11
//! A block grooved by a square key carried along a spline.//!//! Through the kernel's sweep of a prism carried by a frame along a curve (`sweep_prism_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 key, drawn in the frame at the curve's start, is the rectangle −1.5 ≤ x ≤ 1.5,//! −0.8 ≤ y ≤ 0.8 from z = −1.5 to 2.5. The motion is planar, so the kernel finds the plane region//! the moving rectangle covers (its corners' paths, its sides' grazing points' paths and its end//! positions, split where they meet) and extrudes it; 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_prism_along, BooleanOperation, BrepSolid, FrameCurve};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let block = make_box_brep(p(-6.0, -6.0, -8.0), 42.0, 32.0, 8.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 key = sweep_prism_along(&[[-1.5, -0.8], [1.5, -0.8], [1.5, 0.8], [-1.5, 0.8]], -1.5, 2.5, &path)?;
Ok(boolean_operation_nary(&[block, key], 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
126 ms; CPU time 416 ms; peak memory 11.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
10652.87999
10652.87999
1.0e-11
area
3996.725031
3996.725031
6.0e-12
agrees with
cad-kernel, occt, next.BREP, springrep
mesh
3624 triangles, closed
centre of gravity
(15, 10, -4.03024) its STEP's solid
inertia
about it, of unit density: Ixx 968787; Iyy 1.62863e+06; Izz 2.48488e+06; Ixy 6304.18; Iyz 9.54484e-08; Izx 1.02439e-07
//! A block (the box from (−6, −6, −8) to (36, 26, 0)) grooved by a key (the box from//! (−1.5, −0.8, −1.5) to (1.5, 0.8, 2.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.//!//! What the key passes through is cadrs's sweep of a solid along a path (exact: a prism carried//! in its own plane), cut from the block.usecrate::bench::{block, cut, p3};
usecrate::shared::swept::{bezier_path, carried};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
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 key = block(k, p3(-1.5, -0.8, -1.5), p3(1.5, 0.8, 2.5))?;
let path = bezier_path([(0.0, 0.0), (10.0, 0.0), (20.0, 20.0), (30.0, 20.0)]);
let swept = carried(k, key, 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
3.56 s; CPU time 3.56 s; peak memory 13 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
10652.87999
10652.87999
2.8e-12
area
3996.725031
3996.725031
1.8e-11
agrees with
cad-kernel, occt, next.BREP, cadrs
mesh
133402 triangles, closed
centre of gravity
(15, 10, -4.03024) its STEP's solid
inertia
about it, of unit density: Ixx 968787; Iyy 1.62863e+06; Izz 2.48488e+06; Ixy 6304.18; Iyz -1.47465e-09; Izx 5.81721e-10
// A block, the box from (-6, -6, -8) to (36, 26, 0), its top in the top plane; a square key, the// box from (-1.5, -0.8, -1.5) to (1.5, 0.8, 2.5), drawn where the cubic Bezier through (0, 0),// (10, 0), (20, 20) and (30, 20) starts and carried rigidly by a frame riding the curve (its x the// tangent, its z upright), and everything the key passes through cut from the block.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
// the path, a spline over its four control points
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)
// the key's footprint, 3 along the curve's start and 1.6 across it
e := point
f := point hint((1.5, -0.8))
g := point hint((1.5, 0.8))
h := point hint((-1.5, 0.8))
footprint := horizontal line(e, f) -> vertical line(f, g) ->
horizontal line(g, h) -> vertical line(h, e) -> close
fix((-1.5, -0.8)) e
e distance(3) f
f distance(1.6) g
}
part := solid(std.solids.Prism(outline, from: -8mm, to: 0mm))
key := solid(std.solids.Prism(footprint, from: -1.5mm, to: 2.5mm))
along := std.stations.Along(route, up: std.z)
groove := solid({ p | some t in (0rad, 1rad): p in key at(under: along.f) t })
groove cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1 ms; peak memory 3.5 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 square key 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())
}