A curved block, cut by the inner side of a bar turned past it about the block's own axis.
The block is a sector of a ring about the z axis: everything with distance from the z axis between 8 and 12, with z between −1 and 1, and with polar angle between 0° and 60° (measured from +x toward +y).
The bar is a box leaning out from upright in the plane y = 0. Its inner side is the plane through (10, 0, 0) square to the direction (cos 20°, 0, −sin 20°), so it faces the z axis squarely and leans out 20° from upright: at height z it stands 10 + z·tan 20° from the axis. The bar is everything from that plane to 3 beyond it along (cos 20°, 0, −sin 20°), within 2 of the plane y = 0, and within 3 of the plane through (10, 0, 0) square to (sin 20°, 0, cos 20°) (its length runs along that direction). So it stands past the block above and below, and its outer side lies beyond the block's outer wall.
The bar turns rigidly about the z axis, right-handed (from +x toward +y), from −140° to +140°: it starts clear of the block, passes through it, and ends clear of it. Cut from the block everything the bar passes through.
Every line of the inner side that runs along the bar's length is in contact all along it or not at all; the one in the plane through the axis cuts the block's new wall, a cone. What is left of the block is the part of it within 10 + z·tan 20° of the axis.
expected
closed form
volume
37.74535411
(π/6)∫((10 + z tan 20°)² − 8²) dz over |z| ≤ 1 = (π/6)(72 + (2/3)tan²20°)
area
84.88108661
top (π/6)((10 + t)² − 64) + bottom (π/6)((10 − t)² − 64) + inner wall 8·(π/3)·2 + the cone's sixth π·20·(2/cos 20°)/6 + two trapezoids 2·4, t = tan 20°
Drawing
TopIsometricFrontRight
Third-angle projection, the three views at one scale. Drawn from occt's result, which passed.
† works around a missing feature. Pick an entry to see its solid, its measures and its code.
Drag to turn, scroll or pinch to zoom, right-drag to move. The solid as its STEP file has it, meshed in the browser by Open CASCADE (occt-import-js): each face colored by the kind of its surface, and the edges that bound each face drawn between them.
Drag to turn, scroll or pinch to zoom, right-drag to move. Black lines are where the surface turns sharply; red ones, seen through the solid, are open edges, where the mesh is not closed.
Time
242 ms; CPU time 443 ms; peak memory 28.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 ring sector (radii 8 to 12 about z, z from −1 to 1, polar angle 0° to 60°) cut by a bar turned//! about z, right-handed, from −140° to +140°: the box whose inner side is the plane through//! (10, 0, 0) square to e = (cos 20°, 0, −sin 20°), facing the axis squarely, 3 deep along e, 4//! wide across y and 6 long along (sin 20°, 0, cos 20°) about (10, 0, 0).usecrate::sketch::polygon;
use cad_kernel::build::{prism, revolve};
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 cad_kernel::util::space::{add, scale};
use std::f64::consts::FRAC_PI_3;
constUP: V = [0., 0., 1.];
/// The point of the bar's inner side on the plane y = 0 through its middle.constINNER: V = [10., 0., 0.];
/// How far the bar leans out from upright, in degrees.constLEAN: f64 = 20.;
constDEPTH: f64 = 3.;
constHALF_WIDTH: f64 = 2.;
constHALF_LENGTH: f64 = 3.;
/// How far the turn carries the bar each way from where it is drawn, in degrees.constTURN: f64 = 140.;
/// The ring sector: its section in the half-plane at 0° turned 60° about z.fnsector() -> Result<Brep, String> {
let section = polygon(&[[8., 0., -1.], [12., 0., -1.], [12., 0., 1.], [8., 0., 1.]]);
revolve(§ion, [0.; 3], UP, FRAC_PI_3)
}
pubfnbuild() -> Result<Brep, String> {
let blank = sector()?;
let (s, c) = LEAN.to_radians().sin_cos();
let along = [s, 0., c];
// the inner side, a rectangle walked counter-clockwise in (y, along), so that its normal is// y × along = e, and swept 3 along elet at = |y: f64, l: f64| add(add(INNER, [0., y, 0.]), scale(along, l));
let side = polygon(&[at(-HALF_WIDTH, -HALF_LENGTH), at(HALF_WIDTH, -HALF_LENGTH),
at(HALF_WIDTH, HALF_LENGTH), at(-HALF_WIDTH, HALF_LENGTH)]);
let bar = prism(&side, 0., DEPTH)?;
// the turn about z: a screw that does not advance, a radian a radian of the rolllet path = Trajectory::Twist(Screw { origin: [0.; 3], axis: UP, ratio: 1., advance: 0. });
// the kernel's closed swept solid cut from the sector on one arrangement: the inner side's// contact line, its line in the plane through the axis, turned into a cone, and every edge// turned (a box's flat faces mesh exactly, at any bar)let size = blank.size().max(bar.size());
let turn = TURN.to_radians();
cut_from(&blank, &bar, &path, [-turn, turn], size, tolerance(size))
.map_err(|why| format!("the bar's sweep not built: {why:?}"))
}
Time
846 ms; CPU time 845 ms; peak memory 372 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 curved block cut by a bar's side facing the axis squarely. A curved block, cut by the inner
side of a bar turned past it about the block's own axis.
The block is a sector of a ring about the z axis: everything with distance from the z axis between
8 and 12, with z between −1 and 1, and with polar angle between 0° and 60° (measured from +x toward
+y).
The bar is a box leaning out from upright in the plane y = 0. Its inner side is the plane through
(10, 0, 0) square to the direction (cos 20°, 0, −sin 20°), so it faces the z axis squarely and
leans out 20° from upright: at height z it stands 10 + z·tan 20° from the axis. The bar is
everything from that plane to 3 beyond it along (cos 20°, 0, −sin 20°), within 2 of the plane y =
0, and within 3 of the plane through (10, 0, 0) square to (sin 20°, 0, cos 20°) (its length runs
along that direction). So it stands past the block above and below, and its outer side lies beyond
the block's outer wall.
The bar turns rigidly about the z axis, right-handed (from +x toward +y), from −140° to +140°: it
starts clear of the block, passes through it, and ends clear of it. Cut from the block everything
the bar passes through.
Every line of the inner side that runs along the bar's length is in contact all along it or not at
all; the one in the plane through the axis cuts the block's new wall, a cone. What is left of the
block is the part of it within 10 + z·tan 20° of the axis."""import math
fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBoxfromOCP.gp import gp, gp_Ax2, gp_Dir, gp_Pnt
from sweep import cut, flat_contacts_turned, ring_sector, turn, turned
BLOCK = (8, 12, -1, 1, 0, 60) # radii, heights and polar anglesLEAN = math.radians(20)
INNER = (10, 0, 0) # the middle of the bar's inner sideTHICK, HALF_WIDTH, HALF_LENGTH = 3, 2, 3# along u, y and the bar's lengthSTART, STOP = -140, 140# degrees about the z axisdefbuild():
u = (math.cos(LEAN), 0, -math.sin(LEAN)) # out from the inner side
along = (math.sin(LEAN), 0, math.cos(LEAN)) # the bar's length; u × ŷ
corner = [c - HALF_WIDTH * y - HALF_LENGTH * a for c, y, a inzip(INNER, (0, 1, 0), along)]
frame = gp_Ax2(gp_Pnt(*corner), gp_Dir(*along), gp_Dir(*u))
bar = BRepPrimAPI_MakeBox(frame, THICK, 2 * HALF_WIDTH, 2 * HALF_LENGTH).Shape()
bar = turn(bar, gp.OZ_s(), START)
# Each flat face meets the turn square-on along the plane through the axis and its normal:# for the inner and outer sides and the ends, all with normals in the plane y = 0, that plane# itself; the sides y = ±2 nowhere.
swept = turned(bar, gp.OZ_s(), STOP - START, flat_contacts_turned(bar, gp.OZ_s()))
returncut(ring_sector(*BLOCK), swept)
arris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
113 ms; CPU time 154 ms; peak memory 26.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 curved block, the sector of the ring about the z axis between radii 8 and 12, z from −1 to 1//! and polar angle from 0° to 60°, cut by a leaning bar turned past it: the box from its inner//! side, the plane through (10, 0, 0) square to u = (cos 20°, 0, −sin 20°), to 3 beyond it along//! u, within 2 of the plane y = 0 and within 3 along its length ℓ = (sin 20°, 0, cos 20°) of//! (10, 0, 0), turned rigidly about the z axis from −140° to +140°. Everything the bar passes//! through, cut.//!//! The bar is a box in the frame of u, y and ℓ; its sweep is kentron's sweep of a solid//! (`sweep::solid`, one turn), cut from the block.usecrate::bench::{d, p, v};
usecrate::shared::swept::ring_sector;
use kentron::math::{Axis, Frame};
use kentron::primitives::Cuboid;
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let block = ring_sector(m)?;
let (sin, cos) = 20f64.to_radians().sin_cos();
// x along u, y along y, z along u × y = ℓ; from the corner 3 back along ℓ and 2 along −y.let corner = p(10.0, 0.0, 0.0) - v(sin, 0.0, cos) * 3.0 - v(0.0, 2.0, 0.0);
let bar = Cuboid::new(3.0, 4.0, 6.0).with_frame(Frame::new(corner, d(sin, 0.0, cos), d(cos, 0.0, -sin))).build(m)?;
let turn = RigidMotion::Turn { axis: Axis::Z, from: (-140f64).to_radians(), to: 140f64.to_radians() };
let swept = sweep::solid(m, bar, &turn)?;
kentron::boolean::difference(m, block, swept)
}
vcad left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
41 ms; CPU time 41 ms; peak memory 46.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 ring sector, everything between 8 and 12 from the z axis with |z| ≤ 1 and polar angle from//! 0° to 60°, cut by a bar leaning out 20° in the plane y = 0, its inner side facing the z axis//! squarely, turned about the z axis from −140° to +140°. The bar is everything from the plane//! through (10, 0, 0) square to (cos 20°, 0, −sin 20°) to 3 beyond it along that direction,//! within 2 of the plane y = 0 and within 3 of the plane through (10, 0, 0) square to//! (sin 20°, 0, cos 20°).//!//! solidcraft-kernel has no sweep of a solid, so the turn is built by elementary geometry. The//! bar spans a few tens of degrees about the z axis, starts and ends clear of the block, and turns//! far enough that every circle about the z axis in the block that meets it is passed over where//! it crosses the block: what it takes from the block is its shadow, the circles it meets,//! revolved. At height z (|z| ≤ 1.2) the bar is a rectangle: its inner side's line at//! x = 10 + z tan 20°, |y| ≤ 2, its outer side's beyond x = 12.7, and its length's bounds farther//! out still. Its nearest point to the axis is on the inner side at y = 0, so the shadow there is//! everything from 10 + z tan 20° out past 12.5.usesuper::drum_swung_partway_into_ring_sector::{ring_sector, turned};
usecrate::solids::*;
pubfnbuild() -> R<Body> {
let t = 20f64.to_radians().tan();
// the shadow over |z| ≤ 1.2, past the block above and below and beyond its outer walllet shadow = polygon(&[(10.0 - 1.2 * t, -1.2), (12.5, -1.2), (12.5, 1.2), (10.0 + 1.2 * t, 1.2)]);
let swept = turned(&revolve_z(shadow, 280.0)?, -140.0)?;
cut(&ring_sector()?, &swept)
}
brepkit left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
popkern left no solid to show.
Time
3.7 ms; CPU time 3.4 ms; peak memory 11.4 MB
Notes
refused popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly
// A curved block cut by a bar's side facing the axis squarely.//// Refused: popkern has no sweep of a solid (its sweeps carry a profile along a path), and the// envelope this motion leaves is not one its extrudes, revolves and booleans make exactly: the// tool is not symmetric about the planes of its motion, or the motion is a screw or a curve.throw"popkern has no sweep of a solid, and this motion's envelope is not one its extrudes, revolves and booleans make exactly";
aetheris left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
16 ms; CPU time 15 ms; peak memory 17.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 ring sector 8 ≤ ρ ≤ 12, −1 ≤ z ≤ 1, 0° to 60° about the z axis, less everything a leaning//! bar passes through as it turns rigidly about the z axis from −140° to +140°: in the plane y = 0//! at the turn's start, its inner side the plane through (10, 0, 0) square to//! n = (cos 20°, 0, −sin 20°), the bar running 3 beyond it along n, 2 either side of y = 0, and 3//! either way along l = (sin 20°, 0, cos 20°).//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the bar as a convex polyhedron, its//! eight corners and six faces, turned about the z axis from −140° to +140°, asked for where it//! lies in the ring sector (`sweep_solid_clipped`), and cut from it.usecrate::solids::p;
usecrate::solids::swept::{box_tool, less_all, ring_sector, turn_about_z};
usecrate::Refusal;
use brep_kernel::{sweep_solid_clipped, BrepSolid, SweepClip};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let lean = 20f64.to_radians();
let (n, l) = (p(lean.cos(), 0.0, -lean.sin()), p(lean.sin(), 0.0, lean.cos()));
let corner = p(10.0, -2.0, 0.0).add(l.scale(-3.0));
let bar = box_tool(corner, n.scale(3.0), p(0.0, 4.0, 0.0), l.scale(6.0));
let sector = SweepClip {
axis_origin: p(0.0, 0.0, 0.0),
axis_direction: p(0.0, 0.0, 1.0),
reference: p(1.0, 0.0, 0.0),
radius: [8.0, 12.0],
axial: [-1.0, 1.0],
angle: Some([0.0, 60f64.to_radians()]),
};
let turn = turn_about_z((-140f64).to_radians(), 140f64.to_radians(), 0.0);
let block = ring_sector(8.0, 12.0, -1.0, 1.0, 0.0, 60f64.to_radians())?;
less_all(block, vec![sweep_solid_clipped(&bar, &turn, §or)?])
}
geop left no solid to show.
Time
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
Time
10 ms; CPU time 16 ms; peak memory 10.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.
//! A curved block (the ring sector between radii 8 and 12, heights ±1, polar angles 0° to 60°)//! cut by a bar leaning 20° out from upright in the plane y = 0 (its inner side the plane through//! (10, 0, 0) square to (cos 20°, 0, −sin 20°), 3 thick, within 2 of y = 0 and 3 either way//! along its length) turned about the z axis from −140° to +140°.//!//! The bar is a block turned 20° about the y axis and moved to (10, 0, 0); what it passes through//! (one turn) is cut from the block (cadrs's cylindrical box) by cadrs's cut by a swept solid (the//! exact sweep cut from it where it can be, else meshed).usecrate::bench::{block, moved, p3, turned, v3};
usecrate::shared::swept::{cut_swept, ring_sector, swing, z_axis};
usecrate::Refusal;
use cadrs_kernel::{Axis, BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let sector = ring_sector(k, (8.0, 12.0), (-1.0, 1.0), (0.0, 60.0))?;
// In its own frame: 3 thick along x (its inner side x = 0), 4 across along y, 6 long along z;// turned 20° about y, x goes to (cos 20°, 0, −sin 20°) and z to (sin 20°, 0, cos 20°).let local = block(k, p3(0.0, -2.0, -3.0), p3(3.0, 2.0, 3.0))?;
let leaning = turned(k, local, Axis::new(p3(0.0, 0.0, 0.0), v3(0.0, 1.0, 0.0)), 20.0)?;
let bar = moved(k, leaning, v3(10.0, 0.0, 0.0))?;
cut_swept(k, sector, bar, &swing(z_axis(), -140.0, 140.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
4.8 ms; CPU time 4.6 ms; peak memory 8.7 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † its sweep of a solid declines it
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 ring sector (radii 8 to 12, heights −1 to 1, angles 0° to 60°) less everything a leaning bar//! passes through as it turns about the z axis from −140° to 140°: the box whose inner side is the//! plane through (10, 0, 0) square to u = (cos 20°, 0, −sin 20°), 3 deep along u, within 2 of the//! plane y = 0 and within 3 of (10, 0, 0) along l = (sin 20°, 0, cos 20°).//!//! springrep's sweep of a solid declines this one (faces round an edge do not pair off). Within the//! block's reach (12 from the z axis) every circle about the z axis meets the bar in one arc across//! its middle plane y = 0, so there the sweep is the bar's section by that plane, a rectangle//! leaning 20°, turned through the 280° (`shared::swept`, a turn); the bar is clear of the block//! where it starts and stops.use springrep::boolean::difference;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{deg, polygon, sector_block, swing};
pubfnbuild() -> Result<Brep, String> {
let (s, c) = deg(20.0).sin_cos();
// corners in (x, z): (10, 0) ∓ 3l, then 3 along u from eachlet p0 = (10.0 - 3.0 * s, -3.0 * c);
let p1 = (10.0 + 3.0 * s, 3.0 * c);
let p2 = (p1.0 + 3.0 * c, p1.1 - 3.0 * s);
let p3 = (p0.0 + 3.0 * c, p0.1 - 3.0 * s);
let section = polygon(&[p0, p3, p2, p1], "bar");
let (from, to) = (deg(-140.0), deg(140.0));
let cut = swing(§ion, from, to - from, "cut")?;
difference(§or_block()?, &cut).map_err(e)
}
Time
246 ms; CPU time 508 ms; peak memory 44.1 MB
Notes
wrong volume 37.7450820968 against 37.7453541082 (its STEP's); area 84.8807820154 against 84.8810866052 (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
37.7450821
37.74535411
7.2e-06
area
84.88078202
84.88108661
3.6e-06
agrees with
no other kernel
mesh
1380 triangles, closed
centre of gravity
(7.48467, 4.32128, 0.0673196) its STEP's solid
inertia
about it, of unit density: Ixx 218.19; Iyy 92.509; Izz 285.853; Ixy 108.843; Iyz -1.15521; Izx -2.00088
// A curved block, the ring sector between radii 8 and 12 about the z axis, z within 1, polar angle// from 0 to 60 degrees: its section in the front plane (x, z) turned 60 degrees about the z axis.// The bar is drawn in a plane square to its length, through (10, 0, 0), its u = (cos 20, 0,// -sin 20) (x turned 20 degrees about y, the way its inner side faces) and v = y: its section the// rectangle from its inner side, the plane's v axis, 3 out along u and within 2 of the origin// along v; the bar is that section carried 3 either way along the plane's normal, leaning 20// degrees out from upright. It is turned rigidly about the z axis from -140 to +140 degrees, and// everything it passes through cut from the block.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (turns)
in std.front {
a := point
b := point hint((12, -1))
c := point hint((12, 1))
d := point hint((8, 1))
meridian := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((8, -1)) a
a distance(4) b
b distance(2) c
}
part := solid(std.solids.Revolution(meridian, about: std.z, to: 60deg))
across := axis hint(dir: (0.94, 0, -0.34))
across perpendicular std.y
std.x angle(20deg, about: std.y) across
along := axis hint(dir: (0, 1, 0))
along parallel(sense: same) std.y
holder := plane(u: across, v: along)
fix(origin == (10, 0, 0)) holder
in holder {
b0 := point
b1 := point hint((3, -2))
b2 := point hint((3, 2))
b3 := point hint((0, 2))
section := horizontal line(b0, b1) -> vertical line(b1, b2) ->
horizontal line(b2, b3) -> vertical line(b3, b0) -> close
fix((0, -2)) b0
b0 distance(3) b1
b1 distance(4) b2
}
bar := solid(std.solids.Prism(section, from: -3mm, to: 3mm))
swing := frame
swing turns(1) std.z
wall := solid({ p | some t in (-140deg, 140deg): p in bar at(under: swing) t })
wall cut part
anvilcad left no solid to show.
Time
1.3 ms; CPU time 1 ms; peak memory 3.4 MB
Notes
refused anvil-brep has no sweep of a solid, and what this motion sweeps is bounded by envelopes of the body's surfaces under it (a rim or a face leaning to the motion) that follow from no elementary construction, which it would have to compute itself
//! A curved block cut by a bar's side facing the axis squarely.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid, and what this motion sweeps is bounded by envelopes of the body's surfaces under it (a rim or a face leaning to the motion) that follow from no elementary construction, which it would have to compute itself".into())
}