A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut partway up it by a bar that is then withdrawn straight out of its groove, as a lathe's tool runs out of a thread. The tool's path is made of two pieces.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its flat tip 1 inside the rod, and it is 2 wide along the axis.
First it is carried along a screw about the z axis, turning right-handed (from +x toward +y) and rising 6 for every whole turn, rigidly, from a turn of −90° (lowered 1.5, wholly below the rod) to one of +900° (raised 15), where it points along −x, its tip at (−4, 0, 15). Then it slides without turning along −x by 3, straight back along its own length, until its tip is at (−7, 0, 15), clear of the rod. Cut from the rod everything the bar passes through.
The two pieces share the bar where the screw stops and the slide starts. The run-out is the bar's section carried straight out of the groove.
expected
closed form
volume
1364.024214
no closed form: cad-kernel, OCCT and cadrs agree to 4e-11; the mean of their values
area
822.633577
no closed form: cad-kernel, OCCT and cadrs agree to 3e-11; the mean of their values
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
8.45 s; CPU time 28.6 s; peak memory 93.2 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † no sweep along a path with a screw among its pieces
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
1364.024204
1364.024214
7.0e-09
area
822.6335641
822.633577
1.6e-08
agrees with
no other kernel
mesh
27888 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, threaded partway up by the bar//! 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1, screwed about z — right-handed, rising 6 a turn — from a//! turn of −90° to +900°, where its tip is at (−4, 0, 15), and then slid without turning 3 along//! −x, straight out of its groove: a path of two pieces.//!//! cad-kernel's sweep of a solid (`swept::closed::cut_from`) takes a path of pieces only where//! every piece is a slide or a turn (K1); a screw among them sends the path down its road for any//! other motion (K2), which takes only a convex solid of revolution and refuses the bar//! (`Unbuilt::Curved` at its corner). So the path's sweep is built as its pieces' sweeps: each//! piece, a constant twist (the screw) or one taken up where the screw left the bar (`Placed`, the//! slide), swept and cut from the rod in turn.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::{Piece, Pose, Screw, Trajectory};
use std::f64::consts::TAU;
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
constLEAD: f64 = 6.;
/// The screw's stretch of the roll, in radians of its turn.constSCREWED: [f64; 2] = [-90f64.to_radians(), 900f64.to_radians()];
/// How far the run-out slides, along −x.constRUN_OUT: f64 = 3.;
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., -8., -1.], [12., 8., 1.])?;
let screw = Screw { origin: [0., 0., 0.], axis: up, ratio: 1., advance: LEAD };
// the run-out over the next τ of the roll: a slide along −x of its whole length, taken up// where the screw left the bar (`Placed`: the screw's last pose, less the slide's own step at// the join, so the slide starts from nothing there)let [_, join] = SCREWED;
let slide = Screw { origin: [0., 0., 0.], axis: [-1., 0., 0.], ratio: 0., advance: RUN_OUT };
let still = [[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]];
let back = Pose { r: still, p: [RUN_OUT * join / TAU, 0., 0.] };
let at = screw.pose(join).then(back);
let pieces = vec![
Piece { over: SCREWED, path: Trajectory::Twist(screw) },
Piece { over: [join, join + TAU], path: Trajectory::Placed { twist: slide, at } },
];
// the two pieces checked by the kernel to make one path, meeting at the same pose at the joinlet size = rod.size().max(bar.size());
let path = Trajectory::pieces(pieces, tolerance(size), size)?;
// what the bar passes through over the path is what it passes through over each piece: each// piece's sweep cut from the rod in turn, by the kernel's own sweep of a solidletTrajectory::Pieces(pieces) = &path else { unreachable!() };
letmut cut = rod;
for piece in pieces.pieces() {
cut = cut_from(&cut, &bar, &piece.path, piece.over, bar.size(), tolerance(size))
.map_err(|why| format!("the bar's sweep over {:?} not built: {why:?}", piece.over))?;
}
Ok(cut)
}
Time
1.64 s; CPU time 1.64 s; peak memory 385.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
1364.024214
1364.024214
2.2e-10
area
822.6335762
822.633577
1.0e-09
agrees with
kentron, next.BREP, cadrs, springrep
mesh
45484 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
"""A thread with a run-out: a bar screwed up a rod, then withdrawn. A rod, the cylinder of radius 5
about the z axis from z = 0 to z = 20, with a thread cut partway up it by a bar that is then
withdrawn straight out of its groove, as a lathe's tool runs out of a thread. The tool's path is
made of two pieces.
The bar, as placed, is the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1: it points at the rod's axis, its
flat tip 1 inside the rod, and it is 2 wide along the axis.
First it is carried along a screw about the z axis, turning right-handed (from +x toward +y) and
rising 6 for every whole turn, rigidly, from a turn of −90° (lowered 1.5, wholly below the rod) to
one of +900° (raised 15), where it points along −x, its tip at (−4, 0, 15). Then it slides without
turning along −x by 3, straight back along its own length, until its tip is at (−7, 0, 15), clear
of the rod. Cut from the rod everything the bar passes through.
The two pieces share the bar where the screw stops and the slide starts. The run-out is the bar's
section carried straight out of the groove."""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, slid
ROD_RADIUS, ROD_LENGTH = 5, 20BAR = ((4, -8, -1), (12, 8, 1))
LEAD = 6# rise per whole turnSTART, STOP = -90, 900# degreesRUN_OUT = (-3, 0, 0) # then it slides straight back along its length# Neither piece of the path brings any point of the bar nearer the rod's axis: the screw keeps# every point's distance from it, and the slide carries the bar, pointing along −x, further out.# 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)
# The screw: the tip cut along its middle, through the axis, where it meets the motion# square-on; 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)
# The slide: the bar, pointing along −x, slides along its length. Its tip trails, its flat# sides slide in their own planes, and its far face, the cylinder of radius 6, leads all# over (its contact with a slide along x would be on the plane x = 0, far from it).
pieces += slid(screw(near.Shape(), LEAD, STOP), RUN_OUT)
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
2.61 s; CPU time 4.69 s; peak memory 61.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.
Data
its STEP's
expected
rel. error
volume
1364.024213
1364.024214
2.7e-10
area
822.6335763
822.633577
8.1e-10
agrees with
occt, next.BREP, cadrs, springrep
mesh
50852 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a thread cut//! partway up it by a bar, the box 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −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 900°, where it points//! along −x, its tip at (−4, 0, 15), and then slid along −x by 3, out of its groove. Everything the//! bar passes through, cut.//!//! The bar's two moves are each kentron's sweep of a solid (`sweep::solid`): the screw, and the//! slide from where the screw leaves it. Both are cut from the rod.usecrate::bench::{p, v};
use kentron::math::Axis;
use kentron::modify::{self, TransformOptions};
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, -8.0, -1.0), p(12.0, 8.0, 1.0)).build(m)?;
let screw = RigidMotion::Screw { axis: Axis::Z, lead: 6.0, from: (-90f64).to_radians(), to: 900f64.to_radians() };
let screwed = sweep::solid(m, bar, &screw)?;
let stopped = modify::transform(m, bar, &screw.at(1.0), TransformOptions::default())?;
let run_out = sweep::solid(m, stopped, &RigidMotion::Slide { by: v(-3.0, 0.0, 0.0) })?;
let rod = kentron::boolean::difference(m, rod, screwed)?;
kentron::boolean::difference(m, rod, run_out)
}
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
9.98 s; CPU time 9.98 s; peak memory 66.2 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, with a thread cut//! partway up it by the bar 4 ≤ x ≤ 12, −8 ≤ y ≤ 8, −1 ≤ z ≤ 1, carried along the screw about the//! z axis that rises 6 a turn from a turn of −90° to one of 900°, then slid along −x by 3, straight//! out of its groove.//!//! solidcraft-kernel has no sweep of a solid, so the bar's sweep is the union of its two motions'//! sweeps. The screw's is built as `square-bar-screwed-through-rod`'s is: the bar where it//! starts, wholly below the rod, and where the screw stops, with the screw sweeps of its section//! by y = 0, its faces z = ±1 and its back, 12 from the axis. Where the screw stops the bar is//! −12 ≤ x ≤ −4, −8 ≤ y ≤ 8, 14 ≤ z ≤ 16, and slid along its own length by 3 it passes over the//! box −15 ≤ x ≤ −4 of the same section, which holds the bar where the screw stops as well.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)?;
let threaded = bar_cut(rod, (4.0, -8.0, -1.0), (12.0, 8.0, 1.0), 6.0, -90.0, 900.0)?;
cut(&threaded, &block((-15.0, -8.0, 14.0), (-4.0, 8.0, 16.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.1 ms; CPU time 2.9 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 thread with a run-out: a bar screwed up a rod, then withdrawn.//// 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
329 ms; CPU time 329 ms; peak memory 82.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
1364.024214
1364.024214
3.2e-11
area
822.633577
822.633577
1.7e-11
agrees with
occt, kentron, cadrs, springrep
mesh
52490 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
//! A rod threaded partway up by a bar that is then withdrawn straight out of its groove.//!//! What a two-piece motion sweeps is the union of what each piece sweeps. The bar, the box//! 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1: through the kernel's sweep of a solid within a region//! (`sweep_solid_clipped`, the bar as a convex polyhedron) along the screw about the z axis that//! rises 6 a turn from −90° to +900°, asked for within 5.2 of the z axis from z = −0.4 to 20.4; and the//! bar where that stops (turned 900°, raised 15: the box −12 ≤ x ≤ −4, |y| ≤ 8, 14 ≤ z ≤ 16) slid//! 3 along −x, straight back along its own length, which sweeps the box −15 ≤ x ≤ −4. Both are cut//! from the rod.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, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SolidTool, 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 = SolidTool::Polyhedron {
vertices: (0..8)
.map(|i| p(if i & 1 != 0 { 12.0 } else { 4.0 }, if i & 2 != 0 { 8.0 } else { -8.0 }, 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]],
};
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: 900.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,
};
operands.push(sweep_solid_clipped(&tool0, &motion0, &clip0)?);
// The slide carries the bar straight back along its own length: it sweeps the box from the// bar's last place (−12 ≤ x ≤ −4) to 3 further out.
operands.push(make_box_brep(p(-15.0, -8.0, 14.0), 11.0, 16.0, 2.0)?);
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
138 ms; CPU time 283 ms; peak memory 18.2 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
1364.024213
1364.024214
4.8e-10
area
822.6335772
822.633577
2.9e-10
agrees with
occt, kentron, next.BREP, springrep
mesh
46950 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) with a thread cut partway//! up it by a bar (the box 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1) screwed about the z axis, rising 6 a turn,//! from a turn of −90° to 900°, then slid along −x by 3 out of its groove.//!//! Each piece is cadrs's sweep of a solid (the screw: a turn and a slide along its axis at once;//! then one slide of the bar where the screw leaves it), each cut from the rod in turn; of the bar,//! its part within 5.5 of the axis (the screw maps the cylinder about its axis onto itself, and the//! slide carries the bar's points away from the axis, so only that part reaches the rod).usecrate::bench::{block, cut, moved, p3, turned, v3};
usecrate::shared::swept::{near_axis, rod, screwed, slid, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let bar = block(k, p3(4.0, -8.0, -1.0), p3(12.0, 8.0, 1.0))?;
let bar = near_axis(k, bar, 5.5)?;
let screw = screwed(k, bar, z_axis(), 6.0, -90.0, 900.0)?;
// The bar where the screw stops: turned 900° and raised 15.let there = turned(k, bar, z_axis(), 900.0)?;
let there = moved(k, there, v3(0.0, 0.0, 15.0))?;
let out = slid(k, there, v3(-3.0, 0.0, 0.0))?;
let r = rod(k)?;
let r = cut(k, r, screw)?;
cut(k, r, out)
}
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
1.80 s; CPU time 1.80 s; peak memory 17.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
1364.024214
1364.024214
1.2e-11
area
822.633577
822.633577
7.2e-12
agrees with
occt, kentron, next.BREP, cadrs
mesh
38642 triangles, closed
centre of gravity
(0.0131962, -0.0671211, 10.3538) its STEP's solid
inertia
about it, of unit density: Ixx 54683.8; Iyy 54617.7; Izz 15336.9; Ixy -42.1671; Iyz -150.114; Izx -171.059
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything the bar//! 4 ≤ x ≤ 12, |y| ≤ 8, |z| ≤ 1 passes through as it is screwed about the z axis, rising 6 a turn,//! from a turn of −90° to one of 900° (pointing along −x, its tip at (−4, 0, 15)), then slid 3//! along −x, out of its groove.use springrep::boolean::difference;
use springrep::sweep::{Motion, solid};
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{boxed, deg, rod, screwing, unite, v3};
pubfnbuild() -> Result<Brep, String> {
let bar = boxed([4.0, -8.0, -1.0], [12.0, 8.0, 1.0], "bar")?;
let thread = solid(&bar, &screwing(6.0, deg(-90.0), deg(900.0)), "screw").map_err(e)?;
// The path is two pieces, each swept on its own: at a turn of 900°, where the second starts,// the bar is turned half a turn and raised 15, spanning −12 ≤ x ≤ −4.let end = boxed([-12.0, -8.0, 14.0], [-4.0, 8.0, 16.0], "bar")?;
let run_out = solid(&end, &Motion::Slide(v3(-3.0, 0.0, 0.0)), "slide").map_err(e)?;
difference(&rod()?, &unite(&[&thread, &run_out])?).map_err(e)
}
geomsolver left no solid to show.
Time
120 ms; CPU time 120 ms; peak memory 25.8 MB
Notes
refused error[E080]: `thread` is outside the generating-sweep class (M1: the motion is rotations about fixed axes at constant ratios, or one screw, turn or slide (a joint driven by a law alone read as its joint over the values the law reaches)): temporal contacts are read of constant rates, and a frame the drawing moves turns as the drawing does (#398)
// A rod threaded partway up by a square bar that is then withdrawn: a thread with a run-out. The// rod is the cylinder of radius 5 about z from z = 0 to 20. The bar is the box 4 <= x <= 12,// -8 <= y <= 8, -1 <= z <= 1 as placed: its section in a plane through the rod's axis and the// prism over it 8 either side. Its path is two pieces, a screw (6 a turn, from a turn of -90 to// 900 degrees) and then a slide 3 along -x, its own length, so the motion is a frame the drawing// moves: with one parameter t from -90 to 990 degrees, the frame `carrier` stands turned// min(t, 900deg) about z, risen 6 a turn of that, and slid out along -x 3 for the last 90 degrees// of t. The kernel's sweep of the bar under it is cut from the rod. Such a frame carries what is// drawn from where it stands as drawn, at the parameter's first value, so the bar is drawn where// it starts.unit mm
use std
use std.solids (cut)
use std.place (coords)
param t: Angleover (-90deg, 990deg)
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))
// the bar drawn where it starts, t = -90deg: turned -90deg about z, its middle 1.5 downprivate start_u := axis
fix(dir == (0, -1, 0)) start_u
private start_v := axis
fix(dir == (0, 0, 1)) start_v
holder := plane(u: start_u, v: start_v)
fix(origin == (0, 0, -1.5)) holder
in holder {
private b0 := point
private b1 := point
private b2 := point
private b3 := point
b0 coords(du: 4mm, dv: -1mm) holder
b1 coords(du: 12mm, dv: -1mm) holder
b2 coords(du: 12mm, dv: 1mm) holder
b3 coords(du: 4mm, dv: 1mm) holder
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: -8mm, to: 8mm))
// the frame the bar is carried by: turned min(t, 900deg) about z (the screw, held where it// stops), risen 6 a turn of that, and slid out along -x 3 over the last 90 degrees of t
carrier := frame
carrier.v parallel(sense: same) std.z
carrier.u perpendicular std.z
std.x angle(min(t, 900deg), about: std.z) carrier.u
carrier.origin distance(0mm, along: n) std.front
carrier.origin distance(-3mm * max(0deg, t - 900deg) / 90deg, along: n) std.side
carrier.origin distance(6mm * min(t, 900deg) / 360deg, along: n) std.top
construction thread := solid({ p | some t: p in bar at(under: carrier) t })
thread 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 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 thread with a run-out: a bar screwed up a rod, then withdrawn.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())
}