A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved along its length by a wheel of two beads slid past it. The beads are two tori on one axis, which runs parallel to the y axis through (11.5, 0, −9):
the first bead's center is (11.5, 0, −9); the circle through its tube's centers has radius 6, and its tube has radius 2;
the second bead's center is (11.5, 1.5, −9), 1.5 further along the axis; the circle through its tube's centers also has radius 6, and its tube has radius 1.5.
The two beads overlap, and the wheel is their union. It starts below the rod, as placed, and slides without turning 40 along the z axis, up to where it is wholly above the rod. Cut from the rod everything the wheel passes through.
no closed form taken (the rod's disk less two overlapping disks): OCCT, arris and cad-kernel, built independently from this description, agree to 8e-16 (1486.4498667518674 and 1486.4498667518671 and 1486.4498667518683; the mean)
area
787.2349038
no closed form taken (the rod's disk less two overlapping disks): OCCT, arris and cad-kernel, built independently from this description, agree to 2e-15 (787.234903804165 and 787.234903804165 and 787.234903804167; the mean)
Drawing
TopIsometricFrontRight
Third-angle projection, the three views at one scale. Drawn from occt's result, which passed.
† works around a missing feature. ▦ a faceted solid: a mesh stored as B-rep faces. 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.37 s; CPU time 12.6 s; peak memory 22.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 rod, the cylinder of radius 5 about z from z = 0 to 20, grooved along its length by a wheel//! of two beads slid 40 along z: tori on one axis along y, the first centred at (11.5, 0, −9) of//! radii 6 and 2, the second at (11.5, 1.5, −9) of radii 6 and 1.5, united.use cad_kernel::boolean::{combined, Op};
use cad_kernel::build::{disc, prism, torus};
use cad_kernel::geom::{tolerance, V};
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
use std::f64::consts::TAU;
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
/// Each bead: its centre, the radius of the circle through its tube's centres, and its tube's.constBEADS: [(V, f64, f64); 2] = [([11.5, 0., -9.], 6., 2.), ([11.5, 1.5, -9.], 6., 1.5)];
constSLIDE: f64 = 40.;
/// How closely the wheel is meshed for the sweep's membership reads: a hundred-and-fiftieth of/// the thinner tube's radius.constBAR: f64 = 0.01;
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0., 0., 0.], up, ROD_RADIUS), 0., ROD_LENGTH)?;
// the wheel: the two beads united, two torus faces meeting in two circleslet [first, second] =
BEADS.map(|(centre, major, minor)| torus(centre, [0., 1., 0.], major, minor));
let wheel = combined(&first?, &second?, Op::Union, 0.)?;
// the slide along z: a screw that does not turn, advancing its whole length over a roll of τlet path = Trajectory::Twist(Screw { origin: BEADS[0].0, axis: up, ratio: 0., advance: SLIDE });
// the kernel's closed swept solid cut from the rod on one arrangement: each bead's face slid// square to its axis, the meridians square to the slide swept into cylinders along zlet size = rod.size().max(wheel.size());
cut_from(&rod, &wheel, &path, [0., TAU], BAR, tolerance(size))
.map_err(|why| format!("the wheel's sweep not built: {why:?}"))
}
Time
1.69 s; CPU time 1.69 s; peak memory 378.6 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 rod grooved by a wheel of two beads. A rod, the cylinder of radius 5 about the z axis from
z = 0 to z = 20, grooved along its length by a wheel of two beads slid past it. The beads are two
tori on one axis, which runs parallel to the y axis through (11.5, 0, −9):
- the first bead's centre is (11.5, 0, −9); the circle through its tube's centres has radius 6,
and its tube has radius 2;
- the second bead's centre is (11.5, 1.5, −9), 1.5 further along the axis; the circle through its
tube's centres also has radius 6, and its tube has radius 1.5.
The two beads overlap, and the wheel is their union. It starts below the rod, as placed, and
slides without turning 40 along the z axis, up to where it is wholly above the rod. Cut from the
rod everything the wheel passes through."""import math
fromOCP.BRepAlgoAPIimportBRepAlgoAPI_Cut, BRepAlgoAPI_Fuse, BRepAlgoAPI_SplitterfromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeFace, BRepBuilderAPI_TransformfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeCylinder, BRepPrimAPI_MakePrism, BRepPrimAPI_MakeTorusfromOCP.TopAbsimportTopAbs_SHELL, TopAbs_SOLIDfromOCP.TopExpimportTopExp_ExplorerfromOCP.collections importList_TopoDS_ShapefromOCP.gp import gp, gp_Ax2, gp_Ax3, gp_Cylinder, gp_Pln, gp_Pnt, gp_Trsf, gp_Vec
from bench importRefusedROD_RADIUS = 5ROD_LENGTH = 20FIRST_CENTRE, FIRST_TUBE = (11.5, 0, -9), 2SECOND_CENTRE, SECOND_TUBE = (11.5, 1.5, -9), 1.5WHEEL_RADIUS = 6# of each bead's circle through its tube's centresSLIDE = (0, 0, 40)
defshapes(*items):
listed = List_TopoDS_Shape()
for item in items:
listed.Append(item)
return listed
deffused(arguments, tools, what):
fuse = BRepAlgoAPI_Fuse()
fuse.SetArguments(shapes(*arguments))
fuse.SetTools(shapes(*tools))
fuse.Build()
ifnot fuse.IsDone():
raiseRefused(f"BRepAlgoAPI_Fuse declined {what}")
return fuse.Shape()
defslid(bead, centre, tube):
"""Everything one bead passes through as it slides."""
moved = gp_Trsf()
moved.SetTranslation(gp_Vec(*SLIDE))
bead_at_end = BRepBuilderAPI_Transform(bead, moved, True).Shape()
# OCCT's prism sweeps no solid ("Solids are not Processed"), but it sweeps a shell, each face# to the solid that face passes through. A face swept whole is only what it passes through if# the slide never runs along it inside it. A bead's normal, at the point of its tube's circle# turned u about the axis and v round the tube, is cos v·(cos u·x + sin u·z) + sin v·y; it is# square to the slide (z) where sin u = 0, the tube's two circles in the plane z = −9 through# the axis, and where cos v = 0, the bead's circles of radius 6 on its tube's top and bottom.# Split the bead along those four circles, by that plane and by the cylinder of radius 6# about the axis; each piece then slides without folding over itself.
reach = 2 * (WHEEL_RADIUS + tube) # the splitting faces run well past the bead
plane = BRepBuilderAPI_MakeFace(gp_Pln(centre, gp.DZ_s()), -reach, reach, -reach, reach).Face()
cylinder = BRepBuilderAPI_MakeFace(gp_Cylinder(gp_Ax3(centre, gp.DY_s()), WHEEL_RADIUS),
0, 2 * math.pi, -reach, reach).Face()
splitter = BRepAlgoAPI_Splitter()
splitter.SetArguments(shapes(TopExp_Explorer(bead, TopAbs_SHELL).Current()))
splitter.SetTools(shapes(plane, cylinder))
splitter.Build()
ifnot splitter.IsDone():
raiseRefused("BRepAlgoAPI_Splitter could not split a bead along its outline")
prism = BRepPrimAPI_MakePrism(splitter.Shape(), gp_Vec(*SLIDE))
ifnot prism.IsDone():
raiseRefused("BRepPrimAPI_MakePrism could not slide a bead's faces")
# Everything the bead passes through is the bead where it starts, the bead where it ends, and# everything its faces pass through: a point the bead covers that no face ever crosses stays# inside the bead all the way.
pieces = []
swept = TopExp_Explorer(prism.Shape(), TopAbs_SOLID)
while swept.More():
pieces.append(swept.Current())
swept.Next()
returnfused([bead], pieces + [bead_at_end], "a bead's faces' sweeps and the bead at each end")
defbuild():
# The wheel passes through a point when one of its beads does, so what the wheel passes# through is the union of what each bead passes through. (Swept as one solid, split the same# way along its outline, the union's faces' sweeps defeat OCCT's fuse: it returns six solids# that BRepCheck finds invalid.)
sweeps = []
for centre, tube in [(FIRST_CENTRE, FIRST_TUBE), (SECOND_CENTRE, SECOND_TUBE)]:
centre = gp_Pnt(*centre)
bead = BRepPrimAPI_MakeTorus(gp_Ax2(centre, gp.DY_s()), WHEEL_RADIUS, tube).Shape()
sweeps.append(slid(bead, centre, tube))
wheel_sweep = fused(sweeps[:1], sweeps[1:], "the two beads' sweeps")
rod = BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape()
cut = BRepAlgoAPI_Cut(rod, wheel_sweep)
ifnot cut.IsDone():
raiseRefused("BRepAlgoAPI_Cut declined the groove")
return cut.Shape()
Time
37 ms; CPU time 37 ms; peak memory 13.5 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 rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel of//! two overlapping beads slid 40 along z past it. The beads are tori on one axis parallel to y://! one centred at (11.5, 0, −9) with radii 6 and 2, the other 1.5 further along the axis, at//! (11.5, 1.5, −9), with radii 6 and 1.5.//!//! arris has no sweep of a solid, so the wheel's sweep is built from its shape by elementary//! geometry. The sweep of a union is the union of its parts' sweeps, so each bead is swept alone.//! A bead slides along z, in its own mid-plane, and a line along z through a point of its shadow//! meets it in at most two pieces, the gap between them at most its hole's width 8 (or 9), shorter//! than the slide of 40: on that line the bead passes over everything from below its first place//! to above its last. So a bead's sweep is the bead where it starts, the bead where it ends, and//! between their centres its shadow along z extruded: the stadium within its tube's radius of the//! segment its tube's centres cast, from x = 5.5 to x = 17.5. The beads where they start lie wholly//! below z = −1 and where they end wholly above z = 21, clear of the rod, so what the wheel takes//! from the rod is the two prisms', fused into the wheel's shadow extruded.use arris::geom::{Profile, ProfileLoop, ProfileSegment};
use arris::math::{Axis, Control, Frame, Point2, Point3, Vec3};
use arris::ops::{cut, extrude, fuse, primitive_cylinder, OpError};
use arris::topo::{Body, Model};
constROD_RADIUS: f64 = 5.0;
constROD_LENGTH: f64 = 20.0;
/// The wheel's axis: its x and its height where it starts.constAXIS_X: f64 = 11.5;
constSTART_Z: f64 = -9.0;
constSLIDE: f64 = 40.0;
/// Each bead: how far along the axis (y) its centre is, the radius of the circle through its/// tube's centres, and its tube's.constBEADS: [(f64, f64, f64); 2] = [(0.0, 6.0, 2.0), (1.5, 6.0, 1.5)];
pubfnbuild(m: &mutModel) -> Result<Body, OpError> {
let axis = Axis::z_at(Point3::origin());
let (rod, _) = primitive_cylinder(m, axis, ROD_RADIUS, ROD_LENGTH, &Control::NONE)?;
// the plane z = −9 where the wheel starts: u along x, v along ylet start = Frame::new(Point3::new(0.0, 0.0, START_Z), Vec3::z(), Vec3::x())?;
let p = Point2::new;
letmut prisms = Vec::new();
for (along, major, minor) inBEADS {
// the bead's shadow along z: the rectangle its tube's near and far sections span, closed// by a half disc of the tube's radius at each endlet (near, far) = (AXIS_X - major, AXIS_X + major);
let shadow = Profile {
plane: start,
outer: ProfileLoop::Path {
start: p(near, along - minor),
segments: vec![
ProfileSegment::LineTo(p(far, along - minor)),
ProfileSegment::ArcTo {
to: p(far, along + minor),
via: p(far + minor, along),
},
ProfileSegment::LineTo(p(near, along + minor)),
ProfileSegment::ArcTo {
to: p(near, along - minor),
via: p(near - minor, along),
},
],
},
holes: vec![],
};
prisms.push(extrude(m, &shadow, Vec3::z(), SLIDE, &Control::NONE)?.0);
}
let (swept, _) = fuse(m, prisms[0], prisms[1], &Control::NONE)?;
let (grooved, _) = cut(m, rod, swept, &Control::NONE)?;
Ok(grooved)
}
Time
150 ms; CPU time 232 ms; peak memory 17.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 rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel of//! two beads slid past it: tori on one axis parallel to the y axis, the first centred at//! (11.5, 0, −9) with radii 6 and 2, the second at (11.5, 1.5, −9) with radii 6 and 1.5, their//! union slid 40 along the z axis from below the rod to above it. Everything the wheel passes//! through, cut.//!//! The wheel is the beads' union; its sweep is kentron's sweep of a solid (`sweep::solid`, one//! slide), cut from the rod.usecrate::bench::{d, frame, p, v};
use kentron::primitives::{Cylinder, Torus};
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let rod = Cylinder::new(5.0, 20.0).build(m)?;
let first = Torus::new(6.0, 2.0).with_frame(frame(p(11.5, 0.0, -9.0), d(0.0, 1.0, 0.0))).build(m)?;
let second = Torus::new(6.0, 1.5).with_frame(frame(p(11.5, 1.5, -9.0), d(0.0, 1.0, 0.0))).build(m)?;
let wheel = kentron::boolean::union(m, first, second)?;
let swept = sweep::solid(m, wheel, &RigidMotion::Slide { by: v(0.0, 0.0, 40.0) })?;
kentron::boolean::difference(m, rod, swept)
}
Time
82 ms; CPU time 82 ms; peak memory 12.7 MB
Notes
wrong its STEP's faces do not close into a solid
Workaround † no sweep of a solid
Faceted ▦ 992 faces, where the other kernels' solids have 5 (the median): a mesh stored as B-rep faces.
Data
No measures: it built no solid to measure.
STEP
open advanced faces, each on a surface AUTOMOTIVE_DESIGN
STEP faces
992: 992 plane; 992 flat triangles
STEP edges
1489: 1489 line; 2 not bounding exactly two sides of faces, so the shell is open
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel of//! two overlapping beads slid 40 along z past it. The beads are tori on one axis parallel to y://! one centred at (11.5, 0, −9) with radii 6 and 2, the other 1.5 further along the axis, at//! (11.5, 1.5, −9), with radii 6 and 1.5.//!//! vcad has no sweep of a solid, so the wheel's sweep is built from its shape by elementary//! geometry. The sweep of a union is the union of its parts' sweeps, so each bead is swept alone.//! A bead slides along z, in its own mid-plane, and a line along z through a point of its shadow//! meets it in at most two pieces, the gap between them at most its hole's width 8 (or 9), shorter//! than the slide of 40: on that line the bead passes over everything from below its first place//! to above its last. So a bead's sweep is the bead where it starts, the bead where it ends, and//! between their centres its shadow along z extruded: the stadium within its tube's radius of the//! segment its tube's centres cast, from x = 5.5 to x = 17.5. The beads where they start lie wholly//! below z = −1 and where they end wholly above z = 21, clear of the rod, so what the wheel takes//! from the rod is the two prisms': each is cut in turn.usecrate::solids::SEGMENTS;
use vcad_kernel::vcad_kernel_math::{Point2, Point3, Vec3};
use vcad_kernel::vcad_kernel_sketch::{SketchError, SketchProfile, SketchSegment};
use vcad_kernel::Solid;
constROD_RADIUS: f64 = 5.0;
constROD_LENGTH: f64 = 20.0;
/// The wheel's centre's x and the radius of the circle through each bead's tube's centres.constWHEEL_X: f64 = 11.5;
constMAJOR: f64 = 6.0;
/// Each bead: its centre's y and its tube's radius.constBEADS: [(f64, f64); 2] = [(0.0, 2.0), (1.5, 1.5)];
/// The wheel's centre's height where it starts, and how far it slides.constSTART_Z: f64 = -9.0;
constSLIDE: f64 = 40.0;
/// The prism a bead sweeps between its places: its shadow along z, sketched in the plane/// z = −9, extruded along the slide.fnswept(y: f64, minor: f64) -> Result<Solid, SketchError> {
let (near, far) = (WHEEL_X - MAJOR, WHEEL_X + MAJOR);
let p = Point2::new;
let line = |start, end| SketchSegment::Line { start, end };
let arc = |start, end, center| SketchSegment::Arc { start, end, center, ccw: true };
let shadow = vec![
line(p(near, y - minor), p(far, y - minor)),
arc(p(far, y - minor), p(far, y + minor), p(far, y)),
line(p(far, y + minor), p(near, y + minor)),
arc(p(near, y + minor), p(near, y - minor), p(near, y)),
];
let shadow = SketchProfile::new(Point3::new(0.0, 0.0, START_Z), Vec3::x(), Vec3::y(), shadow)?;
Solid::extrude(shadow, Vec3::new(0.0, 0.0, SLIDE))
}
pubfnbuild() -> Result<Solid, crate::Refusal> {
letmut rod = Solid::cylinder(ROD_RADIUS, ROD_LENGTH, SEGMENTS);
for (y, minor) inBEADS {
rod = rod.try_difference(&swept(y, minor)?)?;
}
Ok(rod)
}
Time
65 ms; CPU time 65 ms; peak memory 47.8 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 rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel of two//! overlapping beads on one axis along y slid 40 along z past it: the first bead's centre at//! (11.5, 0, −9), ring 6 and tube 2; the second's at (11.5, 1.5, −9), ring 6 and tube 1.5.//!//! solidcraft-kernel has no sweep of a solid, so the wheel's sweep is built by elementary//! geometry. The sweep of a union is the union of its parts' sweeps, and each bead's is, as in//! `torus-slid-through-rod`, its shadow along z (a slot within its tube's radius of the segment//! its tube's centres cast) extruded from its centre's height where it starts to where it ends,//! with the bead at each end. Those end beads lie wholly below z = −1 and above z = 21, clear of//! the rod, so the two slots' prisms are what the sweep takes from the rod.usesuper::torus_slid_through_rod::shadow;
usecrate::solids::*;
pubfnbuild() -> R<Body> {
letmut rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
for (y, tube) in [(0.0, 2.0), (1.5, 1.5)] {
let (plane, slot) = shadow(11.5, y, -9.0, 6.0, tube);
rod = cut(&rod, &extrude(&plane, slot, 0.0, 40.0)?)?;
}
Ok(rod)
}
Time
11 ms; CPU time 11 ms; peak memory 10.1 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 rod grooved by a wheel of two beads slid along it. brepkit sweeps faces, not solids, so the//! wheel's sweep is built by elementary geometry: the sweep of a union is the union of the sweeps,//! and each bead, a torus with its axis along y, slid along z fills itself at each end and the//! prism of its outline seen along z between them: the stadium of its tube's two meridian discs in//! the plane through its centre and the band between them. For the first bead (tube centres at//! radius 6 about (11.5, 0, −9), tube radius 2) that is the stadium about y = 0 of half-width 2;//! for the second (centre 1.5 further along y, tube radius 1.5) the stadium about y = 1.5 of//! half-width 1.5. The beads at each end of the slide, 40 along z, lie wholly below and above the//! rod, so the rod is cut by the two prisms alone.use brepkit_operations::extrude::extrude;
use brepkit_operations::primitives::make_cylinder;
use brepkit_topology::solid::SolidId;
use brepkit_topology::Topology;
usecrate::solids::sweep::stadium;
usecrate::solids::{cut, v};
usecrate::Refusal;
pubfnbuild(topo: &mutTopology) -> Result<SolidId, Refusal> {
let rod = make_cylinder(topo, 5.0, 20.0)?;
let first = stadium(topo, 11.5, 0.0, -9.0, 6.0, 2.0)?;
let first = extrude(topo, first, v(0.0, 0.0, 1.0), 40.0)?;
let second = stadium(topo, 11.5, 1.5, -9.0, 6.0, 1.5)?;
let second = extrude(topo, second, v(0.0, 0.0, 1.0), 40.0)?;
let rod = cut(topo, rod, first)?;
Ok(cut(topo, rod, second)?)
}
Time
69 ms; CPU time 131 ms; peak memory 28.4 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 rod of radius 5 on the z axis from z = 0 to 20, grooved by a wheel of two beads on one axis// parallel to y, slid without turning 40 along z from below the rod to above it: the first bead// centred at (11.5, 0, -9) with centre circle 6 and tube 2, the second at (11.5, 1.5, -9) with// centre circle 6 and tube 1.5.//// popkern has no sweep of a solid. The wheel's sweep is the union of its beads' sweeps. Sliding// fills each bead's hole (the slide, 40, is longer than any hole is wide), so a bead sweeps what// the solid of its outline does: the convex solid of revolution about its axis whose section is// the tube's outer half-disc joined to the axis. That solid slid along z is itself at each end// of the slide and, between, its section through its centre square to the slide (a stadium:// x = 11.5 ± 6 with half-discs of the tube's radius, across the tube in y) carried along the// slide. At its ends the wheel is wholly below the rod (its top at z = -1) and wholly above it// (its bottom at z = 23), so of everything it passes through only the two stadiums extruded from// z = -9 to 31 meet the rod.fnstadium(m, y, r, label) {
m.profile(xy_at(-9.0))
.path(5.5, y - r).line_to(17.5, y - r).arc_to([17.5 + r, y], [17.5, y + r])
.line_to(5.5, y + r).arc_to([5.5 - r, y], [5.5, y - r]).close()
.sketch(label).extrude(blind(40.0))
}
let m = model();
let rod = m.profile(xy()).circle(5.0).sketch("rod").extrude(blind(20.0));
let swept = m.tool(|m| {
let first = stadium(m, 0.0, 2.0, "first_bead");
let second = m.tool(|m| stadium(m, 1.5, 1.5, "second_bead"));
first.union(second)
});
rod = rod.subtract(swept, #{ label: "groove" });
m
Time
400 ms; CPU time 396 ms; peak memory 84.4 MB
Notes
wrong its STEP is no solid: face #41: a face whose loops bound no region of its surface
Workaround † no sweep of a solid
Data
No measures: it built no solid to measure.
STEP
B-rep advanced faces, each on a surface AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF
// The wheel's sweep follows by elementary geometry. Seen along z, edge on, each bead is a slot: the// disc of its tube's radius carried along its tube's centres, from x = 5.5 to 17.5. Sliding along// z from wholly below the rod to wholly above it, the wheel passes through everything above or// below either slot, so the rod loses the prism on each: two through cuts, one for each bead.ModelTwoBeadsSlidThroughRod {
units: mm
Profile rodSection = Circle2 { center: [0mm, 0mm]; radius: 5mm }
Profile firstBeadEdgeOn = Slot2 { center: [11.5mm, 0mm]; length: 16mm; width: 4mm }
Profile secondBeadEdgeOn = Slot2 { center: [11.5mm, 1.5mm]; length: 15mm; width: 3mm }
Compose rod {
Base stock { profile: rodSection; from: 0mm; to: 20mm; role: Stock }
RemoveOffset<Prism> firstGroove { Target: rod; On: Top; Profile: firstBeadEdgeOn; Termination: ThroughAll }
RemoveOffset<Prism> secondGroove { Target: rod; On: Top; Profile: secondBeadEdgeOn; Termination: ThroughAll }
}
}
Time
45 ms; CPU time 45 ms; peak memory 18.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.
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything a wheel of two beads//! passes through as it slides without turning 40 up the z axis. The beads are tori on one axis//! parallel to y through (11.5, 0, −9): the first centred there, of radii 6 and 2, the second//! centred 1.5 further along the axis, of radii 6 and 1.5; the wheel is their union.//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): what a union sweeps is the union of//! what its parts sweep: each bead, a solid of revolution about the line through (11.5, 0, −9)//! along y whose meridian is its tube's circle, slid 40 up, and both cut from the rod.usecrate::solids::p;
usecrate::solids::swept::{less_all, revolved_tool, slide_by, Piece};
usecrate::Refusal;
use brep_kernel::{make_cylinder_brep, sweep_solid, BrepSolid};
use std::f64::consts::{TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let (x, z) = (p(1.0, 0.0, 0.0), p(0.0, 0.0, 1.0));
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), z, 5.0, 20.0)?;
let bead = |along: f64, tube: f64| revolved_tool(p(11.5, 0.0, -9.0), p(0.0, 1.0, 0.0), x, &[
Piece::Arc { centre: [6.0, along], radius: tube, start: 0.0, end: TAU },
]);
let up = slide_by(p(0.0, 0.0, 40.0));
less_all(rod, vec![sweep_solid(&bead(0.0, 2.0), &up)?, sweep_solid(&bead(1.5, 1.5), &up)?])
}
Time
286 ms; CPU time 286 ms; peak memory 19.8 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 rod, the cylinder of radius 5 about the z axis from z = 0 to 20, grooved by a wheel of two//! beads slid 40 along z, from wholly below the rod to wholly above it: two tori on one axis//! along y, the first centred (11.5, 0, −9), tube radius 2, the second (11.5, 1.5, −9), tube//! radius 1.5, each with its tube's centres on a circle of radius 6.//!//! geop sweeps a profile, not a solid, so what the wheel passes through is built from what it is.//! Sliding along z, each bead fills at each height everything that some height of it covers://! wherever all of it has passed (from z = −1 to z = 21 for both, which takes in the rod), that is//! its shadow along z, the slot between the circles of its tube's radius about (5.5, y) and//! (17.5, y) and the lines tangent to both. So each bead's slot, sketched on a plane at z = −1 and//! extruded 22, to z = 21, is cut from the rod.usecrate::shared::paths::{offset_plane, slot};
usecrate::shared::{Drawing, extrude, sketch, xy};
usecrate::{Bench, Refusal};
use geop_core_math::primitives::FrameAxis;
use geop_ops_model::Combine;
pubfnbuild(b: &mutBench) -> Result<(), Refusal> {
letmut end = Drawing::new();
end.circle([0.0, 0.0], 5.0);
sketch(b, "end", xy(), end)?;
extrude(b, "rod", "end", 20.0, Combine::NewBody)?;
let below = offset_plane(b, "below", FrameAxis::Z, -1.0)?;
for (id, y, radius) in [("first_bead", 0.0, 2.0), ("second_bead", 1.5, 1.5)] {
let shadow = format!("{id}_shadow");
sketch(b, &shadow, below.clone(), slot(y, radius))?;
let rod = b.solid()?;
extrude(b, id, &shadow, 22.0, Combine::cut(rod))?;
}
Ok(())
}
Time
57 ms; CPU time 132 ms; peak memory 20.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 rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel of//! two beads slid past it: tori on one axis parallel to y, the first centered (11.5, 0, −9) of//! radii 6 and 2, the second centered (11.5, 1.5, −9) of radii 6 and 1.5, their union slid//! without turning 40 up the z axis, cut from the rod.//!//! Each bead is cadrs's torus primitive, the wheel their union; its slide is cadrs's sweep of a//! solid (`Kernel::cut_swept`, one slide of 40 up the z axis), cut from the rod.usecrate::bench::{p3, torus, union, v3};
usecrate::shared::swept::{cut_swept, rod, slide};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let body = rod(k)?;
let first = torus(k, p3(11.5, 0.0, -9.0), v3(0.0, 1.0, 0.0), 6.0, 2.0)?;
let second = torus(k, p3(11.5, 1.5, -9.0), v3(0.0, 1.0, 0.0), 6.0, 1.5)?;
let wheel = union(k, first, second)?;
cut_swept(k, body, wheel, &slide(v3(0.0, 0.0, 40.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
133 ms; CPU time 132 ms; peak memory 9.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.
//! The rod of radius 5 about the z axis from z = 0 to z = 20 less everything a wheel of two beads//! passes through as it slides 40 along z: two tori on the line through (11.5, 0, −9) along y, the//! first about (11.5, 0, −9) with radii 6 and 2, the second about (11.5, 1.5, −9) with radii 6 and//! 1.5.use springrep::boolean::difference;
use springrep::primitive::torus;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::swept::{rod, unite, v3};
usecrate::shared::{e, frame};
pubfnbuild() -> Result<Brep, String> {
let first = frame([11.5, 0.0, -9.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0])?;
let second = frame([11.5, 1.5, -9.0], [0.0, 1.0, 0.0], [1.0, 0.0, 0.0])?;
let wheel = unite(&[
&torus(&first, 6.0, 2.0, "bead").map_err(e)?,
&torus(&second, 6.0, 1.5, "bead").map_err(e)?,
])?;
let groove = solid(&wheel, &Motion::Slide(v3(0.0, 0.0, 40.0)), "groove").map_err(e)?;
difference(&rod()?, &groove).map_err(e)
}
Time
136 ms; CPU time 240 ms; peak memory 38.6 MB
Notes
wrong volume 1486.45581284 against 1486.44986675 (its STEP's); area 787.231560347 against 787.234903804 (its STEP's)
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
1486.455813
1486.449867
4.0e-06
area
787.2315603
787.2349038
4.2e-06
agrees with
no other kernel
mesh
11348 triangles, closed
centre of gravity
(-0.244655, -0.00934902, 10) its STEP's solid
inertia
about it, of unit density: Ixx 59284.3; Iyy 57698.1; Izz 17885.3; Ixy 63.1163; Iyz -1.00122e-13; Izx -1.63864e-12
// A rod grooved by a wheel of two beads slid along it. The rod is the cylinder of radius 5 about// z from z = 0 to 20. The beads are two tori on one axis, along y through (11.5, 0, -9): the// first centred there, its tube (radius 2) 6 from the axis; the second centred 1.5 further along// the axis, its tube (radius 1.5) also 6 from it. Each is its tube's circle drawn in the plane// through the axis and x and turned about the axis; the wheel is their union. It slides 40 up z,// and the kernel's sweep of the wheel is cut from the rod.unit mm
use std
use std.solids (cut, union)
use std.place (coords, on_u)
use std.motion (slides)
in std.top {
private o := point
fix((0, 0)) o
private rod_rim := circle(center: o) hint(r: 5)
radius(5mm) rod_rim
}
part := solid(std.solids.Prism(face(rod_rim), from: 0mm, to: 20mm))
// the beads, drawn in the level plane through their axis, below the rodprivate across := axis
fix(dir == (1, 0, 0)) across
private along := axis
fix(dir == (0, 1, 0)) along
bench := plane(u: across, v: along)
fix(origin == (0, 0, -9)) bench
in bench {
private a0 := point
private a1 := point
a0 coords(du: 11.5mm, dv: -1mm) bench
a1 coords(du: 11.5mm, dv: 1mm) bench
private wheel_axis := line(a0, a1)
private tc := point
tc on_u(d: 5.5mm) bench
private tube := circle(center: tc) hint(r: 2)
radius(2mm) tube
private tc2 := point
tc2 coords(du: 5.5mm, dv: 1.5mm) bench
private tube2 := circle(center: tc2) hint(r: 1.5)
radius(1.5mm) tube2
}
construction bead := solid(std.solids.Revolution(face(tube), about: wheel_axis))
construction bead2 := solid(std.solids.Revolution(face(tube2), about: wheel_axis))
construction wheel := solid(bead)
bead2 union wheel
feed := frame
feed slides(40mm) std.z
construction groove := solid({ p | some t in (0deg, 360deg): p in wheel at(under: feed) t })
groove cut part
anvilcad left no solid to show.
Time
41 ms; CPU time 40 ms; peak memory 5.3 MB
Notes
refused boolean operation failed: face split did not close
//! A rod of radius 5 on the z axis from z = 0 to 20 grooved by a wheel of two beads on one axis along y through (11.5, 0, −9), tori of middle circle 6 with tubes 2 and 1.5 (the second 1.5 along the axis), slid along z past it, from//! below the rod to above it.use anvil_brep::{Solid, extrude};
usecrate::shared::{cylinder, e, frame, region, rod, stadium, subtract, torus, unite_all};
/// What a torus whose axis runs along y through (11.5, `y`, −9) (middle circle 6, tube `r`)/// fills as it slides 38 along z: the tube of radius `r` about the stadium its middle circle/// sweeps (its slab, the torus at each end, and a rod along each straight side).fnslid(y: f64, r: f64) -> Result<Solid, String> {
// anvil-brep has no sweep of a solid; a torus slid in its own plane is that tubelet plane = frame([0., y, 0.], [0., 1., 0.], [1., 0., 0.])?;
// in the plane y = const, its sketch x along world x and its sketch y along world −zlet stadium = region(&[stadium((11.5, -29.), (11.5, 9.), 6.)])?;
let slab = extrude::extrude(&plane, &stadium, -r, r).map_err(e)?;
let wheel = |z: f64| torus(&frame([11.5, y, z], [0., 1., 0.], [1., 0., 0.])?, 6., r);
// each joined to what is built so far, which it overlapslet pieces = [wheel(-9.), wheel(29.), rod([5.5, y, -9.], [5.5, y, 29.], r), rod([17.5, y, -9.], [17.5, y, 29.], r)];
unite_all(slab, pieces)
}
pubfnbuild() -> Result<Solid, String> {
let rod_ = cylinder(&anvil_brep::Frame::world(), 5., 0., 20.)?;
// the sweep of the two beads' union is the union of their sweepssubtract(&subtract(&rod_, &slid(0., 2.)?)?, &slid(1.5, 1.5)?)
}