A napkin ring: a ball of radius 5 centered on the origin, with a hole of radius 3 bored right through it along the z axis. Grow it by 1: the solid of every point within 1 of the ring.
The ring's outer face moves out to the sphere of radius 6, and its bore narrows to radius 2. Each of its rims, the circle of radius 3 at z = 4 or z = −4 where the sphere meets the bore at an angle of θ = atan(4/3) (about 53.13°) inside the ring, becomes a piece of a torus's tube of radius 1 about the rim's circle, turning through π − θ (about 126.87°) from the bore to the sphere: from z = ±4 on the bore to the point (3.6, ±4.8) of a section through the axis.
† 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
9.1 ms; CPU time 12 ms; peak memory 11.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 ball of radius 5 about the origin bored through along z with a hole of radius 3, grown by 1.use cad_kernel::boolean::{combined, Op};
use cad_kernel::build::{disc, prism, sphere};
use cad_kernel::offset::{grown, Join};
use cad_kernel::topo::Brep;
pubfnbuild() -> Result<Brep, String> {
let ball = sphere([0., 0., 0.], [0., 0., 1.], 5.)?;
let bore = prism(&disc([0., 0., -6.], [0., 0., 1.], 3.), 0., 12.)?;
grown(&combined(&ball, &bore, Op::Cut, 0.)?, 1., Join::Round)
}
Time
643 ms; CPU time 642 ms; peak memory 367.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.
"""A napkin ring grown by 1. A ball of radius 5 centred on the origin, with a hole of radius 3
bored right through it along the z axis, grown by 1."""fromOCP.BRepAlgoAPIimportBRepAlgoAPI_CutfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeCylinder, BRepPrimAPI_MakeSpherefromOCP.gp import gp, gp_Ax2, gp_Pnt
from bench importRefusedfrom offset import offset
BALL_RADIUS = 5HOLE_RADIUS = 3GROWTH = 1defbuild():
ball = BRepPrimAPI_MakeSphere(gp_Pnt(0, 0, 0), BALL_RADIUS).Shape()
# The drill runs well past the ball at both ends: from z = −10 to z = 10.
drill = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, -2 * BALL_RADIUS), gp.DZ_s()),
HOLE_RADIUS, 4 * BALL_RADIUS).Shape()
cut = BRepAlgoAPI_Cut(ball, drill)
ifnot cut.IsDone():
raiseRefused("BRepAlgoAPI_Cut declined the hole")
returnoffset(cut.Shape(), GROWTH)
arris left no solid to show.
Time
1.1 ms; CPU time 950 µs; peak memory 3.9 MB
Notes
refused arris has no offset with rounded joins: `offset_faces` moves every face and joins the moved faces sharp, where they meet
//! A ball of radius 5 centred on the origin, with a hole of radius 3 bored through it along the//! z axis, grown by 1.//!//! Refused: arris's `offset_faces` moves every face of a solid along its normal and joins the moved//! faces where they meet, so at a convex edge of an outward offset the join is sharp. Growing by//! every point within 1 rounds each convex edge and corner, and arris has no rounded join.usecrate::Refusal;
use arris::topo::{Body, Model};
pubfnbuild(_: &mutModel) -> Result<Body, Refusal> {
Err("arris has no offset with rounded joins: `offset_faces` moves every face and joins the moved faces sharp, where they meet".into())
}
Time
11 ms; CPU time 11 ms; peak memory 11.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 napkin ring, a ball of radius 5 about the origin with a hole of radius 3 bored through it//! along the z axis, grown by 1: every point within 1 of it, its rims pieces of tori. The drill//! runs from z = −10 to z = 10, past the ball at both ends.usecrate::bench::{frame, p};
use kentron::boolean;
use kentron::math::Direction;
use kentron::offset::{self, Join};
use kentron::primitives::{Cylinder, Sphere};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let ball = Sphere::new(5.0).build(m)?;
let drill = Cylinder::new(3.0, 20.0).with_frame(frame(p(0.0, 0.0, -10.0), Direction::Z)).build(m)?;
let ring = boolean::difference(m, ball, drill)?;
offset::shape(m, ring, 1.0, Join::Arc)
}
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
311 ms; CPU time 311 ms; peak memory 49.8 MB
Notes
refused the operation failed: SMLib offset: operation: solidcore: offset::offset_executive::p2::offset_brep: the offset could not be built; caused by offset::offset_executive::p1: the rounded offset's tube about edge 0 by 1 is not proved regular, nor proved to fold, so no size is named
//! A napkin ring, the ball of radius 5 centred on the origin with a hole of radius 3 bored through//! it along z, grown by 1: every point within 1 of it, its sphere moved out to radius 6, its bore//! in to radius 2, its rims pieces of tori, SolidCraft's offset of the whole solid//! (`offset_solid`), its convex edges rounded.usecrate::solids::*;
pubfnbuild() -> R<Body> {
let ball = solidcraft_kernel::sphere(Vec3::ZERO, 5.0)?;
let bore = zcyl(0.0, 0.0, 3.0, -6.0, 6.0)?;
let ring = cut(&ball, &bore)?;
solidcraft_kernel::offset_solid(&ring, 1.0, true)
}
brepkit left no solid to show.
Time
14 ms; CPU time 14 ms; peak memory 12.1 MB
Notes
refused brepkit's offset of the ring has no rim where the grown sphere meets the grown bore to round (the offset solid it returns fails brepkit's own validity check)
//! A napkin ring, the ball of radius 5 about the origin bored through along the z axis by a hole//! of radius 3, grown by 1 with its rims rounded.//!//! brepkit's rounded offset (`offset_solid_arc_v2`) does not build its arc joints yet, so the//! ring is offset with sharp joints (its sphere grown to radius 6, its bore narrowed to radius 2)//! and the grown ring's two rims are then rounded to radius 1: each round lies 1 from the moved//! sphere and bore, on the tube of radius 1 about the ring's own rim, the circle of radius 3 at//! z = ±4.use brepkit_operations::blend_ops::{all_blended, fillet_v2};
use brepkit_operations::offset_v2::offset_solid_v2;
use brepkit_operations::primitives::{make_cylinder, make_sphere};
use brepkit_topology::solid::SolidId;
use brepkit_topology::Topology;
usecrate::solids::{cut, edges_where, moved, near};
usecrate::Refusal;
pubfnbuild(topo: &mutTopology) -> Result<SolidId, Refusal> {
let ball = make_sphere(topo, 5.0, 64)?;
// the bore runs past both endslet bore = make_cylinder(topo, 3.0, 12.0)?;
let bore = moved(topo, bore, 0.0, 0.0, -6.0)?;
let ring = cut(topo, ball, bore)?;
let grown = offset_solid_v2(topo, ring, 1.0)?;
// the rims: where the sphere of radius 6 meets the bore of radius 2let rims = edges_where(topo, grown, |q| {
near(q.x().hypot(q.y()), 2.0) && near(q.x() * q.x() + q.y() * q.y() + q.z() * q.z(), 36.0)
})?;
if rims.is_empty() {
returnErr(
"brepkit's offset of the ring has no rim where the grown sphere meets the grown bore \
to round (the offset solid it returns fails brepkit's own validity check)"
.into(),
);
}
Ok(all_blended(fillet_v2(topo, grown, &rims, 1.0)?)?)
}
Time
120 ms; CPU time 121 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 napkin ring: a ball of radius 5 on the origin (a half disc revolved about z) bored through// along z by a cylinder of radius 3, grown by 1.let m = model();
let ring = m.profile(xz()).path(0.0, -5.0).arc_to([5.0, 0.0], [0.0, 5.0]).line_to(0.0, -5.0).close()
.sketch("half_disc").revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), full_circle());
let bore = m.tool(|m| m.profile(xy_at(-6.0)).circle(3.0).sketch("bore").extrude(blind(12.0)));
ring = ring.subtract(bore, #{ label: "bore" });
ring = ring.offset_solid(1.0, #{ label: "grown" });
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
7.6 ms; CPU time 7.3 ms; peak memory 17.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 napkin ring, the ball of radius 5 about the origin with a hole of radius 3 bored through it//! along the z axis, grown by 1 to its parallel body: the sphere of radius 6 outside, the bore//! narrowed to radius 2, and each rim a piece of a torus's tube of radius 1.//!//! The hole is cut by a cylinder running past both ends of the ball.usecrate::solids::offset::{parallel, subtract};
usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{make_cylinder_brep, make_sphere_brep, BrepSolid};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let ball = make_sphere_brep(p(0.0, 0.0, 0.0), 5.0, p(0.0, 0.0, 1.0))?;
let bore = make_cylinder_brep(p(0.0, 0.0, -6.0), p(0.0, 0.0, 1.0), 3.0, 12.0)?;
let ring = subtract(&ball, &bore)?;
Ok(parallel(&ring, 1.0)?)
}
Time
49.6 s; CPU time 49.6 s; peak memory 76.7 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sphere primitive, no rounded offset 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
737.07767
737.0776973
3.7e-08
area
535.8663635
535.8663888
4.7e-08
agrees with
no other kernel
mesh
33986 triangles, closed
centre of gravity
(2.1208e-16, -2.3618e-16, 1.119e-15) its STEP's solid
inertia
about it, of unit density: Ixx 10607.2; Iyy 10607.2; Izz 12609.8; Ixy 5.23597e-08; Iyz 1.35399e-13; Izx 1.13721e-13
//! A napkin ring, the ball of radius 5 about the origin with a hole of radius 3 bored through it//! along z, grown by 1: every point within 1 of it. The sphere moves out to radius 6, the bore//! narrows to radius 2, and each rim becomes a piece of a torus's tube of radius 1 about the//! rim's circle.//!//! geop has no ball: it is turned from a half disc about the z axis, and the bore cut by a//! circle extruded past it both ways. geop has no offset of a solid that rounds where moved//! faces part: its face offset moves the faces and meets them sharp. So the ring's faces are//! offset 1 out, to the sphere of radius 6 and the bore of radius 2, and its two rims then//! rounded to radius 1: each round is tangent to both moved faces, so it is the tube of radius//! 1 about the ring's own rim.usecrate::shared::hollow::{at, offset_faces, round, turned, whole_edges};
usecrate::shared::{Drawing, extrude_symmetric, sketch, xy};
usecrate::{Bench, Refusal};
use geop_ops_fillet::FilletArgs;
use geop_ops_model::Combine;
pubfnbuild(b: &mutBench) -> Result<(), Refusal> {
let ball = turned(b, "ball", |d| {
let (bottom, top) = (d.point(at(0.0, -5.0)), d.point(at(0.0, 5.0)));
d.arc(top, bottom, 180.0);
d.line(bottom, top)
})?;
letmut bore = Drawing::new();
bore.circle([0.0, 0.0], 3.0);
sketch(b, "bore", xy(), bore)?;
extrude_symmetric(b, "hole", "bore", 20.0, Combine::cut(ball))?;
letmut faces = round(5.0, 0.0);
faces.extend(round(3.0, 0.0));
offset_faces(b, "grow", &faces, 1.0)?;
// The rims, where the sphere of radius 6 meets the bore of radius 2: at z = ±√32.letmut rims = round(2.0, 32f64.sqrt());
rims.extend(round(2.0, -(32f64.sqrt())));
let rims = whole_edges(b, &rims)?;
b.step("rounds", FilletArgs::constant(rims, 1.0))
}
Time
4.5 ms; CPU time 4.3 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.
//! A napkin ring, a ball of radius 5 about the origin with a hole of radius 3 bored through it//! along the z axis, grown by 1: the solid of every point within 1 of it. The sphere moves out to//! radius 6, the bore narrows to radius 2, and each rim becomes a piece of a torus's tube of//! radius 1.//!//! The ball is cadrs's sphere primitive, its poles on the z axis. The bore is a circle extruded//! through it and cut. Then cadrs's offset with rounded edges.usecrate::bench::{ball, cut, cylinder, p3, v3};
usecrate::shared::offset::grown;
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let b = ball(k, p3(0.0, 0.0, 0.0), 5.0)?;
let bore = cylinder(k, p3(0.0, 0.0, -6.0), v3(0.0, 0.0, 1.0), 3.0, 12.0)?;
let ring = cut(k, b, bore)?;
grown(k, ring, 1.0)
}
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.4 ms; CPU time 3.1 ms; peak memory 8.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 napkin ring, the ball of radius 5 about the origin bored through along z by a hole of radius//! 3, grown by 1: the sphere grows to radius 6, the bore narrows to 2, and each rim becomes a piece//! of a torus.use springrep::boolean::difference;
use springrep::primitive::{cylinder, sphere};
use springrep::topo::Brep;
usecrate::shared::offset::grown;
usecrate::shared::{at, e};
pubfnbuild() -> Result<Brep, String> {
let ball = sphere(&at([0., 0., 0.]), 5., "ball").map_err(e)?;
let bore = cylinder(&at([0., 0., -6.]), 3., 12., "bore").map_err(e)?;
let ring = difference(&ball, &bore).map_err(e)?;
grown(&ring, 1.)
}
geomsolver left no solid to show.
Time
47 ms; CPU time 47 ms; peak memory 24.9 MB
Notes
refused error[E080]: `grown.body`: a face on a sphere: read by the field
// A napkin ring grown by 1: the points of the ball of radius 5 about the origin that are not within// 3 of the z axis, and the points within 1 of that ring, `std.rounds.Grown`'s body.unit mm
use std
use std.sets
use std.rounds
o := point
fix((0, 0, 0)) o
up := point
fix((0, 0, 1)) up
z_axis := line(o, up)
ball := std.sets.Ball(o, r: 5mm)
bore := std.sets.Cylinder(z_axis, r: 3mm)
ring := solid({ p | p in ball; p notin bore })
grown := std.rounds.Grown(ring, d: 1mm)
part := solid(grown.body)
anvilcad left no solid to show.
Time
1.1 ms; CPU time 930 µs; peak memory 3.4 MB
Notes
refused anvil-brep's offset moves each face along its normal and extends the moved faces until they meet, keeping the solid's edges; it adds no round about a convex edge or corner, so it cannot grow a solid to every point within a distance of it
//! A napkin ring grown by 1, grown with its convex edges rounded.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep's offset moves each face along its normal and extends the moved faces until they meet, keeping the solid's edges; it adds no round about a convex edge or corner, so it cannot grow a solid to every point within a distance of it".into())
}