A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a square thread cut along it by a bar carried along a screw, as a lathe's tool cuts a thread.
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 (the face x = 4) 1 inside the rod, and it is 2 wide along the axis.
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 groove's root is the cylinder of radius 4, where the tip passes. Its walls are where the tip's two long edges pass, so the groove widens outward: at distance ρ from the axis it is 2 + (6/π)·acos(4/ρ) wide along the axis, by the turn a point of an edge makes to come round to the tip's plane. At the rod's surface that is 3.23 of every 6, so neighbouring turns of the groove stay apart.
† 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
7.23 s; CPU time 24.6 s; peak memory 80 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
1300.550211
1300.550213
1.7e-09
area
821.1671524
821.1671556
3.8e-09
agrees with
occt, kentron, next.BREP, cadrs, springrep
mesh
37538 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, with a square thread cut along it 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 1350°.//!//! Built by the kernel's closed sweep cut from the rod: `cut_from` takes the bar (its edges run//! along the screw's axis or square to it) over all four turns, as it does stopped after two//! (`square-bar-screwed-partway-up-rod`).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., -8., -1.], [12., 8., 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
1.98 s; CPU time 1.98 s; peak memory 385.1 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
1300.550213
1300.550213
4.1e-10
area
821.1671551
821.1671556
6.0e-10
agrees with
cad-kernel, kentron, next.BREP, cadrs, springrep
mesh
57770 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
"""A rod threaded by a square bar screwed along it. A rod, the cylinder of radius 5 about the z
axis from z = 0 to z = 20, with a square thread cut along it by a bar carried along a screw, as a
lathe's tool cuts a thread.
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 (the face x = 4) 1 inside the rod, and it is 2 wide along the axis.
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 groove's root is the cylinder of radius 4, where the tip passes. Its walls are where the tip's
two long edges pass, so the groove widens outward: at distance ρ from the axis it is 2 +
(6/π)·acos(4/ρ) wide along the axis, by the turn a point of an edge makes to come round to the
tip's plane. At the rod's surface that is 3.23 of every 6, so neighbouring turns of the groove stay
apart."""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, -8, -1), (12, 8, 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
1.12 s; CPU time 1.94 s; peak memory 53.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
1300.550213
1300.550213
3.8e-10
area
821.1671547
821.1671556
9.9e-10
agrees with
cad-kernel, occt, next.BREP, cadrs, springrep
mesh
68286 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a square thread//! cut 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 1350° (wholly above it).//! Everything the bar passes through, cut.//!//! 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, -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: 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
12.2 s; CPU time 12.2 s; peak memory 71.2 MB
Notes
refused the operation failed: SMLib boolean: operation: solidcore: SmApiBoolean: topology::brep::p6: no radial sector of the edge takes the new edge use; caused by topology::edge: no radial sector lies between the faces
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, with a square thread cut//! 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 1350°.//!//! solidcraft-kernel has no sweep of a solid, so the bar's sweep is built by elementary geometry//! from the kernel's helical sweep of planar regions (`sweep_helix`), which is the set a region//! passes through wherever the screw carries it across itself, never along it. Split the bar by//! the plane y = 0, through the screw's axis. The half on y ≥ 0 moves away from a point only//! through its face z = −1, its back x = 12 and the cut y = 0 (the screw turns from +x toward +y),//! so a point it passes over and leaves before the end is left through one of those; the half on//! y ≤ 0 likewise first reaches a point through its face z = 1, its back or the cut. So the bar's//! sweep is the bar where it starts and where it ends, with the screw sweeps of its section by//! y = 0, its faces z = ±1 and its back. The back stays 12 from the axis and the two places of the//! bar lie wholly below and above the rod, so the section and the faces are what it cuts.usecrate::bench::{rotated, translated};
usecrate::shared::sweep::SCREW_TOLERANCE;
usecrate::solids::*;
usecrate::Refusal;
use solidcore_ops::sweep::{screw_sweep, Curve};
use solidcore_ops::BodyasOpsBody;
use solidcraft_kernel::sweep_helix;
/// `p` turned by `deg` degrees about the z axis, from +x toward +y.pubfnturned(p: Vec3, deg: f64) -> Vec3 {
let (s, c) = deg.to_radians().sin_cos();
v3(c * p.x - s * p.y, s * p.x + c * p.y, p.z)
}
/// `plane` carried to its turn of `deg` degrees along the screw about the z axis that rises/// `lead` a turn.pubfnscrewed(plane: &Plane, lead: f64, deg: f64) -> Plane {
let rise = v3(0.0, 0.0, lead * deg / 360.0);
Plane { origin: turned(plane.origin, deg) + rise, x: turned(plane.x, deg), y: turned(plane.y, deg) }
}
/// What `region` on `plane` passes through as the screw about the z axis that rises `lead` a/// turn carries it from its turn of `start` degrees to that of `stop`.pubfnscrew(plane: &Plane, region: &Region2, lead: f64, start: f64, stop: f64) -> R<Body> {
let at = screwed(plane, lead, start);
sweep_helix(&at, region, Vec3::ZERO, Vec3::Z, lead, (stop - start) / 360.0)
}
/// The rod cut by the screw sweeps of the section by y = 0 and the faces z = `z0`, `z1` of the bar/// from (`x0`, `y0`, `z0`) to (`x1`, `y1`, `z1`), which points at the z axis across y = 0, carried/// by the screw rising `lead` a turn from its turn of `start` degrees to that of `stop`.pubfnbar_cut(rod: Body, a: (f64, f64, f64), b: (f64, f64, f64), lead: f64, start: f64, stop: f64) -> R<Body> {
let ((x0, y0, z0), (x1, y1, z1)) = (a, b);
let section = screw(&xz(), &rect(x0, z0, x1, z1), lead, start, stop)?;
let level = |z| Plane { origin: v3(0.0, 0.0, z), x: Vec3::X, y: Vec3::Y };
letmut cut_rod = cut(&rod, §ion)?;
for z in [z1, z0] {
cut_rod = cut(&cut_rod, &screw(&level(z), &rect(x0, y0, x1, y1), lead, start, stop)?)?;
}
Ok(cut_rod)
}
/// What the closed `profile` passes through as the screw about the z axis that rises `lead` a/// turn carries it from its turn of `start` degrees to that of `stop`, on solidcore-ops, whose/// screw sweep holds its walls to the runner's `SCREW_TOLERANCE`: swept from where it is drawn,/// then turned and raised to the screw's turn of `start`.pubfnscrew_ops(profile: &[Curve], lead: f64, start: f64, stop: f64) -> Result<OpsBody, Refusal> {
let turns = (stop - start) / 360.0;
let swept = screw_sweep(profile, [0.0; 3], [0.0, 0.0, 1.0], lead, turns, None, SCREW_TOLERANCE)?;
let turned = rotated(swept, [0.0; 3], [0.0, 0.0, 1.0], start)?;
translated(turned, [0.0, 0.0, lead * start / 360.0])
}
pubfnbuild() -> R<Body> {
let rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
bar_cut(rod, (4.0, -8.0, -1.0), (12.0, 8.0, 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.3 ms; CPU time 3 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 square bar screwed along it.//// 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
441 ms; CPU time 440 ms; peak memory 111.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
1300.550213
1300.550213
4.6e-11
area
821.1671555
821.1671556
3.1e-11
agrees with
cad-kernel, occt, kentron, cadrs, springrep
mesh
74370 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
//! A rod with a square thread cut by a 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| ≤ 8 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, -8.0], to: [12.0, -8.0] },
OutlinePiece::Line { from: [12.0, -8.0], to: [12.0, 8.0] },
OutlinePiece::Line { from: [12.0, 8.0], to: [4.0, 8.0] },
OutlinePiece::Line { from: [4.0, 8.0], to: [4.0, -8.0] },
],
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 { 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]],
};
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
184 ms; CPU time 375 ms; peak memory 20.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.
Data
its STEP's
expected
rel. error
volume
1300.550212
1300.550213
5.8e-10
area
821.1671561
821.1671556
7.0e-10
agrees with
cad-kernel, occt, kentron, next.BREP, springrep
mesh
62214 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
//! A rod (the cylinder of radius 5 about the z axis from z = 0 to z = 20) with a square thread cut//! 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 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, -8.0, -1.0), p3(12.0, 8.0, 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
2.15 s; CPU time 2.15 s; peak memory 20.3 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Its volume and area are its STEP file's, as the harness measures them from the file's exact geometry (harness/mass/); its triangles are Open CASCADE's mesh of the file, for the pictures.
Data
its STEP's
expected
rel. error
volume
1300.550213
1300.550213
2.8e-13
area
821.1671556
821.1671556
7.0e-13
agrees with
cad-kernel, occt, kentron, next.BREP, cadrs
mesh
50618 triangles, closed
centre of gravity
(-0.0255477, -0.0442499, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50361.8; Iyy 50367.1; Izz 14025.5; Ixy 4.62754; Iyz -160.102; Izx 277.305
//! 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 1350°: a square thread.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, -8.0, -1.0], [12.0, 8.0, 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
988 ms; CPU time 1.63 s; peak memory 71.3 MB
Notes
wrong volume 1300.46112813 against 1300.55021318 (its STEP's); area 821.304557479 against 821.167155564 (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
1300.461128
1300.550213
6.8e-05
area
821.3045575
821.1671556
1.7e-04
agrees with
no other kernel
mesh
171620 triangles, closed
centre of gravity
(-0.0255674, -0.0442563, 10) its STEP's solid
inertia
about it, of unit density: Ixx 50358.1; Iyy 50363.4; Izz 14024.1; Ixy 4.62717; Iyz -160.215; Izx 277.327
// A rod threaded by a square bar carried along a screw, as a lathe cuts a square thread. 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,// -8 <= y <= 8, -1 <= z <= 1: its section drawn in the front plane (x, z), dimensioned from the// rod's axis, and the prism over it 8 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: -8mm, to: 8mm))
// 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 980 µ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 rod threaded by a square bar screwed along it.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())
}