The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3), whose edges are 6√2 long, grown by 1: the solid of every point within 1 of the tetrahedron.
Each face moves 1 outward. The faces meet at an angle of acos(1/3), about 70.53°, so each edge becomes a piece of a cylinder of radius 1 about it, turning through π − acos(1/3), about 109.47°. Each corner becomes a piece of a ball of radius 1 about it, bounded by three arcs, which together make the whole ball.
† works around a missing feature. ✦ an elegant solution. 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
101 ms; CPU time 280 ms; peak memory 13.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.
//! The regular tetrahedron on (3, 3, 3), (3, −3, −3), (−3, 3, −3), (−3, −3, 3), grown by 1.use cad_kernel::build::hull;
use cad_kernel::offset::{grown, Join};
use cad_kernel::topo::Brep;
pubfnbuild() -> Result<Brep, String> {
let corners = [[3., 3., 3.], [3., -3., -3.], [-3., 3., -3.], [-3., -3., 3.]];
// the tetrahedron: its corners' convex hullgrown(&hull(&corners)?, 1., Join::Round)
}
Time
628 ms; CPU time 627 ms; peak memory 367.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 regular tetrahedron grown by 1. The tetrahedron with corners (3, 3, 3), (3, −3, −3),
(−3, 3, −3) and (−3, −3, 3), grown by 1."""from itertools import combinations
fromOCP.BRepBuilderAPIimport (BRepBuilderAPI_MakeFace, BRepBuilderAPI_MakePolygon,
BRepBuilderAPI_MakeSolid, BRepBuilderAPI_Sewing)
fromOCP.TopoDSimportTopoDSfromOCP.gp import gp_Pnt
from bench importRefusedfrom offset import offset
CORNERS = [(3, 3, 3), (3, -3, -3), (-3, 3, -3), (-3, -3, 3)]
GROWTH = 1defbuild():
# Each three of the corners make a face; sewn, the four faces close into a shell.
sewing = BRepBuilderAPI_Sewing()
for triangle incombinations(CORNERS, 3):
polygon = BRepBuilderAPI_MakePolygon(*(gp_Pnt(*p) for p in triangle), True)
sewing.Add(BRepBuilderAPI_MakeFace(polygon.Wire()).Face())
sewing.Perform()
solid = BRepBuilderAPI_MakeSolid(TopoDS.Shell(sewing.SewedShape()))
ifnot solid.IsDone():
raiseRefused("BRepBuilderAPI_MakeSolid could not close the tetrahedron")
returnoffset(solid.Shape(), GROWTH)
arris left no solid to show.
Time
1.1 ms; CPU time 970 µs; peak memory 3.8 MB
Notes
refused arris has no offset with rounded joins: `offset_faces` moves every face and joins the moved faces sharp, where they meet
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3),//! 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
3.9 ms; CPU time 3.6 ms; peak memory 10.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3),//! grown by 1: every point within 1 of it, its edges pieces of cylinders and its corners pieces//! of balls. The tetrahedron is the solid its four triangles enclose.usecrate::bench::p;
usecrate::shared::offset::polygon_face;
use kentron::boolean;
use kentron::offset::{self, Join};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let corners = [p(3.0, 3.0, 3.0), p(3.0, -3.0, -3.0), p(-3.0, 3.0, -3.0), p(-3.0, -3.0, 3.0)];
letmut faces = Vec::new();
for left_out in0..4 {
let triangle: Vec<_> = (0..4).filter(|&i| i != left_out).map(|i| corners[i]).collect();
faces.push(polygon_face(m, &triangle)?);
}
let tetrahedron = boolean::enclosed_solids(m, &faces)?;
offset::shape(m, tetrahedron, 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.
Time
617 ms; CPU time 617 ms; peak memory 49.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.
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3) grown//! by 1: every point within 1 of it, its edges pieces of cylinders and its corners pieces of a//! ball, SolidCraft's offset of the whole solid (`offset_solid`), its convex edges rounded. The//! tetrahedron is SolidCraft's convex polyhedron of the four half-spaces its faces bound.usecrate::solids::*;
use solidcraft_kernel::{convex_polyhedron, HalfSpace};
pubfnbuild() -> R<Body> {
// the face opposite corner c lies on the plane −c·x = 9, at √3 from the centre, facing away// from clet corners = [[3.0, 3.0, 3.0], [3.0, -3.0, -3.0], [-3.0, 3.0, -3.0], [-3.0, -3.0, 3.0]];
let s = 27f64.sqrt();
let faces: Vec<HalfSpace> =
corners.iter().map(|c| HalfSpace { n: v3(-c[0] / s, -c[1] / s, -c[2] / s), d: 3f64.sqrt() }).collect();
let tetrahedron = convex_polyhedron(&faces)?;
solidcraft_kernel::offset_solid(&tetrahedron, 1.0, true)
}
Time
2.3 ms; CPU time 2.1 ms; peak memory 7.7 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no rounded offset
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 regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3), the//! convex hull of its corners, grown by 1 with its edges and corners rounded.//!//! brepkit's rounded offset (`offset_solid_arc_v2`) does not build its arc joints yet, so the//! tetrahedron is offset with sharp joints, each face moved 1 outward and extended to meet, and//! the grown tetrahedron's six edges are then rounded to radius 1 in one fillet: each round lies//! 1 from both moved faces, on the cylinder of radius 1 about the tetrahedron's own edge, and the//! three rounds at a corner close on the ball of radius 1 about its corner.use brepkit_operations::blend_ops::{all_blended, fillet_v2};
use brepkit_operations::offset_v2::offset_solid_v2;
use brepkit_operations::primitives::make_convex_hull;
use brepkit_topology::explorer::solid_edges;
use brepkit_topology::solid::SolidId;
use brepkit_topology::Topology;
usecrate::solids::p;
usecrate::Refusal;
pubfnbuild(topo: &mutTopology) -> Result<SolidId, Refusal> {
let corners = [
p(3.0, 3.0, 3.0),
p(3.0, -3.0, -3.0),
p(-3.0, 3.0, -3.0),
p(-3.0, -3.0, 3.0),
];
let tetrahedron = make_convex_hull(topo, &corners)?;
let grown = offset_solid_v2(topo, tetrahedron, 1.0)?;
let edges = solid_edges(topo, grown)?;
Ok(all_blended(fillet_v2(topo, grown, &edges, 1.0)?)?)
}
Time
29 ms; CPU time 42 ms; peak memory 27.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.
// The regular tetrahedron with corners (3, 3, 3), (3, -3, -3), (-3, 3, -3), (-3, -3, 3): popkern has// no polyhedron primitive, so it is the common part of four slabs, each sketched on one face's// plane (through the face's centre) and extruded inward. Grown by 1.let m = model();
let faces_of = [
[[-1.0, -1.0, -1.0], [1.0, 1.0, 1.0]],
[[-1.0, 1.0, 1.0], [1.0, -1.0, -1.0]],
[[1.0, -1.0, 1.0], [-1.0, 1.0, -1.0]],
[[1.0, 1.0, -1.0], [-1.0, -1.0, 1.0]],
];
let t = m.profile(plane_at(faces_of[0][0], faces_of[0][1])).rect(40.0, 40.0)
.sketch("slab_0").extrude(blind(20.0));
for i in1..4 {
let f = faces_of[i];
let slab = m.tool(|m| m.profile(plane_at(f[0], f[1])).rect(40.0, 40.0)
.sketch(`slab_${i}`).extrude(blind(20.0)));
t = t.intersect(slab, #{ label: `face_${i}` });
}
t = t.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
10 ms; CPU time 9.9 ms; peak memory 11.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.
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3), grown//! by 1 to its parallel body: its faces moved out, its edges pieces of cylinders and its corners//! pieces of balls of radius 1.//!//! The tetrahedron is the kernel's three-sided pyramid with edges 6√2 and height 4√3, its base//! centred on the origin, turned so that its axis runs along (1, 1, 1) and moved so that its base//! is the face opposite (3, 3, 3), centred on (−1, −1, −1).usecrate::solids::offset::parallel;
usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{make_pyramid_brep, transform_brep, AffineTransform, BrepSolid};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let edge = 6.0 * 2f64.sqrt();
let pyramid = make_pyramid_brep(p(-edge / 2.0, -edge / 2.0, 0.0), edge, 4.0 * 3f64.sqrt(), 3)?;
// The pyramid's x, y and z axes go to (−1, 1, 0)/√2, (−1, −1, 2)/√6 and (1, 1, 1)/√3.let (a, b, c) = (2f64.sqrt(), 6f64.sqrt(), 3f64.sqrt());
let turn = AffineTransform::new([
-1.0 / a, -1.0 / b, 1.0 / c, -1.0,
1.0 / a, -1.0 / b, 1.0 / c, -1.0,
0.0, 2.0 / b, 1.0 / c, -1.0,
0.0, 0.0, 0.0, 1.0,
])?;
let tetrahedron = transform_brep(&pyramid, turn, false)?;
Ok(parallel(&tetrahedron, 1.0)?)
}
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3),//! grown by 1: every point within 1 of it. Each face moves 1 outward, each edge becomes a piece//! of a cylinder of radius 1 about it, each corner a piece of a ball of radius 1 about it.//!//! The tetrahedron is the cube from (−3, −3, −3) to (3, 3, 3) with its other four corners cut//! off, each by the plane through the three tetrahedron corners round it: a datum plane through//! those three corners of the cube, picked, and a rectangle sketched on it extruded out through//! the cube's corner. 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 four faces are offset 1 out, and all six//! edges, selected together, then rounded to radius 1: each round is tangent to two moved faces, so it lies about the//! tetrahedron's own edge, and where three meet, the corner is the ball about its own corner.usecrate::shared::hollow::{all_edges, level, offset_faces, vertex};
usecrate::shared::{Drawing, extrude, made, sketch};
usecrate::{Bench, Refusal};
use geop_ops_fillet::FilletArgs;
use geop_ops_model::datums::datum;
use geop_ops_model::selection::Selected;
use geop_ops_model::sketch::SketchPlane;
use geop_ops_model::{Combine, element};
use geop_ops_reference_geometry::{AddDatumArgs, Construction};
pubfnbuild(b: &mutBench) -> Result<(), Refusal> {
let floor = level(b, "floor", -3.0)?;
letmut base = Drawing::new();
base.rectangle([-3.0, -3.0], [3.0, 3.0]);
sketch(b, "base", floor, base)?;
extrude(b, "cube", "base", 6.0, Combine::NewBody)?;
letmut body = made("extrude", "cube");
// Each face's corners in the order that turns the plane's normal, (b − a) × (c − a), away// from the tetrahedron, towards the corner of the cube cut off.let faces: [[[f64; 3]; 3]; 4] = [
[[3.0, -3.0, -3.0], [-3.0, -3.0, 3.0], [-3.0, 3.0, -3.0]],
[[3.0, 3.0, 3.0], [-3.0, 3.0, -3.0], [-3.0, -3.0, 3.0]],
[[3.0, 3.0, 3.0], [-3.0, -3.0, 3.0], [3.0, -3.0, -3.0]],
[[3.0, 3.0, 3.0], [3.0, -3.0, -3.0], [-3.0, 3.0, -3.0]],
];
for (i, corners) in faces.iter().enumerate() {
let plane = format!("face{i}");
let selection = (corners.iter())
.map(|&c| Ok(Selected::Vertex(element(vertex(b, c)?))))
.collect::<Result<Vec<_>, Refusal>>()?;
b.step(&plane, AddDatumArgs { selection, construction: Construction::ThreePoints {} })?;
letmut beyond = Drawing::new();
beyond.rectangle([-20.0, -20.0], [20.0, 20.0]);
let sketch_id = format!("beyond{i}");
sketch(b, &sketch_id, SketchPlane::Datum(datum(plane.as_str())), beyond)?;
let cut = format!("corner{i}");
extrude(b, &cut, &sketch_id, 20.0, Combine::cut(body))?;
body = made("extrude", &cut);
}
// A point inside each face: the middle of its corners.let middles: Vec<[f64; 3]> =
(faces.iter()).map(|f| [0, 1, 2].map(|k| (f[0][k] + f[1][k] + f[2][k]) / 3.0)).collect();
offset_faces(b, "grow", &middles, 1.0)?;
let edges = all_edges(b)?;
b.step("rounds", FilletArgs::constant(edges, 1.0))
}
Time
3.9 ms; CPU time 5 ms; peak memory 7.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3),//! grown by 1: the solid of every point within 1 of it. Each face moves 1 out, each edge becomes//! a piece of a cylinder of radius 1 and each corner a piece of a ball.//!//! The tetrahedron is a loft from a sketched triangle, its base through three of the corners,//! to the fourth corner as a point (cadrs has no tetrahedron, nor any polyhedron, primitive; a//! loft to a point is how its Part Studio makes a pyramid). Then cadrs's offset with rounded//! edges.usecrate::bench::{p2, p3, P3};
usecrate::shared::offset::grown;
usecrate::Refusal;
use cadrs_kernel::{BodyId, BodyKind, DefaultKernel, Kernel, LoftEnd, LoftSection, LoftSpec, Loop, Plane, Profile};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let apex = p3(3.0, 3.0, 3.0);
let base: [P3; 3] = [p3(3.0, -3.0, -3.0), p3(-3.0, 3.0, -3.0), p3(-3.0, -3.0, 3.0)];
// The sketch plane through the base's corners, its normal toward the apex.let normal = (base[1] - base[0]).cross(&(base[2] - base[0]));
let normal = if normal.dot(&(apex - base[0])) < 0.0 { -normal } else { normal };
let on = Plane::new(base[0], base[1] - base[0], normal);
let y_dir = on.normal.cross(&on.x_dir);
let at = |p: P3| {
let d = p - on.origin;
p2(d.dot(&on.x_dir), d.dot(&y_dir))
};
let corners: Vec<[f64; 2]> = base.iter().map(|&p| at(p)).map(|q| [q.x, q.y]).collect();
let triangle = Profile::of(on, vec![Loop::polygon(&corners)]);
let spec = LoftSpec {
body: BodyKind::Solid,
sections: vec![LoftSection::Profile(triangle), LoftSection::Point(apex)],
start: LoftEnd::default(),
end: LoftEnd::default(),
source: 1,
};
let tetrahedron = k.loft_with(&spec)?.bodies[0];
grown(k, tetrahedron, 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
13 ms; CPU time 12 ms; peak memory 8.9 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
//! The regular tetrahedron with corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3), grown//! by 1. springrep has no polyhedron, so the tetrahedron is a block cut by the planes of its four//! faces, each keeping the side its opposite corner is on.use springrep::boolean::split;
use springrep::math::Vec3;
use springrep::primitive::block;
use springrep::topo::Brep;
usecrate::shared::offset::grown;
usecrate::shared::{at, e};
pubfnbuild() -> Result<Brep, String> {
letmut tet = block(&at([-5., -5., -5.]), Vec3::new(10., 10., 10.), "block").map_err(e)?;
let corners = [[3., 3., 3.], [3., -3., -3.], [-3., 3., -3.], [-3., -3., 3.]];
for corner in corners {
// the face opposite a corner passes through the other three, a third of the way from the// centre to the corner, back across the centre: its normal points at the cornerlet toward = Vec3::from_array(corner);
let (kept, _) = split(&tet, toward * (-1. / 3.), toward).map_err(e)?;
tet = kept;
}
grown(&tet, 1.)
}
Time
90 ms; CPU time 121 ms; peak memory 32.6 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Elegant ✦ one corner and its half turns about the three axes, made regular by three edges; the hull the join of two opposite edges, grown by one set statement, built exactly
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 regular tetrahedron on the corners (3, 3, 3), (3, −3, −3), (−3, 3, −3) and (−3, −3, 3), grown// by 1. Its three axes of symmetry are the world's: one corner and its half turns about x, y and z// are its four. Its three edges from that corner are equal, which makes it regular, their length an// unknown the solve finds (6√2); it stands 6 tall, the corner 6 above its half turn about x; and// the corner lies toward +x of its half turn about y and toward +y of its half turn about z, which// says which of the four roots is meant. It is the hull of its corners, written as the join of two// opposite edges: the segments from some point of one edge to some point of the other. Grown, it is// the points a ball of radius 1 about some point of it reaches.unit mm
use std
use std.sets
param edge: Lengthhint(8mm)
a := point
b := point
c := point
d := point
a symmetry(std.x) b
a symmetry(std.y) c
a symmetry(std.z) d
a distance(edge) b
a distance(edge) c
a distance(edge) d
b distance(6mm, along: std.z) a
c distance(>= 0mm, along: std.x) a
d distance(>= 0mm, along: std.y) a
tetrahedron := solid({ p | some q in std.sets.Segment(a, b), r in std.sets.Segment(c, d):
p in std.sets.Segment(q, r) })
part := solid({ p | some q in tetrahedron: p distance(<= 1mm) q })
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 regular tetrahedron 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())
}