A block, the box from (−6, −6, −8) to (18, 18, 0), with a curved groove cut into its top face by a ball. The ball has radius 3 and its center starts at (12, 0, 0), on the top face, so it is half sunk in the block. It swings a quarter turn about the z axis, right-handed (from +x toward +y), so that its center ends at (0, 12, 0); its center stays in the top face all the way. Cut from the block everything the ball passes through.
The groove is a round-bottomed channel: a quarter of a torus's tube below the top face, closed at each end by a quarter of the ball.
† works around a missing feature. ✦ an elegant solution. ▦ 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
6.9 ms; CPU time 9.6 ms; peak memory 11.3 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Elegant ✦ the kernel sweeps the ball itself; no torus and end balls assembled by hand
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 block (−6, −6, −8)–(18, 18, 0) with a groove cut into its top face by a ball of radius 3 whose//! centre swings a quarter turn about the z axis, right-handed, from (12, 0, 0) to (0, 12, 0).usecrate::sketch::block;
use cad_kernel::boolean::{combined, Op};
use cad_kernel::build::canal;
use cad_kernel::topo::Brep;
use std::f64::consts::FRAC_PI_2;
constRADIUS: f64 = 3.;
constSWING_RADIUS: f64 = 12.;
constSWING: f64 = FRAC_PI_2;
pubfnbuild() -> Result<Brep, String> {
let stock = block([-6., -6., -8.], [18., 18., 0.])?;
// everything the ball passes through as it turns about z, by cad-kernel's own sweep of a// ball: the canal of a turn with no advance, the disc square to the path turned (a quarter of// a torus) with the half ball beyond each end disclet start = [SWING_RADIUS, 0., 0.];
let swept = canal(start, RADIUS, [0., 0., 0.], [0., 0., 1.], SWING, 0., "groove")?;
Ok(combined(&stock, &swept, Op::Cut, 0.)?)
}
Time
649 ms; CPU time 649 ms; peak memory 369.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 groove swung by a ball. A block, the box from (−6, −6, −8) to (18, 18, 0), with a curved
groove cut into its top face by a ball. The ball has radius 3 and its centre starts at (12, 0, 0),
on the top face, so it is half sunk in the block. It swings a quarter turn about the z axis,
right-handed (from +x towards +y), so that its centre ends at (0, 12, 0); its centre stays in the
top face all the way. Cut from the block everything the ball passes through.
The groove is a round-bottomed channel: a quarter of a torus's tube below the top face, closed at
each end by a quarter of the ball."""import math
fromOCP.BRepAlgoAPIimportBRepAlgoAPI_Cut, BRepAlgoAPI_Fuse, BRepAlgoAPI_SplitterfromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeFacefromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeRevol, BRepPrimAPI_MakeSpherefromOCP.TopAbsimportTopAbs_SHELL, TopAbs_SOLIDfromOCP.TopExpimportTopExp_ExplorerfromOCP.collections importList_TopoDS_ShapefromOCP.gp import gp, gp_Ax2, gp_Pln, gp_Pnt
from bench importRefusedBLOCK_LOW, BLOCK_HIGH = (-6, -6, -8), (18, 18, 0)
BALL_RADIUS = 3SWING_RADIUS = 12# the centre's distance from the z axisSWING = 90# degrees, about the z axisdefshapes(*items):
listed = List_TopoDS_Shape()
for item in items:
listed.Append(item)
return listed
defbuild():
start = gp_Pnt(SWING_RADIUS, 0, 0)
end = gp_Pnt(SWING_RADIUS * math.cos(math.radians(SWING)),
SWING_RADIUS * math.sin(math.radians(SWING)), 0)
# The ball's poles on the y axis, so its equator lies in the plane y = 0.
ball = BRepPrimAPI_MakeSphere(gp_Ax2(start, gp.DY_s()), BALL_RADIUS).Shape()
ball_at_end = BRepPrimAPI_MakeSphere(end, BALL_RADIUS).Shape()
# OCCT's revolution 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 motion never runs along it inside it: a point p of the ball moves along# z × p, which runs along the sphere where (z × p)·(p − c) = 0, that is (z × c)·(p − c) = 0# for the centre c = (12, 0, 0): the great circle in the plane y = 0, through the axis and# the centre. So split the sphere there, into the half facing the turn and the half facing# away; each half then sweeps without folding, and that circle sweeps to the torus's tube.
reach = 2 * SWING_RADIUS# the splitting face, a square well past the ball
plane = BRepBuilderAPI_MakeFace(gp_Pln(gp.Origin_s(), gp.DY_s()),
-reach, reach, -reach, reach).Face()
splitter = BRepAlgoAPI_Splitter()
splitter.SetArguments(shapes(TopExp_Explorer(ball, TopAbs_SHELL).Current()))
splitter.SetTools(shapes(plane))
splitter.Build()
ifnot splitter.IsDone():
raiseRefused("BRepAlgoAPI_Splitter could not split the ball along its equator")
revol = BRepPrimAPI_MakeRevol(splitter.Shape(), gp.OZ_s(), math.radians(SWING))
ifnot revol.IsDone():
raiseRefused("BRepPrimAPI_MakeRevol could not swing the ball's faces")
# Everything the ball passes through is the ball where it starts, the ball where it ends, and# everything its faces pass through: a point the ball covers that no face ever crosses stays# inside the ball all the way.
tools = shapes(ball_at_end)
swept = TopExp_Explorer(revol.Shape(), TopAbs_SOLID)
while swept.More():
tools.Append(swept.Current())
swept.Next()
fuse = BRepAlgoAPI_Fuse()
fuse.SetArguments(shapes(ball))
fuse.SetTools(tools)
fuse.Build()
ifnot fuse.IsDone():
raiseRefused("BRepAlgoAPI_Fuse declined the faces' sweeps and the ball at each end")
block = BRepPrimAPI_MakeBox(gp_Pnt(*BLOCK_LOW), gp_Pnt(*BLOCK_HIGH)).Shape()
cut = BRepAlgoAPI_Cut(block, fuse.Shape())
ifnot cut.IsDone():
raiseRefused("BRepAlgoAPI_Cut declined the groove")
return cut.Shape()
Time
23 ms; CPU time 23 ms; peak memory 10.7 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a solid, no sphere primitive
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 block, the box from (−6, −6, −8) to (18, 18, 0), with a groove cut into its top face by a//! ball of radius 3 whose centre swings a quarter turn about the z axis in the top face, from//! (12, 0, 0) to (0, 12, 0).//!//! arris has no sweep of a solid, so the ball's sweep is built from what it is by elementary//! geometry: every point within 3 of the quarter circle its centre runs along. That is the tube//! the ball's great disc square to the circle fills as it turns, a quarter of a torus, with half a//! ball on each end, bulging out of the turn: the ball's other half lies inside the tube.use arris::geom::{Profile, ProfileLoop, ProfileSegment};
use arris::math::{Axis, Control, Frame, Point2, Point3, Vec3};
use arris::ops::{cut, fuse_many, primitive_box, revolve, OpError};
use arris::topo::{Body, Model};
use std::f64::consts::{FRAC_1_SQRT_2, FRAC_PI_2, TAU};
constBLOCK_LOW: [f64; 3] = [-6.0, -6.0, -8.0];
constBLOCK_HIGH: [f64; 3] = [18.0, 18.0, 0.0];
constBALL_RADIUS: f64 = 3.0;
/// The centre's distance from the z axis, which it keeps as it swings.constSWING_RADIUS: f64 = 12.0;
constSWING: f64 = FRAC_PI_2;
/// A half ball of `radius` on the disc about `centre` square to `outward`, bulging along it: the/// quarter disc in a plane through `outward`, turned about it.fnhalf_ball(m: &mutModel, centre: Point3, outward: Vec3, radius: f64) -> Result<Body, OpError> {
let across = Frame::from_z(centre, outward)?.x().into_inner();
let (r, h) = (radius, radius * FRAC_1_SQRT_2);
let quarter_disc = Profile {
plane: Frame::new(centre, across.cross(&outward), across)?,
outer: ProfileLoop::Path {
start: Point2::origin(),
segments: vec![
ProfileSegment::LineTo(Point2::new(r, 0.0)),
ProfileSegment::ArcTo { to: Point2::new(0.0, r), via: Point2::new(h, h) },
ProfileSegment::LineTo(Point2::origin()),
],
},
holes: vec![],
};
Ok(revolve(m, &quarter_disc, Axis::new(centre, outward)?, TAU, &Control::NONE)?.0)
}
pubfnbuild(m: &mutModel) -> Result<Body, OpError> {
let [x0, y0, z0] = BLOCK_LOW;
let [x1, y1, z1] = BLOCK_HIGH;
let (block, _) =
primitive_box(m, Point3::new(x0, y0, z0), Point3::new(x1, y1, z1), &Control::NONE)?;
// the ball's great disc in the xz plane where it starts, turned with it a quarter turn about// z: the xz plane's normal −y, so a positive turn about z leaves it towards +ylet xz = Frame::new(Point3::origin(), -Vec3::y(), Vec3::x())?;
let disc = Profile {
plane: xz,
outer: ProfileLoop::Circle { center: Point2::new(SWING_RADIUS, 0.0), radius: BALL_RADIUS },
holes: vec![],
};
let (tube, _) = revolve(m, &disc, Axis::z_at(Point3::origin()), SWING, &Control::NONE)?;
// the ends: the ball leaves its start going +y and arrives at its end going −x, so the halves// outside the tube bulge −y at the start and −x at the endlet start = Point3::new(SWING_RADIUS, 0.0, 0.0);
let end = Point3::new(0.0, SWING_RADIUS, 0.0);
let back = half_ball(m, start, -Vec3::y(), BALL_RADIUS)?;
let front = half_ball(m, end, -Vec3::x(), BALL_RADIUS)?;
// the half balls' flat faces are the tube's end caps, which the fuse removeslet (swept, _) = fuse_many(m, &[tube, back, front], &Control::NONE)?;
let (grooved, _) = cut(m, block, swept, &Control::NONE)?;
Ok(grooved)
}
Time
12 ms; CPU time 12 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.
//! A block, the box from (−6, −6, −8) to (18, 18, 0), with a groove cut into its top face by a//! ball of radius 3 whose centre swings a quarter turn about the z axis, right-handed, from//! (12, 0, 0) to (0, 12, 0), staying in the top face: everything the ball passes through, cut.//!//! The ball's sweep is kentron's sweep of a solid (`sweep::solid`, one turn), cut from the block.usecrate::bench::{frame, p};
use kentron::math::{Axis, Direction};
use kentron::primitives::{Cuboid, Sphere};
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
use std::f64::consts::FRAC_PI_2;
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let block = Cuboid::from_corners(p(-6.0, -6.0, -8.0), p(18.0, 18.0, 0.0)).build(m)?;
let ball = Sphere::new(3.0).with_frame(frame(p(12.0, 0.0, 0.0), Direction::Z)).build(m)?;
let swept = sweep::solid(m, ball, &RigidMotion::Turn { axis: Axis::Z, from: 0.0, to: FRAC_PI_2 })?;
kentron::boolean::difference(m, block, swept)
}
vcad left no solid to show.
Time
41.0 s; CPU time 41.0 s; peak memory 249.5 MB
Notes
wrong its STEP's faces do not close into a solid
Workaround † no sweep of a solid
Faceted ▦ 42102 faces, where the other kernels' solids have 10 (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
42102: 42102 plane; 42074 flat triangles
STEP edges
63756: 63756 line; 1234 not bounding exactly two sides of faces, so the shell is open
//! A block, the box from (−6, −6, −8) to (18, 18, 0), with a groove cut into its top face by a//! ball of radius 3 whose centre swings a quarter turn about the z axis in the top face, from//! (12, 0, 0) to (0, 12, 0).//!//! vcad has no sweep of a solid, so the ball's sweep is built from what it is by elementary//! geometry: every point within 3 of the quarter circle its centre runs along. That is the tube the//! ball's great disc square to the circle fills as it turns, the quarter of the torus about the//! z axis (radii 12 and 3) between the half planes x = 0 and y = 0, with a ball at each end: half//! of each lies inside the tube.usecrate::solids::SEGMENTS;
use vcad_kernel::Solid;
constBLOCK_MIN: [f64; 3] = [-6.0, -6.0, -8.0];
constBLOCK_MAX: [f64; 3] = [18.0, 18.0, 0.0];
constBALL_RADIUS: f64 = 3.0;
/// The ball's centre's distance from the z axis.constSWING: f64 = 12.0;
pubfnbuild() -> Result<Solid, crate::Refusal> {
let [x0, y0, z0] = BLOCK_MIN;
let [x1, y1, z1] = BLOCK_MAX;
let block = Solid::cube(x1 - x0, y1 - y0, z1 - z0).translate(x0, y0, z0);
// vcad's torus is centred on the origin about the z axis; the quarter of it the ball turns// through is what lies in a box on the quadrant x, y ≥ 0, reaching past the torus elsewherelet torus = Solid::torus(SWING, BALL_RADIUS, SEGMENTS);
let reach = 2.0 * (SWING + BALL_RADIUS);
let quadrant = Solid::cube(reach, reach, reach).translate(0.0, 0.0, -reach / 2.0);
let tube = torus.try_intersection(&quadrant)?;
let ball = |x: f64, y: f64| Solid::sphere(BALL_RADIUS, SEGMENTS).translate(x, y, 0.0);
// the tube and the ball at each end, each cut in turnlet grooved = block.try_difference(&tube)?;
let grooved = grooved.try_difference(&ball(SWING, 0.0))?;
Ok(grooved.try_difference(&ball(0.0, SWING))?)
}
Time
237 ms; CPU time 236 ms; peak memory 52.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 block, the box from (−6, −6, −8) to (18, 18, 0), with a groove cut by a ball of radius 3//! whose centre swings a quarter turn about the z axis in the top face, from (12, 0, 0) to//! (0, 12, 0).//!//! solidcraft-kernel has no sweep of a solid, so the ball's sweep is built by elementary geometry://! every point within 3 of the arc its centre runs along, which is the ball's great disc in the//! plane through the axis turned the quarter turn (a quarter of a torus's tube) with the ball at//! each end. Half of each end ball lies inside the tube; the other half is the half ball on the//! tube's end disc, outside it, joined to the tube on that disc. (The whole ball joined or cut//! meets the tube only tangentially, along its end disc's rim, and the kernel's boolean finds no//! result there.)usecrate::solids::*;
/// The half of the ball of `radius` about `centre` on the side of the plane through `centre` that/// `outward` points to.pubfnhalf_ball(centre: Vec3, outward: Vec3, radius: f64) -> R<Body> {
let ball = solidcraft_kernel::sphere(centre, radius)?;
let cap = Plane::from_normal(centre, outward)
.ok_or_else(|| KernelError::Invalid("the half ball's direction".into()))?;
solidcraft_kernel::half_space(&ball, &cap, true)?
.0
.ok_or_else(|| KernelError::Failed("the half ball is empty".into()))
}
pubfnbuild() -> R<Body> {
let block = block((-6.0, -6.0, -8.0), (18.0, 18.0, 0.0))?;
// the disc about (12, 0, 0) in the xz plane, turned a quarter turn from +x towards +yletmut swept = revolve_z(disc((12.0, 0.0), 3.0), 90.0)?;
// the half balls beyond the tube's ends: it leaves (12, 0, 0) along +y and reaches (0, 12, 0)// along −xfor (end, outward) in [(v3(12.0, 0.0, 0.0), -Vec3::Y), (v3(0.0, 12.0, 0.0), -Vec3::X)] {
swept = union(&swept, &half_ball(end, outward, 3.0)?)?;
}
cut(&block, &swept)
}
Time
511 ms; CPU time 512 ms; peak memory 31.2 MB
Notes
wrong volume 4287.00220092 against 4284.97201341 (its STEP's); area 2012.40028122 against 2012.82987757 (its STEP's)
Workaround † no sweep of a solid
Faceted ▦ 1034 faces, where the other kernels' solids have 10 (the median): a mesh stored as B-rep faces.
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
4287.002201
4284.972013
4.7e-04
area
2012.400281
2012.829878
2.1e-04
agrees with
no other kernel
mesh
2300 triangles, closed
centre of gravity
(5.89891, 5.89872, -4.20588) its STEP's solid
inertia
about it, of unit density: Ixx 235583; Iyy 235588; Izz 427643; Ixy -4759.21; Iyz 1271.23; Izx 1264.86
//! A block grooved by a ball of radius 3 swung a quarter turn about the z axis. brepkit sweeps//! faces, not solids, so the ball's sweep is built by elementary geometry: a ball moving along a//! path fills the tube about its centre's path with a ball at each end. Here the tube is the disc//! of radius 3 about (12, 0, 0) in the xz plane revolved a quarter turn about the z axis, and the//! balls are about (12, 0, 0) and (0, 12, 0). The groove is cut from the box from (−6, −6, −8) to//! (18, 18, 0).use std::f64::consts::FRAC_PI_2;
use brepkit_operations::primitives::{make_box, make_sphere};
use brepkit_operations::revolve::revolve;
use brepkit_topology::solid::SolidId;
use brepkit_topology::Topology;
usecrate::solids::sweep::disc;
usecrate::solids::{cut, fuse, moved, p, v};
usecrate::Refusal;
pubfnbuild(topo: &mutTopology) -> Result<SolidId, Refusal> {
let block = make_box(topo, 24.0, 24.0, 8.0)?;
let block = moved(topo, block, -6.0, -6.0, -8.0)?;
let section = disc(topo, p(12.0, 0.0, 0.0), v(0.0, 1.0, 0.0), 3.0)?;
let tube = revolve(topo, section, p(0.0, 0.0, 0.0), v(0.0, 0.0, 1.0), FRAC_PI_2)?;
let ball = make_sphere(topo, 3.0, 64)?;
let start = moved(topo, ball, 12.0, 0.0, 0.0)?;
let ball = make_sphere(topo, 3.0, 64)?;
let end = moved(topo, ball, 0.0, 12.0, 0.0)?;
let swept = fuse(topo, tube, start)?;
let swept = fuse(topo, swept, end)?;
Ok(cut(topo, block, swept)?)
}
Time
179 ms; CPU time 218 ms; peak memory 29.9 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.
fnball(m, r) {
m.sphere(r)
}
// A block from (-6, -6, -8) to (18, 18, 0), with a groove cut by a ball of radius 3 whose centre// swings a quarter turn about the z axis from (12, 0, 0) to (0, 12, 0).//// popkern has no sweep of a solid; a ball's sweep is the tube about its centre's path with a ball// at each end. The tube is the quarter of the torus about z (centre circle 12, tube 3) between// the planes x = 0 and y = 0: the whole torus revolved and cut down to the quadrant, since a// revolve through part of a turn makes NURBS faces where a full turn makes the exact torus. The// tube and the balls are cut from the block one after another.let m = model();
let block = m.profile(xy_at(-8.0)).rect(24.0, 24.0).at(6.0, 6.0)
.sketch("block").extrude(blind(8.0));
let tube = m.tool(|m| {
let torus = m.profile(xz()).circle(3.0).at(12.0, 0.0).sketch("tube")
.revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), full_circle());
let quadrant = m.tool(|m| m.profile(xy_at(-5.0)).rect(20.0, 20.0).at(10.0, 10.0)
.sketch("quadrant").extrude(blind(10.0)));
torus.intersect(quadrant)
});
block = block.subtract(tube, #{ label: "channel" });
let start = m.tool(|m| ball(m, 3.0).translate(12.0, 0.0, 0.0));
block = block.subtract(start, #{ label: "start_end" });
let finish = m.tool(|m| ball(m, 3.0).translate(0.0, 12.0, 0.0));
block = block.subtract(finish, #{ label: "finish_end" });
m
aetheris left no solid to show.
Time
225 ms; CPU time 217 ms; peak memory 71 MB
Notes
refused path-feature-arc: groove: open arcs currently require Flat ends and a positive sweep no greater than 180deg.
// The ball's sweep follows by elementary geometry: its centre stays in the top face, so the groove// is a semicircular channel of radius 3 along the quarter arc its centre travels, closed at each// end by a quarter ball: a Groove<Semicircular> with round ends.//// A Box stands centred on the z axis from z = 0, and a Model cannot move it, so this block is the// case's moved by (−6, −6, 8): the arc is about (−6, −6), from (6, −6) to (−6, 6).ModelBallSwungGroove {
units: mm
Path swing {
start: Point2(6mm, -6mm)
heading: 90degArc quarter { radius: 12mm; turn: 90deg }
}
Box block { size: [24mm, 24mm, 8mm] }
Modify block {
Groove<Semicircular> groove { on: +Z; path: swing; radius: 3mm; ends: Round }
}
}
Time
92 ms; CPU time 92 ms; peak memory 20.3 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 box from (−6, −6, −8) to (18, 18, 0), less everything a ball of radius 3 passes through as//! its centre swings a quarter turn about the z axis, right-handed, from (12, 0, 0) to (0, 12, 0).//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the ball, a solid of revolution//! about the upright line through (12, 0, 0) whose meridian is the half disc of radius 3, turned a//! quarter turn about the z axis, and cut from the block.usecrate::solids::p;
usecrate::solids::swept::{less_all, revolved_tool, turn_about_z, Piece};
usecrate::Refusal;
use brep_kernel::{make_box_brep, sweep_solid, BrepSolid};
use std::f64::consts::{FRAC_PI_2};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let (x, z) = (p(1.0, 0.0, 0.0), p(0.0, 0.0, 1.0));
let block = make_box_brep(p(-6.0, -6.0, -8.0), 24.0, 24.0, 8.0)?;
let ball = revolved_tool(p(12.0, 0.0, 0.0), z, x, &[
Piece::Arc { centre: [0.0, 0.0], radius: 3.0, start: -FRAC_PI_2, end: FRAC_PI_2 },
Piece::Line { from: [0.0, 3.0], to: [0.0, -3.0] },
]);
less_all(block, vec![sweep_solid(&ball, &turn_about_z(0.0, FRAC_PI_2, 0.0))?])
}
Time
2.04 s; CPU time 2.04 s; peak memory 20.2 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep of a solid, no sphere primitive
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 block, the box from (−6, −6, −8) to (18, 18, 0), with a groove cut into its top by a ball of//! radius 3 whose centre swings a quarter turn about the z axis in the top face, from (12, 0, 0)//! to (0, 12, 0).//!//! geop sweeps a profile, not a solid, so what the ball passes through is built as what it is://! the tube about its centre's path — the ball's great circle on the xz plane, about (12, 0, 0),//! turned a quarter turn about the z axis — and the ball at each end (turned from a half disc).//! Each is cut from the block.usecrate::shared::paths::ball;
usecrate::shared::{Drawing, axis, extrude, revolve, sketch, xy, zx, zx_at};
usecrate::{Bench, Refusal};
use geop_core_math::primitives::FrameAxis;
use geop_ops_model::Combine;
pubfnbuild(b: &mutBench) -> Result<(), Refusal> {
letmut base = Drawing::new();
base.rectangle([-6.0, -6.0], [18.0, 18.0]);
sketch(b, "base", xy(), base)?;
extrude(b, "block", "base", -8.0, Combine::NewBody)?;
letmut section = Drawing::new();
section.circle(zx_at(12.0, 0.0), 3.0);
sketch(b, "section", zx(), section)?;
let block = b.solid()?;
// Turned from +x towards +y: −90° as geop's revolve counts it for a profile on the xz plane.revolve(b, "groove", "section", axis(FrameAxis::Z), -90.0, Combine::cut(block))?;
for (id, centre) in [("first_end", [12.0, 0.0, 0.0]), ("last_end", [0.0, 12.0, 0.0])] {
let block = b.solid()?;
ball(b, id, centre, 3.0, Combine::cut(block))?;
}
Ok(())
}
Time
12 ms; CPU time 17 ms; peak memory 10.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 block, the box from (−6, −6, −8) to (18, 18, 0), grooved by a ball of radius 3 whose//! center swings a quarter turn about the z axis in the top face, from (12, 0, 0) to (0, 12, 0)://! everything the ball passes through cut from the block.//!//! The ball is cadrs's sphere primitive; its swing is cadrs's sweep of a solid over part of a//! turn (`Kernel::cut_swept`, a rigid turn about the z axis from 0° to 90°), cut from the block.usecrate::bench::{ball, block, p3};
usecrate::shared::swept::{cut_swept, swing, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let body = block(k, p3(-6.0, -6.0, -8.0), p3(18.0, 18.0, 0.0))?;
let tool = ball(k, p3(12.0, 0.0, 0.0), 3.0)?;
cut_swept(k, body, tool, &swing(z_axis(), 0.0, 90.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
7.3 ms; CPU time 7 ms; peak memory 8.6 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 box (−6, −6, −8)–(18, 18, 0) with a groove cut by a ball of radius 3 whose center swings a//! quarter turn about the z axis from (12, 0, 0) to (0, 12, 0).use std::f64::consts::FRAC_PI_2;
use springrep::boolean::difference;
use springrep::primitive::sphere;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::swept::{boxed, turning};
usecrate::shared::{at, e};
pubfnbuild() -> Result<Brep, String> {
let block = boxed([-6.0, -6.0, -8.0], [18.0, 18.0, 0.0], "block")?;
let ball = sphere(&at([12.0, 0.0, 0.0]), 3.0, "ball").map_err(e)?;
let groove = solid(&ball, &turning(0.0, FRAC_PI_2), "groove").map_err(e)?;
difference(&block, &groove).map_err(e)
}
Time
139 ms; CPU time 263 ms; peak memory 36.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 block, the box from (-6, -6, -8) to (18, 18, 0), its top in the top plane; a ball of radius 3,// its centre 12 out along x on the top face, swung a quarter turn about the z axis, and everything// it passes through cut from the block.unit mm
use std
use std.sets
use std.solids
use std.solids (cut)
use std.motion (turns)
in std.top {
a := point
b := point hint((18, -6))
c := point hint((18, 18))
d := point hint((-6, 18))
outline := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((-6, -6)) a
a distance(24) b
b distance(24) c
}
part := solid(std.solids.Prism(outline, from: -8mm, to: 0mm))
// the ball, about its centre on the top face
o := point
fix((12, 0, 0)) o
ball := solid(std.sets.Ball(o, r: 3mm))
// the quarter turn about the z axis, right-handed from +x toward +y
swing := frame
swing turns(1) std.z
groove := solid({ p | some t in (0deg, 90deg): p in ball at(under: swing) t })
groove cut part
anvilcad left no solid to show.
Time
5.9 ms; CPU time 5.7 ms; peak memory 5 MB
Notes
refused not supported yet: the surfaces touch along their intersection
//! A block from (−6, −6, −8) to (18, 18, 0) less what a ball of radius 3 passes through, its//! center swung a quarter turn about the z axis from (12, 0, 0) to (0, 12, 0).use anvil_brep::Solid;
use anvil_brep::profile::Segment;
usecrate::shared::{ball, block, cut_all, swung, v2};
pubfnbuild() -> Result<Solid, String> {
// anvil-brep has no sweep of a solid. A ball swung about an axis is the tube about its// center's arc, its disk turned, with the ball at each endlet tube = swung(vec![Segment::circle(v2(12., 0.), 3.)], 0., 90.)?;
cut_all(block([-6., -6., -8.], [18., 18., 0.])?, [Ok(tube), ball([12., 0., 0.], 3.), ball([0., 12., 0.], 3.)])
}