A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut along it by a short bar carried along a screw, so that the bar's corners, and not only its edges, carry the groove's walls.
The bar, as placed, is the box 4 ≤ x ≤ 12, −1.5 ≤ y ≤ 1.5, −1 ≤ z ≤ 1: it points at the rod's axis, its flat tip (the face x = 4) 1 inside the rod, 2 wide along the axis and 3 across.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 6 for every whole turn, rigidly. It runs from a turn of −90° (the bar lowered 1.5, wholly below the rod) to a turn of 1350° (raised 22.5, wholly above it). Cut from the rod everything the bar passes through.
The bar's four corners (4, ±1.5, ±1) lie inside the rod. Out to distance √(4² + 1.5²) ≈ 4.272 from the axis the groove's walls are carried by the tip's long edges, as a long bar's are; beyond it, by the edges where the bar's sides y = ±1.5 meet its faces z = ±1. The two meet at the corners' paths.
† 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
6.02 s; CPU time 20.6 s; peak memory 126.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
1326.863558
1326.86356
1.8e-09
area
882.2909696
882.2909725
3.3e-09
agrees with
occt, kentron, next.BREP, cadrs, springrep
mesh
43100 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, threaded by a short bar, the box//! 4 ≤ x ≤ 12, −1.5 ≤ y ≤ 1.5, −1 ≤ z ≤ 1, screwed about z — right-handed, rising 6 a turn — from//! a turn of −90° to 1350°: its corners inside the rod carry the groove's walls too.usecrate::sketch::block;
use cad_kernel::build::{disc, prism};
use cad_kernel::geom::tolerance;
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
constLEAD: f64 = 6.;
constROLL: [f64; 2] = [-90f64.to_radians(), 1350f64.to_radians()];
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0., 0., 0.], up, ROD_RADIUS), 0., ROD_LENGTH)?;
let bar = block([4., -1.5, -1.], [12., 1.5, 1.])?;
// the screw about z: a radian a radian of the roll, rising the lead a turnlet path = Trajectory::Twist(Screw {
origin: [0., 0., 0.], axis: up, ratio: 1., advance: LEAD,
});
// the kernel's swept solid cut from the rod on one arrangement: the bar's edges along the axis// and square to it, screwed into cylinders and helicoidal sheets (a box's flat faces mesh// exactly, at any bar)let size = rod.size().max(bar.size());
cut_from(&rod, &bar, &path, ROLL, bar.size(), tolerance(size))
.map_err(|why| format!("the bar's sweep not built: {why:?}"))
}
Time
2.78 s; CPU time 2.78 s; peak memory 391 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
1326.86356
1326.86356
3.7e-10
area
882.2909718
882.2909725
7.7e-10
agrees with
cad-kernel, kentron, next.BREP, cadrs, springrep
mesh
43124 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
"""A rod threaded by a short bar whose corners cut. A rod, the cylinder of radius 5 about the z
axis from z = 0 to z = 20, with a thread cut along it by a short bar carried along a screw, so that
the bar's corners, and not only its edges, carry the groove's walls.
The bar, as placed, is the box 4 ≤ x ≤ 12, −1.5 ≤ y ≤ 1.5, −1 ≤ z ≤ 1: it points at the rod's axis,
its flat tip (the face x = 4) 1 inside the rod, 2 wide along the axis and 3 across.
The screw is about the z axis: the bar turns right-handed about it (from +x toward +y) and rises 6
for every whole turn, rigidly. It runs from a turn of −90° (the bar lowered 1.5, wholly below the
rod) to a turn of 1350° (raised 22.5, wholly above it). Cut from the rod everything the bar passes
through.
The bar's four corners (4, ±1.5, ±1) lie inside the rod. Out to distance √(4² + 1.5²) ≈ 4.272 from
the axis the groove's walls are carried by the tip's long edges, as a long bar's are; beyond it, by
the edges where the bar's sides y = ±1.5 meet its faces z = ±1. The two meet at the corners'
paths."""fromOCP.BRepAlgoAPIimportBRepAlgoAPI_CommonfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeBox, BRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Ax2, gp_Pnt
from bench importRefusedfrom sweep import cut, flat_contacts_screwed, screw, screwed
ROD_RADIUS, ROD_LENGTH = 5, 20BAR = ((4, -1.5, -1), (12, 1.5, 1))
LEAD = 6# rise per whole turnSTART, STOP = -90, 1350# degrees# A screw about the rod's axis keeps every point's distance from it, so only the part of the bar# within the rod's radius ever enters the rod; the bar is cut down to the part within this.REACH = 6defbuild():
bar = BRepPrimAPI_MakeBox(gp_Pnt(*BAR[0]), gp_Pnt(*BAR[1])).Shape()
within = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(0, 0, -10), gp.DZ_s()), REACH, 20).Shape()
near = BRepAlgoAPI_Common(bar, within)
ifnot near.IsDone():
raiseRefused("BRepAlgoAPI_Common declined the bar's part near the rod")
tool = screw(near.Shape(), LEAD, START)
# Of the faces left, the cylinder of radius 6 is carried along itself; the flat ones are# cut along their contact: the tip along its middle, through the axis, the sides square to# it nowhere; the level faces rise or sink all over.# Every circle about the axis meets the bar, cut down to within REACH of it, in one arc, so# no point is entered twice in a pass, and the leading faces of each span are swept whole.
pieces = screwed(tool, LEAD, START, STOP, flat_contacts_screwed(tool, LEAD), whole=True)
rod = BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape()
returncut(rod, pieces)
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
987 ms; CPU time 1.67 s; peak memory 54.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
1326.86356
1326.86356
1.8e-10
area
882.2909716
882.2909725
1.1e-09
agrees with
cad-kernel, occt, next.BREP, cadrs, springrep
mesh
73210 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut by a//! short bar, the box 4 ≤ x ≤ 12, −1.5 ≤ y ≤ 1.5, −1 ≤ z ≤ 1, carried along a screw about the z//! axis rising 6 a turn, from a turn of −90° (wholly below the rod) to 1350° (wholly above it).//! Everything the bar passes through, cut; its corners, inside the rod, carry the groove's walls//! with its edges, which the outline's turn sweeps alike.//!//! The bar's sweep is kentron's sweep of a solid (`sweep::solid`, one screw), cut from the rod.usecrate::bench::p;
use kentron::math::Axis;
use kentron::primitives::{Cuboid, Cylinder};
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 bar = Cuboid::from_corners(p(4.0, -1.5, -1.0), p(12.0, 1.5, 1.0)).build(m)?;
let screw = RigidMotion::Screw { axis: Axis::Z, lead: 6.0, from: (-90f64).to_radians(), to: 1350f64.to_radians() };
let swept = sweep::solid(m, bar, &screw)?;
kentron::boolean::difference(m, rod, 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.
solidcraft left no solid to show.
Time
10.8 s; CPU time 10.8 s; peak memory 70.1 MB
Notes
refused the operation failed: SMLib boolean: operation: solidcore: SmApiBoolean: boolean::merge::p2::make_faceuse: the radial sector search at a common edge found no face use of the other operand; caused by topology::edge: no radial edge use is left after culling
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, threaded by the short//! bar 4 ≤ x ≤ 12, −1.5 ≤ y ≤ 1.5, −1 ≤ z ≤ 1 carried along the screw about the z axis that rises//! 6 a turn, from a turn of −90° to one of 1350°.//!//! solidcraft-kernel has no sweep of a solid, so the bar's sweep is built as//! `square-bar-screwed-through-rod`'s is: split by the plane y = 0, the half on y ≥ 0 leaves a//! point only through its face z = −1, its back or the cut, and the half on y ≤ 0 first reaches//! one only through its face z = 1, its back or the cut (its sides y = ±1.5 lead and trail as the//! long bar's do). So the sweep is the bar at its ends, below and above the rod, with the screw//! sweeps of its section by y = 0, its faces z = ±1 and its back, 12 from the axis.usesuper::square_bar_screwed_through_rod::bar_cut;
usecrate::solids::*;
pubfnbuild() -> R<Body> {
let rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
bar_cut(rod, (4.0, -1.5, -1.0), (12.0, 1.5, 1.0), 6.0, -90.0, 1350.0)
}
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.5 ms; peak memory 11.6 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 rod threaded by a short bar whose corners cut.//// 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
567 ms; CPU time 567 ms; peak memory 148.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.
Data
its STEP's
expected
rel. error
volume
1326.86356
1326.86356
3.9e-11
area
882.2909725
882.2909725
1.8e-11
agrees with
cad-kernel, occt, kentron, cadrs, springrep
mesh
54206 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
//! A rod threaded by a short bar carried along a screw about its axis.//!//! Through the kernel's sweep of a solid within a region (`sweep_solid_clipped`, the bar as a convex//! polyhedron; else `sweep_solid_within`, the bar as a prism); the bar, its//! rectangle 4 ≤ x ≤ 12, |y| ≤ 1.5 from z = −1 to 1, along the screw about the z axis that rises 6//! a turn, from −90° to +1350°, within 5.2 of the z axis from z = −0.4 to 20.4 (which holds the rod//! and which neither end position reaches); cut from the rod. The kernel's sweep carries a solid of//! revolution along a screw and a prism only along a planar motion, so it may refuse.usecrate::solids::p;
usecrate::Refusal;
#[allow(unused_imports)]use brep_kernel::{
boolean_operation_nary, make_box_brep, make_cylinder_brep, revolve_profile_brep,
sweep_solid_clipped, sweep_solid_within, SolidTool, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SweepClip, SweptTool, Vec3,
};
#[allow(unused_imports)]use std::f64::consts::{FRAC_PI_2, PI, TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), p(0.0, 0.0, 1.0), 5.0, 20.0)?;
letmut operands = vec![rod];
let tool0 = SweptTool::Prism {
origin: p(0.0, 0.0, 0.0),
normal: p(0.0, 0.0, 1.0),
x_axis: p(1.0, 0.0, 0.0),
outline: vec![
OutlinePiece::Line { from: [4.0, -1.5], to: [12.0, -1.5] },
OutlinePiece::Line { from: [12.0, -1.5], to: [12.0, 1.5] },
OutlinePiece::Line { from: [12.0, 1.5], to: [4.0, 1.5] },
OutlinePiece::Line { from: [4.0, 1.5], to: [4.0, -1.5] },
],
from: -1.0,
to: 1.0,
};
let motion0 = 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: 6.0 / TAU },
],
from: (-90.0f64).to_radians(),
to: 1350.0f64.to_radians(),
};
let clip0 = 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: [0.0, 5.2],
axial: [-0.4, 20.4],
angle: None,
};
// The bar as the convex polyhedron it is: the kernel sweeps it along the screw and cuts it from// the rod faster than its level engine builds the rod less the sweep (host: square bar 1.06 s// against 1.53 s, the same volume to 5e-8).let bar = SolidTool::Polyhedron {
vertices: (0..8)
.map(|i| p(if i & 1 != 0 { 12.0 } else { 4.0 }, if i & 2 != 0 { 1.5 } else { -1.5 }, if i & 4 != 0 { 1.0 } else { -1.0 }))
.collect(),
faces: vec![vec![0, 2, 3, 1], vec![4, 5, 7, 6], vec![0, 1, 5, 4], vec![2, 6, 7, 3], vec![0, 4, 6, 2], vec![1, 3, 7, 5]],
};
ifletOk(swept) = sweep_solid_clipped(&bar, &motion0, &clip0) {
operands.push(swept);
returnOk(boolean_operation_nary(&operands, BooleanOperation::Subtract)?);
}
operands.extend(sweep_solid_within(&tool0, &motion0, &clip0)?);
Ok(boolean_operation_nary(&operands, 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
244 ms; CPU time 542 ms; peak memory 19.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.
Data
its STEP's
expected
rel. error
volume
1326.86356
1326.86356
2.1e-10
area
882.2909736
882.2909725
1.2e-09
agrees with
cad-kernel, occt, kentron, next.BREP, springrep
mesh
44206 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) threaded by a short bar//! (the box 4 ≤ x ≤ 12, |y| ≤ 1.5, |z| ≤ 1) screwed about the z axis, rising 6 a turn, from a turn//! of −90° to 1350°.//!//! What the bar passes through is cadrs's sweep of a solid (a turn and a slide along its axis at//! once: a screw), cut from the rod; of the bar, its part within 5.5 of the axis (the screw maps//! the cylinder about its axis onto itself, so only that part reaches the rod).usecrate::bench::{block, cut, p3};
usecrate::shared::swept::{near_axis, rod, screwed, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let bar = block(k, p3(4.0, -1.5, -1.0), p3(12.0, 1.5, 1.0))?;
let bar = near_axis(k, bar, 5.5)?;
let swept = screwed(k, bar, z_axis(), 6.0, -90.0, 1350.0)?;
let r = rod(k)?;
cut(k, r, swept)
}
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
3.75 s; CPU time 3.75 s; peak memory 20.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.
Data
its STEP's
expected
rel. error
volume
1326.86356
1326.86356
1.0e-13
area
882.2909725
882.2909725
9.6e-13
agrees with
cad-kernel, occt, kentron, next.BREP, cadrs
mesh
39792 triangles, closed
centre of gravity
(-0.0247313, -0.0428358, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51530; Iyy 51547.3; Izz 14619.7; Ixy 14.9384; Iyz -158.122; Izx 273.875
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything the bar//! 4 ≤ x ≤ 12, |y| ≤ 1.5, |z| ≤ 1 passes through as it is screwed about the z axis, rising 6 a//! turn, from a turn of −90° to one of 1350°.use springrep::boolean::difference;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, rod, screwing};
pubfnbuild() -> Result<Brep, String> {
let bar = boxed([4.0, -1.5, -1.0], [12.0, 1.5, 1.0], "bar")?;
let swept = solid(&bar, &screwing(6.0, deg(-90.0), deg(1350.0)), "screw").map_err(e)?;
difference(&rod()?, &swept).map_err(e)
}
Time
936 ms; CPU time 1.63 s; peak memory 75.4 MB
Notes
wrong volume 1326.62115542 against 1326.86356036 (its STEP's); area 882.799824241 against 882.290972524 (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
1326.621155
1326.86356
1.8e-04
area
882.7998242
882.2909725
5.8e-04
agrees with
no other kernel
mesh
134344 triangles, closed
centre of gravity
(-0.0247935, -0.0428503, 10) its STEP's solid
inertia
about it, of unit density: Ixx 51520.1; Iyy 51537.2; Izz 14615.8; Ixy 14.9543; Iyz -158.49; Izx 273.917
// A rod threaded by a short bar carried along a screw. The rod is the cylinder of radius 5 about// the z axis from z = 0 to 20. The bar is the box 4 <= x <= 12, -1.5 <= y <= 1.5, -1 <= z <= 1: its// section drawn in the front plane (x, z), dimensioned from the rod's axis, and the prism over it// 1.5 either side. The screw is about z, right-handed, rising 6 a turn; the kernel's sweep of the// bar from a turn of -90 to 1350 degrees is cut from the rod.unit mm
use std
use std.solids (cut)
use std.place (coords, above)
use std.motion (screws)
in std.top {
private o := point
fix((0, 0)) o
private rim := circle(center: o) hint(r: 5)
radius(5mm) rim
}
part := solid(std.solids.Prism(face(rim), from: 0mm, to: 20mm))
in std.front {
// the rod's axis, up from its foot at the originconstruction centerline ax := line(std.origin)
ax.p2 above(d: 20mm) std.origin
// the bar's section, from the axis: 4 to 12 out along x, 1 either side of z = 0private b0 := point
private b1 := point
private b2 := point
private b3 := point
b0 coords(du: 4mm, dv: -1mm) std.front
b1 coords(du: 12mm, dv: -1mm) std.front
b2 coords(du: 12mm, dv: 1mm) std.front
b3 coords(du: 4mm, dv: 1mm) std.front
private lower := line(b0, b1)
private end := line(b1, b2)
private upper := line(b2, b3)
private nose := line(b3, b0)
}
construction bar := solid(std.solids.Prism(face(lower, end, upper, nose), from: -1.5mm, to: 1.5mm))
// the screw about the rod's axis, carrying the bar from below the rod to above it
feed := frame
feed screws(6mm) ax
construction thread := solid({ p | some t in (-90deg, 1350deg): p in bar at(under: feed) t })
thread cut part
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1.1 ms; peak memory 3.3 MB
Notes
refused anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps
//! A rod threaded by a short bar whose corners cut.use anvil_brep::Solid;
pubfnbuild() -> Result<Solid, String> {
Err("anvil-brep has no sweep of a solid and no helical curve: a body screwed along an axis sweeps envelopes of its surfaces under the screw, which it cannot make from its profile sweeps".into())
}