A curved block whose floor is cut by the flat end of a leaning bar turned past it.
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 drawn in the plane through (10, 0, 0) spanned by u = (cos 20°, 0, −sin 20°) and v = (0, 1, 0): a point (a, b) of that plane is (10, 0, 0) + a u + b v. Its end is the rectangle 3 by 4 there turned 5° in that plane, {(a, b): 0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2}, whose side through (10, 0, 0) is the bar's inner side. The bar is that rectangle carried 3 along n = (sin 20°, 0, cos 20°), square to the plane: it leans 20° out from upright, its flat end facing down and toward the z axis.
It 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.
The end touches along the line where it meets the plane through the z axis and its normal, which the turn carries round into the cut's floor, a cone; the inner side touches along a line crossing its rulings; the rim between them carries the contact from the one to the other. The section is turned 5° so that no side faces the axis squarely.
expected
closed form
volume
53.56455345
no closed form: cad-kernel, OCCT and cadrs agree to 2e-12; the mean of their values
area
131.1212946
no closed form: cad-kernel, OCCT and cadrs give the same area to the twelve figures the board publishes
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
1.28 s; CPU time 3.84 s; peak memory 44.1 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.
Data
its STEP's
expected
rel. error
volume
53.56455345
53.56455345
1.4e-13
area
131.1212946
131.1212946
1.3e-12
agrees with
occt, kentron, next.BREP, cadrs
mesh
2658 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
//! A ring sector (radii 8 to 12 about z, z from −1 to 1, polar angle 0° to 60°) whose floor is cut//! by the flat end of a leaning bar turned about z, right-handed, from −140° to +140°. The end is//! the rectangle {0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2} at//! (10, 0, 0) + a u + b v, u = (cos 20°, 0, −sin 20°), v = (0, 1, 0); the bar is that rectangle//! carried 3 along n = (sin 20°, 0, cos 20°).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.];
/// Where the end's plane is drawn from: (a, b) = (0, 0).constORIGIN: V = [10., 0., 0.];
/// How far the bar leans out from upright, and how far its end is turned in its plane, in degrees.constLEAN: f64 = 20.;
constTURNED: f64 = 5.;
/// The end: 3 across from its inner side, 2 either side of its middle line; the bar 3 long.constWIDTH: f64 = 3.;
constHALF: f64 = 2.;
constLENGTH: 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 (u, v) = ([c, 0., -s], [0., 1., 0.]);
// a corner of the end by its own coordinates, p across it from its inner side and q along it,// turned 5° in (a, b)let (s5, c5) = TURNED.to_radians().sin_cos();
let corner = |p: f64, q: f64| {
let (a, b) = (p * c5 - q * s5, p * s5 + q * c5);
add(add(ORIGIN, scale(u, a)), scale(v, b))
};
// walked counter-clockwise in (a, b), so its normal is u × v = n, and swept 3 along itlet end = polygon(&[corner(0., -HALF), corner(WIDTH, -HALF), corner(WIDTH, HALF),
corner(0., HALF)]);
let bar = prism(&end, 0., LENGTH)?;
// 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 end's contact// line turned into a cone, the inner side's into a hyperboloid, every edge turned (a bar'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
1.41 s; CPU time 1.41 s; peak memory 376.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.
Data
its STEP's
expected
rel. error
volume
53.56455345
53.56455345
2.5e-11
area
131.1212946
131.1212946
6.8e-11
agrees with
cad-kernel, kentron, next.BREP, cadrs
mesh
4068 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
"""A floor cut by a leaning bar's flat end, turned. A curved block whose floor is cut by the flat
end of a leaning bar turned past it.
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 drawn in the plane through (10, 0, 0) spanned by u = (cos 20°, 0, −sin 20°) and v = (0,
1, 0): a point (a, b) of that plane is (10, 0, 0) + a u + b v. Its end is the rectangle 3 by 4
there turned 5° in that plane, {(a, b): 0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2},
whose side through (10, 0, 0) is the bar's inner side. The bar is that rectangle carried 3 along n
= (sin 20°, 0, cos 20°), square to the plane: it leans 20° out from upright, its flat end facing
down and toward the z axis.
It 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.
The end touches along the line where it meets the plane through the z axis and its normal, which
the turn carries round into the cut's floor, a cone; the inner side touches along a line crossing
its rulings; the rim between them carries the contact from the one to the other. The section is
turned 5° so that no side faces the axis squarely."""import math
fromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeFace, BRepBuilderAPI_MakePolygonfromOCP.BRepPrimAPIimportBRepPrimAPI_MakePrismfromOCP.gp import gp, gp_Pnt, gp_Vec
from sweep import cut, flat_contacts_turned, ring_sector, turn, turned
BLOCK = (8, 12, -1, 1, 0, 60) # radii, heights and polar anglesORIGIN = (10, 0, 0)
LEAN = math.radians(20)
TWIST = math.radians(5) # the end's rectangle, turned in its planeLENGTH, HALF_WIDTH = 3, 2# of the rectangle, along a and across itDEPTH = 3# the bar's end carried along nSTART, STOP = -140, 140# degrees about the z axisdefbuild():
u = (math.cos(LEAN), 0, -math.sin(LEAN))
v = (0, 1, 0)
n = (math.sin(LEAN), 0, math.cos(LEAN))
c, s = math.cos(TWIST), math.sin(TWIST)
# the rectangle's corners, (a, b) = p(cos 5°, sin 5°) + q(−sin 5°, cos 5°) for p from 0 to 3# and q from −2 to 2, placed at (10, 0, 0) + a u + b v
corners = []
for p, q in ((0, -HALF_WIDTH), (LENGTH, -HALF_WIDTH), (LENGTH, HALF_WIDTH), (0, HALF_WIDTH)):
a, b = p * c - q * s, p * s + q * c
corners.append(gp_Pnt(*(o + a * x + b * y for o, x, y inzip(ORIGIN, u, v))))
end = BRepBuilderAPI_MakeFace(BRepBuilderAPI_MakePolygon(*corners, True).Wire()).Face()
bar = turn(BRepPrimAPI_MakePrism(end, gp_Vec(*(DEPTH * x for x in n))).Shape(), gp.OZ_s(),
START)
# Each flat face meets the turn square-on along the plane through the axis and its normal,# which cuts it along its contact where it reaches it.
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
325 ms; CPU time 486 ms; peak memory 28.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.
Data
its STEP's
expected
rel. error
volume
53.56455345
53.56455345
3.0e-12
area
131.1212946
131.1212946
8.8e-12
agrees with
cad-kernel, occt, next.BREP, cadrs
mesh
3470 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
//! 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°, its floor cut by the flat end of a leaning bar turned past it://! in the plane through (10, 0, 0) spanned by u = (cos 20°, 0, −sin 20°) and v = (0, 1, 0), the//! 3 × 4 rectangle 0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2 of points (a, b), carried 3//! along n = (sin 20°, 0, cos 20°), 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 the rectangle's sides and n; its sweep is kentron's sweep of a//! solid (`sweep::solid`, one turn), cut from the block.usecrate::bench::{d, v};
usecrate::shared::swept::ring_sector;
use kentron::math::{Axis, Frame, Point, Vector};
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 (s20, c20) = 20f64.to_radians().sin_cos();
let (s5, c5) = 5f64.to_radians().sin_cos();
let (u, w, n) = (v(c20, 0.0, -s20), v(0.0, 1.0, 0.0), v(s20, 0.0, c20));
// The rectangle's sides' directions, 5° round from u and v (n × e1 = e2); its corner where// a cos 5° + b sin 5° is 0 and b cos 5° − a sin 5° is −2.let (e1, e2) = (u * c5 + w * s5, w * c5 - u * s5);
let corner = Point::new(10.0, 0.0, 0.0) - e2 * 2.0;
let unit = |a: Vector| d(a.x, a.y, a.z);
let bar = Cuboid::new(3.0, 4.0, 3.0).with_frame(Frame::new(corner, unit(n), unit(e1))).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
978 ms; CPU time 977 ms; peak memory 50.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.
Data
its STEP's
expected
rel. error
volume
53.56455289
53.56455345
1.0e-08
area
131.1212897
131.1212946
3.7e-08
agrees with
no other kernel
mesh
4820 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
//! 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 leaning bar turned about the z axis from −140° to +140°. The bar's end is//! the rectangle {0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2} in the plane of the//! points (10, 0, 0) + a u + b v, u = (cos 20°, 0, −sin 20°), v = (0, 1, 0); the bar is that//! rectangle carried 3 along n = (sin 20°, 0, cos 20°).//!//! solidcore-ops has no sweep of a solid, so the turn is built by elementary geometry, from the//! kernel's revolves of flat faces about the z axis ([`leading_faces_turned`]). The bar starts//! clear of the block, so what it takes from it is what its leading faces sweep.usecrate::bench::{cut_all, polygon, rotated};
usecrate::Refusal;
use solidcore_ops::sweep::revolve;
use solidcore_ops::Body;
typeP = [f64; 3];
fnsub(a: P, b: P) -> P {
[a[0] - b[0], a[1] - b[1], a[2] - b[2]]
}
fndot(a: P, b: P) -> f64 {
a[0] * b[0] + a[1] * b[1] + a[2] * b[2]
}
fncross(a: P, b: P) -> P {
[a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0]]
}
/// The solids the faces of a convex polyhedron sweep where they lead, as it turns `degrees`/// about the z axis, right-handed, from where it is drawn: its `corners`, and its `faces` as/// lists of corners in order round each.////// A point the polyhedron passes over that is outside it where it starts is entered across its/// boundary where the boundary moves towards it: where a face's outward normal n leads the/// velocity ẑ × p. That is where m · p > 0, m = n × ẑ: the half of the face's plane on one side of/// the plane through the z axis square to m, whose line across the face is its contact. So the/// polyhedron's sweep is where it starts and what the leading part of each face sweeps (a face/// square to the axis turns in its own plane, and leads nowhere). A leading part meets each/// circle about the axis at most once, so it turns without folding over itself: the kernel's/// revolve of that flat region.pubfnleading_faces_turned(corners: &[P], faces: &[Vec<usize>], degrees: f64) -> Result<Vec<Body>, Refusal> {
let n = corners.len() as f64;
let centre = corners.iter().fold([0.0; 3], |c, p| [c[0] + p[0] / n, c[1] + p[1] / n, c[2] + p[2] / n]);
letmut swept = Vec::new();
for face in faces {
let ring: Vec<P> = face.iter().map(|&i| corners[i]).collect();
letmut normal = cross(sub(ring[1], ring[0]), sub(ring[2], ring[0]));
ifdot(normal, sub(ring[0], centre)) < 0.0 {
normal = [-normal[0], -normal[1], -normal[2]];
}
let m = cross(normal, [0.0, 0.0, 1.0]);
ifdot(m, m).sqrt() < 1e-9 * dot(normal, normal).sqrt() {
continue;
}
// the face clipped to m · p ≥ 0, where the contact line crosses its sidesletmut lead = Vec::new();
for (k, &p) in ring.iter().enumerate() {
let q = ring[(k + 1) % ring.len()];
let (sp, sq) = (dot(m, p), dot(m, q));
if sp >= 0.0 {
lead.push(p);
}
if (sp > 0.0 && sq < 0.0) || (sp < 0.0 && sq > 0.0) {
let t = sp / (sp - sq);
lead.push([p[0] + t * (q[0] - p[0]), p[1] + t * (q[1] - p[1]), p[2] + t * (q[2] - p[2])]);
}
}
lead.dedup_by(|a, b| dot(sub(*a, *b), sub(*a, *b)) < 1e-24);
if lead.len() < 3 {
continue;
}
let area = (1..lead.len() - 1)
.map(|k| dot(cross(sub(lead[k], lead[0]), sub(lead[k + 1], lead[0])), normal))
.sum::<f64>();
if area.abs() < 1e-9 * dot(normal, normal).sqrt() {
continue;
}
swept.push(revolve(&polygon(&lead), [0.0; 3], [0.0, 0.0, 1.0], degrees.to_radians(), true)?);
}
Ok(swept)
}
/// The block the turned tools cut: the rectangle 8 ≤ x ≤ 12, |z| ≤ 1 at y = 0 revolved from 0°/// to 60°.pubfnring_sector() -> Result<Body, Refusal> {
let section = polygon(&[[8.0, 0.0, -1.0], [12.0, 0.0, -1.0], [12.0, 0.0, 1.0], [8.0, 0.0, 1.0]]);
Ok(revolve(§ion, [0.0; 3], [0.0, 0.0, 1.0], 60f64.to_radians(), true)?)
}
pubfnbuild() -> Result<Body, Refusal> {
let (s20, c20) = 20f64.to_radians().sin_cos();
let (s5, c5) = 5f64.to_radians().sin_cos();
let (u, v, n) = ([c20, 0.0, -s20], [0.0, 1.0, 0.0], [s20, 0.0, c20]);
let point = |a: f64, b: f64, s: f64| -> P {
letmut p = [10.0, 0.0, 0.0];
for i in0..3 {
p[i] += a * u[i] + b * v[i] + s * n[i];
}
p
};
// the end's corners, (a, b) = p (cos 5°, sin 5°) + q (−sin 5°, cos 5°), at s = 0 and 3letmut corners = Vec::new();
for s in [0.0, 3.0] {
for (p, q) in [(0.0, -2.0), (3.0, -2.0), (3.0, 2.0), (0.0, 2.0)] {
corners.push(point(p * c5 - q * s5, p * s5 + q * c5, s));
}
}
letmut faces = vec![vec![0, 1, 2, 3], vec![4, 5, 6, 7]];
for i in0..4 {
let j = (i + 1) % 4;
faces.push(vec![i, j, j + 4, i + 4]);
}
let start = -140.0;
let swept = leading_faces_turned(&corners, &faces, 280.0)?
.into_iter()
.map(|b| rotated(b, [0.0; 3], [0.0, 0.0, 1.0], start))
.collect::<Result<Vec<_>, _>>()?;
cut_all(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.9 ms; CPU time 3.7 ms; peak memory 11.7 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 floor cut by a leaning bar's flat end, turned.//// 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
53 ms; CPU time 52 ms; peak memory 20.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.
Data
its STEP's
expected
rel. error
volume
53.56455345
53.56455345
1.2e-11
area
131.1212946
131.1212946
2.6e-11
agrees with
cad-kernel, occt, kentron, cadrs
mesh
4824 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
//! A ring sector whose floor is cut by the flat end of a leaning bar turned past it.//!//! Through the kernel's sweep of a solid within a region (`sweep_solid_clipped`, asked for 7.5 to//! 12.5 from the z axis, z from −1.5 to 1.5, angles −10° to 70°, which holds the block), the bar as a convex polyhedron: its//! end, the rectangle {0 ≤ a cos 5° + b sin 5° ≤ 3, |b cos 5° − a sin 5°| ≤ 2} of the plane through//! (10, 0, 0) along u = (cos 20°, 0, −sin 20°) and v = (0, 1, 0), carried 3 along n = (sin 20°, 0,//! cos 20°); turned about the z axis from −140° to +140°; cut from the block (the rectangle 8 ≤ x ≤ 12,//! |z| ≤ 1 revolved from 0° to 60°).usecrate::solids::p;
usecrate::Refusal;
use brep_kernel::{
boolean_operation_nary, revolve_profile_brep, sweep_solid_clipped, BooleanOperation, BrepSolid, ScrewStep,
SolidMotion, SolidTool, SweepClip,
};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let section = [p(8.0, 0.0, -1.0), p(12.0, 0.0, -1.0), p(12.0, 0.0, 1.0), p(8.0, 0.0, 1.0)];
let block = revolve_profile_brep(&crate::solids::polygon(§ion)?, p(0.0, 0.0, 0.0), p(0.0, 0.0, 1.0), 60f64.to_radians())?;
let (c, s) = (5f64.to_radians().cos(), 5f64.to_radians().sin());
let lean = 20f64.to_radians();
let u = p(lean.cos(), 0.0, -lean.sin());
let v = p(0.0, 1.0, 0.0);
let n = p(lean.sin(), 0.0, lean.cos());
// a corner (a', b') of the turned rectangle, at height h along nlet corner = |a: f64, b: f64, h: f64| {
let (x, y) = (a * c - b * s, a * s + b * c);
p(10.0, 0.0, 0.0).add(u.scale(x)).add(v.scale(y)).add(n.scale(h))
};
letmut vertices = Vec::new();
for h in [0.0, 3.0] {
for (a, b) in [(0.0, -2.0), (3.0, -2.0), (3.0, 2.0), (0.0, 2.0)] {
vertices.push(corner(a, b, h));
}
}
let faces = vec![vec![0, 1, 2, 3], vec![4, 5, 6, 7], vec![0, 1, 5, 4], vec![1, 2, 6, 5], vec![2, 3, 7, 6], vec![3, 0, 4, 7]];
let motion = SolidMotion {
steps: vec![ScrewStep { axis_origin: p(0.0, 0.0, 0.0), axis_direction: p(0.0, 0.0, 1.0), turn: 1.0, advance: 0.0 }],
from: (-140f64).to_radians(),
to: 140f64.to_radians(),
};
let around_block = 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: [7.5, 12.5],
axial: [-1.5, 1.5],
angle: Some([(-10f64).to_radians(), 70f64.to_radians()]),
};
let swept = sweep_solid_clipped(&SolidTool::Polyhedron { vertices, faces }, &motion, &around_block)?;
Ok(boolean_operation_nary(&[block, swept], BooleanOperation::Subtract)?)
}
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
11 ms; CPU time 22 ms; peak memory 11 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.
Data
its STEP's
expected
rel. error
volume
53.56455345
53.56455345
2.0e-13
area
131.1212946
131.1212946
7.9e-13
agrees with
cad-kernel, occt, kentron, next.BREP
mesh
3358 triangles, closed
centre of gravity
(7.89792, 4.55987, -0.155704) its STEP's solid
inertia
about it, of unit density: Ixx 352.87; Iyy 166.616; Izz 481.537; Ixy 161.3; Iyz 5.86191; Izx 10.1531
//! A curved block (the ring sector between radii 8 and 12, heights ±1, polar angles 0° to 60°)//! whose floor is cut by the flat end of a leaning bar turned past it about the z axis from −140°//! to +140°.//!//! The bar is its end (the rectangle 3 by 4 turned 5°, in the plane through (10, 0, 0) spanned by//! u = (cos 20°, 0, −sin 20°) and v = (0, 1, 0)) extruded 3 along that plane's normal; what it//! passes through (one turn) is cut from the block by cadrs's cut by a swept solid (the exact//! sweep cut from it where it can be, else meshed).usecrate::bench::{extrude, p3, v3};
usecrate::shared::swept::{cut_swept, ring_sector, swing, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel, Loop, Plane, Profile};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let block = ring_sector(k, (8.0, 12.0), (-1.0, 1.0), (0.0, 60.0))?;
let t = 20f64.to_radians();
let (u, n) = (v3(t.cos(), 0.0, -t.sin()), v3(t.sin(), 0.0, t.cos()));
// (The sketch's y axis, n × u, is v.)let on = Plane::new(p3(10.0, 0.0, 0.0), u, n);
let f = 5f64.to_radians();
let corner = |p: f64, q: f64| [p * f.cos() - q * f.sin(), p * f.sin() + q * f.cos()];
let end = Loop::polygon(&[corner(0.0, -2.0), corner(3.0, -2.0), corner(3.0, 2.0), corner(0.0, 2.0)]);
let bar = extrude(k, &Profile::of(on, vec![end]), 3.0)?;
cut_swept(k, block, 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.
springrep left no solid to show.
Time
598 ms; CPU time 597 ms; peak memory 11.5 MB
Notes
refused invalid result: the edge through (-10.215341, 7.720184, -0.978523) would be used by 1 faces; the edge through (-10.561934, 7.308221, -0.962538) would be used by 1 faces; the edge through (-10.825297, 6.838668, -0.978523) would be used by 1 faces
//! The ring sector (radii 8 to 12, heights −1 to 1, angles 0° to 60°) less everything a leaning//! bar, its end a 3 × 4 rectangle turned 5° in its plane, passes through as it turns about the z//! axis from −140° to 140°.use springrep::boolean::difference;
use springrep::math::{Frame, Vec3};
use springrep::primitive::block;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{deg, sector_block, turning, v3};
pubfnbuild() -> Result<Brep, String> {
let (lean, twist) = (deg(20.0), deg(5.0));
let (u, v) = (v3(lean.cos(), 0.0, -lean.sin()), Vec3::Y);
let n = v3(lean.sin(), 0.0, lean.cos());
// the end's sides turned 5° in its plane: a′ = a cos 5° + b sin 5° from 0 to 3, and// b′ = b cos 5° − a sin 5° from −2 to 2let along = u * twist.cos() + v * twist.sin();
let across = v * twist.cos() - u * twist.sin();
let corner = v3(10.0, 0.0, 0.0) - across * 2.0;
let end = Frame::new(corner, n, along).map_err(e)?;
let bar = block(&end, v3(3.0, 4.0, 3.0), "bar").map_err(e)?;
let swept = solid(&bar, &turning(deg(-140.0), deg(140.0)), "turn").map_err(e)?;
difference(§or_block()?, &swept).map_err(e)
}
Time
421 ms; CPU time 689 ms; peak memory 43.8 MB
Notes
wrong volume 53.569537376 against 53.5645534465 (its STEP's); area 131.123116863 against 131.121294585 (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
53.56953738
53.56455345
9.3e-05
area
131.1231169
131.1212946
1.4e-05
agrees with
no other kernel
mesh
54198 triangles, closed
centre of gravity
(7.89796, 4.55989, -0.155683) its STEP's solid
inertia
about it, of unit density: Ixx 352.903; Iyy 166.629; Izz 481.581; Ixy 161.318; Iyz 5.86166; Izx 10.1527
// 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 the plane of its flat end, through (10, 0, 0), its u = (cos 20, 0, -sin 20)// (x turned 20 degrees about y) and v = y: its end the rectangle 3 deep and 4 wide whose inner side// is bisected by the plane's origin, its sides turned 5 degrees from the plane's axes; the bar is// that rectangle carried 3 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 {
o := point
fix((0, 0)) o
b0 := point hint((0.17, -2))
b1 := point hint((3.16, -1.73))
b2 := point hint((2.81, 2.25))
b3 := point hint((-0.17, 2))
end := (lower := line(b0, b1)) -> perpendicular (outer_side := line(b1, b2)) -> perpendicular
(upper := line(b2, b3)) -> perpendicular (inner_side := line(b3, b0)) -> close
o midpoint inner_side
length(4) inner_side
length(3) lower
holder.u angle(5deg) lower
}
bar := solid(std.solids.Prism(end, from: 0mm, to: 3mm))
swing := frame
swing turns(1) std.z
floor := solid({ p | some t in (-140deg, 140deg): p in bar at(under: swing) t })
floor cut part
anvilcad left no solid to show.
Time
1.1 ms; CPU time 950 µs; peak memory 3.5 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 floor cut by a leaning bar's flat end, turned.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())
}