The rod and tunnel of swept/box-screwed-inside-a-rod, turned rigidly about the origin so that the rod's axis is no longer a coordinate axis. Write u = (2, −2, 1)/3, v = (2, 1, −2)/3 and w = (1, 2, 2)/3: three unit vectors square to one another, right-handed (u × v = w). The point that case puts at (x, y, z) is here at x·u + y·v + z·w.
So: a rod, the cylinder of radius 5 about the line through the origin along w, from the origin to 20w = (20/3, 40/3, 40/3), with a sealed helical tunnel inside it: everything a small box passes through as it is carried along a screw wholly within the rod.
The box, as placed, is a cube of side 1 with its edges along u, v and w: every point p with 2.5 ≤ p·u ≤ 3.5, −0.5 ≤ p·v ≤ 0.5 and 2 ≤ p·w ≤ 3. Its corner 2.5u − 0.5v + 2w is (2, −1/2, 5/2).
The screw is about the rod's axis: the box turns right-handed about w (from u toward v) and rises 4 along w for every whole turn, rigidly, from a turn of 0° to one of 720°, ending as the box 2.5 ≤ p·u ≤ 3.5, −0.5 ≤ p·v ≤ 0.5, 10 ≤ p·w ≤ 11. Cut from the rod everything the box passes through.
The box stays inside the rod all the way, so the result is the rod with a closed helical cavity two turns long, square in section and ended by the box's own faces: two shells. The box's faces square to w sweep helicoidal sheets and its other faces cylinders and ruled sheets, meeting along its edges' helices.
expected
closed form
volume
1522.316219
no closed form: swept/box-screwed-inside-a-rod's answer (the mean of cad-kernel's and OCCT's values, which agree to 4e-11), the solid being that one turned rigidly
area
961.1374882
no closed form: swept/box-screwed-inside-a-rod's answer (the mean of cad-kernel's and OCCT's values, which agree to 7e-11), the solid being that one turned rigidly
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.
cad-kernel left no solid to show.
Time
13.2 s; CPU time 46.6 s; peak memory 503.1 MB
Notes
refused the box's sweep not built: Failed("face 11 (): loop 1 turns the wrong way (8.602653673138234e-1 in its parameters)")
//! The rod and tunnel of `swept/box-screwed-inside-a-rod` turned rigidly so that the rod's axis is//! w = (1, 2, 2)/3: the cylinder of radius 5 about w from the origin to 20w, less everything the unit//! cube 2.5 ≤ p·u ≤ 3.5, −0.5 ≤ p·v ≤ 0.5, 2 ≤ p·w ≤ 3 passes through as it is screwed about w,//! rising 4 a turn, for two turns: a sealed helical cavity.usecrate::sketch::block;
use cad_kernel::build::{disc, prism};
use cad_kernel::geom::{tolerance, Frame, V};
use cad_kernel::swept::closed::cut_from;
use cad_kernel::topo::Brep;
use cad_kernel::trajectory::{Screw, Trajectory};
use std::f64::consts::TAU;
/// The turned frame: u where the case before it had x, w where it had z (v = w × u).constU: V = [2. / 3., -2. / 3., 1. / 3.];
constW: V = [1. / 3., 2. / 3., 2. / 3.];
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
/// The box in (u, v, w).constBOX_LO: V = [2.5, -0.5, 2.];
constBOX_HI: V = [3.5, 0.5, 3.];
/// How far the screw rises a whole turn, and how many turns it makes.constRISE: f64 = 4.;
constTURNS: f64 = 2.;
pubfnbuild() -> Result<Brep, String> {
let rod = prism(&disc([0.; 3], W, ROD_RADIUS), 0., ROD_LENGTH)?;
// the box drawn in (u, v, w) and placed: the point (x, y, z) at xu + yv + zwlet tool = block(BOX_LO, BOX_HI)?.moved(&Frame::new([0.; 3], W, U).placing());
// the screw about w: a radian a radian of the roll, rising `RISE` a turnlet path = Trajectory::Twist(Screw { origin: [0.; 3], axis: W, ratio: 1., advance: RISE });
let size = rod.size();
cut_from(&rod, &tool, &path, [0., TURNS * TAU], size, tolerance(size))
.map_err(|why| format!("the box's sweep not built: {why:?}"))
}
Time
11.4 s; CPU time 11.4 s; peak memory 422.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
1522.316219
1522.316219
1.6e-11
area
961.1374881
961.1374882
2.9e-11
agrees with
next.BREP, cadrs, springrep
mesh
18490 triangles, closed
centre of gravity
(3.36914, 6.74232, 6.7403) its STEP's solid
inertia
about it, of unit density: Ixx 56364.3; Iyy 42420.2; Izz 42523.4; Ixy -9363.01; Iyz -18591.3; Izx -9330.25
"""A sealed helical tunnel in a tilted rod: a box screwed inside it. The rod and tunnel of
swept/box-screwed-inside-a-rod, turned rigidly about the origin so that the point that case puts
at (x, y, z) is here at x·u + y·v + z·w, where u = (2, −2, 1)/3, v = (2, 1, −2)/3 and
w = (1, 2, 2)/3.
So: a rod, the cylinder of radius 5 about the line through the origin along w, from the origin to
20w, with a sealed helical tunnel inside it: everything the cube of side 1 with 2.5 ≤ p·u ≤ 3.5,
−0.5 ≤ p·v ≤ 0.5 and 2 ≤ p·w ≤ 3 passes through as it turns right-handed about w (from u toward
v), rising 4 along w for every whole turn, from a turn of 0° to one of 720°."""fromOCP.BRepBuilderAPIimportBRepBuilderAPI_TransformfromOCP.gp import gp_Ax3, gp_Dir, gp_Pnt, gp_Trsf
from bench import other_case
U = (2 / 3, -2 / 3, 1 / 3)
W = (1 / 3, 2 / 3, 2 / 3) # the rod's axis; v = w × udefbuild():
# OCCT's sweeps of the box's faces along a screw (sweep.py's `screwed`) follow a screw about# the z axis, so the rod and its tunnel are built in the frame whose z axis is the rod's,# as swept/box-screwed-inside-a-rod builds them, and placed by the rigid motion that takes# that frame to u, v, w.
upright = other_case("swept/box-screwed-inside-a-rod").build()
placing = gp_Trsf()
placing.SetDisplacement(gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1), gp_Dir(1, 0, 0)),
gp_Ax3(gp_Pnt(0, 0, 0), gp_Dir(*W), gp_Dir(*U)))
returnBRepBuilderAPI_Transform(upright, placing, True).Shape()
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.
kentron 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.
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
8.39 s; CPU time 8.39 s; peak memory 70.8 MB
Notes
refused the operation failed: SMLib boolean: operation: solidcore: SmApiBoolean: topology::proto_topology::p3::split_intersecting_proto_edges: two proto edges overlap along less than their definitions can split
//! `swept/box-screwed-inside-a-rod` turned rigidly about the origin so that the rod's axis is//! w = (1, 2, 2)/3: the point that case puts at (x, y, z) is here at x·u + y·v + z·w, with//! u = (2, −2, 1)/3 and v = (2, 1, −2)/3.//!//! Built as that case builds it, the box's sweep made by elementary geometry from the kernel's//! helical sweep of planar regions (solidcraft-kernel has no sweep of a solid), each piece turned//! into place as it is made, so that every cut is made about the tilted axis.usesuper::box_screwed_inside_a_rod::placed_rod;
usecrate::solids::*;
use solidcraft_kernel::transform_matrix;
/// The turn taking x, y and z to u, v and w, column by column.constTURN: [[f64; 4]; 4] = [
[2.0 / 3.0, -2.0 / 3.0, 1.0 / 3.0, 0.0],
[2.0 / 3.0, 1.0 / 3.0, -2.0 / 3.0, 0.0],
[1.0 / 3.0, 2.0 / 3.0, 2.0 / 3.0, 0.0],
[0.0, 0.0, 0.0, 1.0],
];
pubfnbuild() -> R<Body> {
placed_rod(1.0, &|piece| transform_matrix(&piece, TURN))
}
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
It has not run.
Notes
missing no implementation
Data
No measures: it built no solid to measure.
Implementation
No implementation yet.
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
7.49 s; CPU time 7.49 s; peak memory 135 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
1522.316219
1522.316219
2.3e-11
area
961.1374881
961.1374882
4.7e-11
agrees with
occt, cadrs, springrep
mesh
23466 triangles, closed
centre of gravity
(3.36914, 6.74232, 6.7403) its STEP's solid
inertia
about it, of unit density: Ixx 56364.3; Iyy 42420.2; Izz 42523.4; Ixy -9363.01; Iyz -18591.3; Izx -9330.25
//! `swept/box-screwed-inside-a-rod` turned rigidly so that the rod's axis runs along//! w = (1, 2, 2)/3, with u = (2, −2, 1)/3 and v = (2, 1, −2)/3: a rod (radius 5, from the origin to//! 20w) with a sealed helical tunnel, everything the unit cube 2.5 ≤ p·u ≤ 3.5, |p·v| ≤ 0.5,//! 2 ≤ p·w ≤ 3 passes through along the screw about the rod's axis that rises 4 a turn, from 0° to//! 720°.//!//! Built as the original is, every point and direction it places at (x, y, z) placed at//! x·u + y·v + z·w: the kernel's sweep of a solid in parts (`sweep_solid_parts`), the cube as a//! convex polyhedron, screwed about w; the rod is cut by the parts.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_parts, BooleanOperation, BrepSolid, OutlinePiece, ScrewStep, SolidMotion,
SolidTool, Vec3,
};
#[allow(unused_imports)]use std::f64::consts::{FRAC_PI_2, PI, TAU};
/// The point (or direction) the upright case puts at (x, y, z), here at x·u + y·v + z·w.fnat(x: f64, y: f64, z: f64) -> Vec3 {
let (u, v, w) = (p(2.0, -2.0, 1.0).scale(1.0 / 3.0), p(2.0, 1.0, -2.0).scale(1.0 / 3.0),
p(1.0, 2.0, 2.0).scale(1.0 / 3.0));
u.scale(x).add(v.scale(y)).add(w.scale(z))
}
pubfnbuild() -> Result<BrepSolid, Refusal> {
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), at(0.0, 0.0, 1.0), 5.0, 20.0)?;
letmut operands = vec![rod];
let tool0 = SolidTool::Polyhedron {
vertices: (0..8)
.map(|i| at(if i & 1 != 0 { 3.5 } else { 2.5 }, if i & 2 != 0 { 0.5 } else { -0.5 }, if i & 4 != 0 { 3.0 } else { 2.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: at(0.0, 0.0, 1.0), turn: 1.0, advance: 4.0 / TAU },
],
from: 0.0,
to: (4.0 * PI),
};
operands.extend(sweep_solid_parts(&tool0, &motion0)?);
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
2.23 s; CPU time 6.07 s; peak memory 69.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
1522.316219
1522.316219
7.7e-11
area
961.1374879
961.1374882
2.3e-10
agrees with
occt, next.BREP, springrep
mesh
16832 triangles, closed, 2 degenerate
centre of gravity
(3.36914, 6.74232, 6.7403) its STEP's solid
inertia
about it, of unit density: Ixx 56364.3; Iyy 42420.2; Izz 42523.4; Ixy -9363.01; Iyz -18591.3; Izx -9330.25
//! `swept/box-screwed-inside-a-rod` turned rigidly so that the rod's axis runs along//! w = (1, 2, 2)/3, with u = (2, −2, 1)/3 and v = (2, 1, −2)/3: a rod (radius 5, from the origin//! to 20w) with a sealed helical tunnel, everything the unit cube 2.5 ≤ p·u ≤ 3.5,//! −0.5 ≤ p·v ≤ 0.5, 2 ≤ p·w ≤ 3 passes through as it is screwed about the rod's axis, rising 4//! a turn, from 0° to 720°.//!//! The cube is a square sketched on the plane through 2.5u − 0.5v + 2w square to w (its x axis//! along u), extruded 1 along w; its screw is cadrs's sweep of a solid, cut from the rod.usecrate::bench::{cut, cylinder, extrude, p3, v3};
usecrate::shared::swept::screwed;
usecrate::Refusal;
use cadrs_kernel::{Axis, BodyId, DefaultKernel, Loop, Plane, Profile};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let (u, w) = (v3(2.0, -2.0, 1.0) / 3.0, v3(1.0, 2.0, 2.0) / 3.0);
let o = p3(0.0, 0.0, 0.0);
let face = Profile::of(Plane::new(p3(2.0, -0.5, 2.5), u, w), vec![Loop::rectangle(0.0, 0.0, 1.0, 1.0)]);
let tool = extrude(k, &face, 1.0)?;
let swept = screwed(k, tool, Axis::new(o, w), 4.0, 0.0, 720.0)?;
let r = cylinder(k, o, w, 5.0, 20.0)?;
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
1.87 s; CPU time 1.87 s; peak memory 14.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
1522.316219
1522.316219
2.1e-11
area
961.1374881
961.1374882
3.6e-11
agrees with
occt, next.BREP, cadrs
mesh
16824 triangles, closed
centre of gravity
(3.36914, 6.74232, 6.7403) its STEP's solid
inertia
about it, of unit density: Ixx 56364.3; Iyy 42420.2; Izz 42523.4; Ixy -9363.01; Iyz -18591.3; Izx -9330.25
//! `swept/box-screwed-inside-a-rod` turned rigidly so that the rod's axis runs along//! w = (1, 2, 2)/3, with u = (2, −2, 1)/3 and v = (2, 1, −2)/3: the rod of radius 5 about the line//! through the origin along w, from the origin to 20w, less everything the unit cube//! 2.5 ≤ p·u ≤ 3.5, |p·v| ≤ 0.5, 2 ≤ p·w ≤ 3 passes through as it is screwed about that line,//! rising 4 a turn, from a turn of 0° to one of 720°: a sealed helical tunnel.//!//! Built as the original is, each frame it places (the world's, at a point) placed with its x//! along u, its y along v and its z along w: the shared box and rod written out on those frames,//! and the shared screw about w.use std::f64::consts::PI;
use springrep::boolean::difference;
use springrep::math::{Point3, Vec3};
use springrep::primitive::{block, cylinder};
use springrep::sweep::{solid, Helix, Motion};
use springrep::topo::Brep;
usecrate::shared::swept::deg;
usecrate::shared::{e, frame};
constU: [f64; 3] = [2.0 / 3.0, -2.0 / 3.0, 1.0 / 3.0];
constV: [f64; 3] = [2.0 / 3.0, 1.0 / 3.0, -2.0 / 3.0];
constW: [f64; 3] = [1.0 / 3.0, 2.0 / 3.0, 2.0 / 3.0];
/// The point the upright case puts at (x, y, z), here at x·u + y·v + z·w.fnat(x: f64, y: f64, z: f64) -> [f64; 3] {
[0, 1, 2].map(|i| x * U[i] + y * V[i] + z * W[i])
}
pubfnbuild() -> Result<Brep, String> {
let bar = block(&frame(at(2.5, -0.5, 2.0), W, U)?, Vec3::new(1.0, 1.0, 1.0), "bar").map_err(e)?;
let screw = Motion::Screw {
screw: Helix { origin: Point3::ZERO, axis: Vec3::from_array(W), rise: 4.0 / (2.0 * PI), sign: 1.0 },
from: 0.0,
to: deg(720.0),
};
let swept = solid(&bar, &screw, "screw").map_err(e)?;
let rod = cylinder(&frame([0.0, 0.0, 0.0], W, U)?, 5.0, 20.0, "rod").map_err(e)?;
difference(&rod, &swept).map_err(e)
}
geomsolver 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.
anvilcad left no solid to show.
Time
1.2 ms; CPU time 1 ms; 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 sealed helical tunnel in a tilted rod: a box screwed inside 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())
}