A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved along its length by a wheel slid past it. The wheel is a torus: its axis is parallel to the y axis, the circle through its tube's centers has radius 6, and its tube has radius 2. It starts with its center at (11.5, 0, −9), so the part of its tube nearest the rod is centered 5.5 from the rod's axis and reaches 1.5 into it, and the whole wheel is below the rod. It slides without turning along the z axis, up to center (11.5, 0, 29), where the whole wheel is above the rod. Cut from the rod everything the wheel passes through.
As a set:
$$\{\,\rho \le 5,\ 0 \le z \le 20\,\} \setminus \bigl(T \oplus \{\,s\,(0,0,38) : 0 \le s \le
1\,\}\bigr), \quad T = \bigl\{\,\bigl(\sqrt{(x-11.5)^2 + (z+9)^2} - 6\bigr)^2 + y^2 \le
2^2\,\bigr\}$$
† works around a missing feature. ▦ a faceted solid: a mesh stored as B-rep faces. 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
63 ms; CPU time 91 ms; 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.
//! A rod, the cylinder of radius 5 about z from z = 0 to 20, grooved along its length by a torus//! (axis along y, radii 6 and 2) slid without turning along z from centre (11.5, 0, −9) to//! (11.5, 0, 29).use cad_kernel::build::{disc, prism, torus};
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 std::f64::consts::TAU;
constROD_RADIUS: f64 = 5.;
constROD_LENGTH: f64 = 20.;
constCENTRE: V = [11.5, 0., -9.];
constMAJOR: f64 = 6.;
constMINOR: f64 = 2.;
constSLIDE: f64 = 38.;
/// How closely the wheel is meshed for the sweep's membership reads: a two-hundredth of its tube's/// radius.constBAR: f64 = 0.01;
pubfnbuild() -> Result<Brep, String> {
let up = [0., 0., 1.];
let rod = prism(&disc([0., 0., 0.], up, ROD_RADIUS), 0., ROD_LENGTH)?;
let wheel = torus(CENTRE, [0., 1., 0.], MAJOR, MINOR)?;
// the slide along z: a screw that does not turn, advancing its whole length over a roll of τlet path = Trajectory::Twist(Screw { origin: CENTRE, axis: up, ratio: 0., advance: SLIDE });
// the kernel's closed swept solid cut from the rod on one arrangement: a torus slid square to// its axis, the meridians square to the slide swept into cylinders along zlet size = rod.size().max(wheel.size());
cut_from(&rod, &wheel, &path, [0., TAU], BAR, tolerance(size))
.map_err(|why| format!("the wheel's sweep not built: {why:?}"))
}
Time
1.13 s; CPU time 1.13 s; peak memory 378.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.
"""A rod grooved by a wheel slid along it. A rod, the cylinder of radius 5 about the z axis from
z = 0 to z = 20, grooved along its length by a wheel slid past it. The wheel is a torus: its axis
is parallel to the y axis, the circle through its tube's centres has radius 6, and its tube has
radius 2. It starts with its centre at (11.5, 0, −9), so the part of its tube nearest the rod is
centred 5.5 from the rod's axis and reaches 1.5 into it, and the whole wheel is below the rod. It
slides without turning along the z axis, up to centre (11.5, 0, 29), where the whole wheel is
above the rod. Cut from the rod everything the wheel passes through."""import math
fromOCP.BRepAlgoAPIimportBRepAlgoAPI_Cut, BRepAlgoAPI_Fuse, BRepAlgoAPI_SplitterfromOCP.BRepBuilderAPIimportBRepBuilderAPI_MakeFace, BRepBuilderAPI_TransformfromOCP.BRepPrimAPIimportBRepPrimAPI_MakeCylinder, BRepPrimAPI_MakePrism, BRepPrimAPI_MakeTorusfromOCP.TopAbsimportTopAbs_SHELL, TopAbs_SOLIDfromOCP.TopExpimportTopExp_ExplorerfromOCP.collections importList_TopoDS_ShapefromOCP.gp import gp, gp_Ax2, gp_Ax3, gp_Cylinder, gp_Pln, gp_Pnt, gp_Trsf, gp_Vec
from bench importRefusedROD_RADIUS = 5ROD_LENGTH = 20WHEEL_START = (11.5, 0, -9)
WHEEL_END = (11.5, 0, 29)
WHEEL_RADIUS = 6# of the circle through the tube's centresTUBE_RADIUS = 2defshapes(*items):
listed = List_TopoDS_Shape()
for item in items:
listed.Append(item)
return listed
defbuild():
centre = gp_Pnt(*WHEEL_START)
wheel = BRepPrimAPI_MakeTorus(gp_Ax2(centre, gp.DY_s()), WHEEL_RADIUS, TUBE_RADIUS).Shape()
slide = gp_Vec(centre, gp_Pnt(*WHEEL_END))
moved = gp_Trsf()
moved.SetTranslation(slide)
wheel_at_end = BRepBuilderAPI_Transform(wheel, moved, True).Shape()
# OCCT's prism sweeps no solid ("Solids are not Processed"), but it sweeps a shell, each face# to the solid that face passes through. A face swept whole is only what it passes through if# the slide never runs along it inside it. The torus's normal, at the point of its tube's# circle turned u about the wheel's axis and v round the tube, is# cos v·(cos u·x + sin u·z) + sin v·y; it is square to the slide (z) where sin u = 0, the tube's# two circles in the plane z = −9 through the centre, and where cos v = 0, the wheel's two# circles of radius 6 on its tube's top and bottom (y = ±2). Split the torus along those four# circles, by that plane and by the cylinder of radius 6 about the wheel's axis; each piece# then slides without folding over itself.
reach = 2 * (WHEEL_RADIUS + TUBE_RADIUS) # the splitting faces run well past the wheel
plane = BRepBuilderAPI_MakeFace(gp_Pln(centre, gp.DZ_s()), -reach, reach, -reach, reach).Face()
cylinder = BRepBuilderAPI_MakeFace(gp_Cylinder(gp_Ax3(centre, gp.DY_s()), WHEEL_RADIUS),
0, 2 * math.pi, -reach, reach).Face()
splitter = BRepAlgoAPI_Splitter()
splitter.SetArguments(shapes(TopExp_Explorer(wheel, TopAbs_SHELL).Current()))
splitter.SetTools(shapes(plane, cylinder))
splitter.Build()
ifnot splitter.IsDone():
raiseRefused("BRepAlgoAPI_Splitter could not split the wheel along its outline")
prism = BRepPrimAPI_MakePrism(splitter.Shape(), slide)
ifnot prism.IsDone():
raiseRefused("BRepPrimAPI_MakePrism could not slide the wheel's faces")
# Everything the wheel passes through is the wheel where it starts, the wheel where it ends,# and everything its faces pass through: a point the wheel covers that no face ever crosses# stays inside the wheel all the way.
tools = shapes(wheel_at_end)
swept = TopExp_Explorer(prism.Shape(), TopAbs_SOLID)
while swept.More():
tools.Append(swept.Current())
swept.Next()
fuse = BRepAlgoAPI_Fuse()
fuse.SetArguments(shapes(wheel))
fuse.SetTools(tools)
fuse.Build()
ifnot fuse.IsDone():
raiseRefused("BRepAlgoAPI_Fuse declined the faces' sweeps and the wheel at each end")
rod = BRepPrimAPI_MakeCylinder(gp.XOY_s(), ROD_RADIUS, ROD_LENGTH).Shape()
cut = BRepAlgoAPI_Cut(rod, fuse.Shape())
ifnot cut.IsDone():
raiseRefused("BRepAlgoAPI_Cut declined the groove")
return cut.Shape()
Time
18 ms; CPU time 18 ms; peak memory 11 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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a torus slid//! along z past it: the torus's axis parallel to y, the circle through its tube's centres of//! radius 6, its tube of radius 2, its centre slid from (11.5, 0, −9) to (11.5, 0, 29).//!//! arris has no sweep of a solid, so the wheel's sweep is built from its shape by elementary//! geometry. The slide runs along z, in the torus's own mid-plane (y = 0). A line along z through//! a point (x, y) meets the torus where (x, y) is in the torus's shadow along z: within 2 of the//! segment from (5.5, 0) to (17.5, 0), the stadium the tube's circles cast. The line meets the//! torus in at most two pieces, the gap between them at most the hole's width 8, and the slide of//! 38 is longer, so the pieces' sweeps run together: on that line the wheel passes over everything//! from below its first place to above its last. The sweep is the torus where it//! starts, the torus where it ends, and between their centres the stadium extruded along z. The//! end tori lie wholly below z = −1 and above z = 21, clear of the rod, so what the sweep takes//! from the rod is that prism's alone: it is the tool cut here.use arris::geom::{Profile, ProfileLoop, ProfileSegment};
use arris::math::{Axis, Control, Frame, Point2, Point3, Vec3};
use arris::ops::{cut, extrude, primitive_cylinder, OpError};
use arris::topo::{Body, Model};
constROD_RADIUS: f64 = 5.0;
constROD_LENGTH: f64 = 20.0;
/// The wheel: its centre's x, the radius of the circle through its tube's centres and its tube's.constWHEEL_X: f64 = 11.5;
constMAJOR: f64 = 6.0;
constMINOR: f64 = 2.0;
/// The wheel's centre's height where it starts and where it ends.constSTART_Z: f64 = -9.0;
constEND_Z: f64 = 29.0;
pubfnbuild(m: &mutModel) -> Result<Body, OpError> {
let axis = Axis::z_at(Point3::origin());
let (rod, _) = primitive_cylinder(m, axis, ROD_RADIUS, ROD_LENGTH, &Control::NONE)?;
// the wheel's shadow along z, in the plane z = −9 (u along x, v along y): the rectangle the// tube's near and far sections span, closed by a half disc of the tube's radius at each endlet (near, far) = (WHEEL_X - MAJOR, WHEEL_X + MAJOR);
let p = Point2::new;
let shadow = Profile {
plane: Frame::new(Point3::new(0.0, 0.0, START_Z), Vec3::z(), Vec3::x())?,
outer: ProfileLoop::Path {
start: p(near, -MINOR),
segments: vec![
ProfileSegment::LineTo(p(far, -MINOR)),
ProfileSegment::ArcTo { to: p(far, MINOR), via: p(far + MINOR, 0.0) },
ProfileSegment::LineTo(p(near, MINOR)),
ProfileSegment::ArcTo { to: p(near, -MINOR), via: p(near - MINOR, 0.0) },
],
},
holes: vec![],
};
let (swept, _) = extrude(m, &shadow, Vec3::z(), END_Z - START_Z, &Control::NONE)?;
let (grooved, _) = cut(m, rod, swept, &Control::NONE)?;
Ok(grooved)
}
Time
101 ms; CPU time 150 ms; peak memory 16 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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel slid//! past it: the torus with its axis parallel to the y axis, radii 6 and 2, slid without turning//! from centre (11.5, 0, −9), wholly below the rod, to (11.5, 0, 29), wholly above it. Everything//! the wheel passes through, cut.//!//! The wheel's sweep is kentron's sweep of a solid (`sweep::solid`, one slide), cut from the rod.usecrate::bench::{frame, p, v};
use kentron::math::Direction;
use kentron::primitives::{Cylinder, Torus};
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 wheel = Torus::new(6.0, 2.0).with_frame(frame(p(11.5, 0.0, -9.0), Direction::Y)).build(m)?;
let swept = sweep::solid(m, wheel, &RigidMotion::Slide { by: v(0.0, 0.0, 38.0) })?;
kentron::boolean::difference(m, rod, swept)
}
Time
75 ms; CPU time 75 ms; peak memory 12 MB
Notes
wrong volume 1494.90079969 against 1493.75457295 (its STEP's); area 794.730108435 against 794.360898928 (its STEP's)
Workaround † no sweep of a solid
Faceted ▦ 880 faces, where the other kernels' solids have 4 (the median): a mesh stored as B-rep faces.
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
1494.9008
1493.754573
7.7e-04
area
794.7301084
794.3608989
4.6e-04
agrees with
no other kernel
mesh
880 triangles, closed
centre of gravity
(-0.217514, -1.07624e-10, 10) its STEP's solid
inertia
about it, of unit density: Ixx 59595.1; Iyy 58161.2; Izz 18081.5; Ixy 7.02218e-07; Iyz 0.0362032; Izx -2.66138e-06
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a torus slid//! along z past it: the torus's axis parallel to y, the circle through its tube's centres of//! radius 6, its tube of radius 2, its centre slid from (11.5, 0, −9) to (11.5, 0, 29).//!//! vcad has no sweep of a solid, so the wheel's sweep is built from its shape by elementary//! geometry. The slide runs along z, in the torus's own mid-plane (y = 0). A line along z through//! a point (x, y) meets the torus where (x, y) is in the torus's shadow along z: within 2 of the//! segment from (5.5, 0) to (17.5, 0), the stadium the tube's circles cast. The line meets the//! torus in at most two pieces, the gap between them at most the hole's width 8, and the slide of//! 38 is longer, so the pieces' sweeps run together: on that line the wheel passes over everything//! from below its first place to above its last. The sweep is the torus where it starts, the torus//! where it ends, and between their centres the stadium extruded along z. The end tori lie wholly//! below z = −1 and above z = 21, clear of the rod, so what the sweep takes from the rod is that//! prism's alone: it is the tool cut here.usecrate::solids::SEGMENTS;
use vcad_kernel::vcad_kernel_math::{Point2, Point3, Vec3};
use vcad_kernel::vcad_kernel_sketch::{SketchProfile, SketchSegment};
use vcad_kernel::Solid;
constROD_RADIUS: f64 = 5.0;
constROD_LENGTH: f64 = 20.0;
/// The wheel: its centre's x, the radius of the circle through its tube's centres and its tube's.constWHEEL_X: f64 = 11.5;
constMAJOR: f64 = 6.0;
constMINOR: f64 = 2.0;
/// The wheel's centre's height where it starts and where it ends.constSTART_Z: f64 = -9.0;
constEND_Z: f64 = 29.0;
pubfnbuild() -> Result<Solid, crate::Refusal> {
let rod = Solid::cylinder(ROD_RADIUS, ROD_LENGTH, SEGMENTS);
// the wheel's shadow along z, sketched in the plane z = −9: the rectangle the tube's near and// far sections span, closed by a half disc of the tube's radius at each endlet (near, far) = (WHEEL_X - MAJOR, WHEEL_X + MAJOR);
let p = Point2::new;
let line = |start, end| SketchSegment::Line { start, end };
let arc = |start, end, center| SketchSegment::Arc { start, end, center, ccw: true };
let shadow = vec![
line(p(near, -MINOR), p(far, -MINOR)),
arc(p(far, -MINOR), p(far, MINOR), p(far, 0.0)),
line(p(far, MINOR), p(near, MINOR)),
arc(p(near, MINOR), p(near, -MINOR), p(near, 0.0)),
];
let shadow = SketchProfile::new(Point3::new(0.0, 0.0, START_Z), Vec3::x(), Vec3::y(), shadow)?;
let swept = Solid::extrude(shadow, Vec3::new(0.0, 0.0, END_Z - START_Z))?;
Ok(rod.try_difference(&swept)?)
}
Time
33 ms; CPU time 33 ms; peak memory 44.4 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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a torus slid//! along z past it: its axis parallel to y, the circle through its tube's centres of radius 6,//! its tube of radius 2, its centre slid from (11.5, 0, −9) to (11.5, 0, 29).//!//! solidcraft-kernel has no sweep of a solid, so the wheel's sweep is built by elementary//! geometry. A line along z through (x, y) meets the wheel if and only if (x, y) lies in its//! shadow along z: within 2 of the segment from (5.5, 0) to (17.5, 0), a slot. The wheel is//! symmetric about its centre's height, and on such a line it spans at most 16 with a gap of at//! most 8, the hole, so slid 38 it passes over the whole of the line from its centre where it//! starts to its centre where it ends. The sweep is then the slot extruded between those heights,//! with the wheel where it starts and where it ends; those two lie wholly below z = −1 and above//! z = 21, clear of the rod, so the slot's prism is what the sweep takes from the rod.usecrate::solids::*;
/// The shadow along z of a wheel whose axis runs along y through (`x`, `y`, `z`): its tube of/// radius `tube` about a circle of radius `ring`. The slot within `tube` of the segment from/// `x − ring` to `x + ring` at height `y`, on the plane at height `z`.pubfnshadow(x: f64, y: f64, z: f64, ring: f64, tube: f64) -> (Plane, Region2) {
use solidcore_record::Seg2;
use std::f64::consts::{FRAC_PI_2, PI};
let (near, far) = (x - ring, x + ring);
let segs = vec![
Seg2::Line { a: v2(near, y - tube), b: v2(far, y - tube) },
Seg2::Arc { center: v2(far, y), radius: tube, start: -FRAC_PI_2, sweep: PI },
Seg2::Line { a: v2(far, y + tube), b: v2(near, y + tube) },
Seg2::Arc { center: v2(near, y), radius: tube, start: FRAC_PI_2, sweep: PI },
];
let plane = Plane { origin: v3(0.0, 0.0, z), x: Vec3::X, y: Vec3::Y };
(plane, Region2 { outer: Loop2 { segs }, holes: vec![] })
}
pubfnbuild() -> R<Body> {
let rod = zcyl(0.0, 0.0, 5.0, 0.0, 20.0)?;
let (plane, slot) = shadow(11.5, 0.0, -9.0, 6.0, 2.0);
cut(&rod, &extrude(&plane, slot, 0.0, 38.0)?)
}
Time
6.2 ms; CPU time 6 ms; peak memory 9.9 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.
//! A rod grooved by a wheel slid along it. brepkit sweeps faces, not solids, so the wheel's sweep//! is built by elementary geometry: a solid slid along a line fills itself at each end and the//! prism its outline, seen along the slide, sweeps between them. Seen along z, the torus (axis//! along y, tube centres on a circle of radius 6, tube radius 2) covers the stadium of its tube's//! two meridian discs in the plane through its centre, at x = 11.5 ± 6, and the band of width 4//! between them. The wheel at each end, centred at z = −9 and z = 29, lies wholly below and above//! the rod, so the rod, the cylinder of radius 5 from z = 0 to z = 20, is cut by that prism alone,//! the stadium at z = −9 extruded 38 along +z.use brepkit_operations::extrude::extrude;
use brepkit_operations::primitives::make_cylinder;
use brepkit_topology::solid::SolidId;
use brepkit_topology::Topology;
usecrate::solids::sweep::stadium;
usecrate::solids::{cut, v};
usecrate::Refusal;
pubfnbuild(topo: &mutTopology) -> Result<SolidId, Refusal> {
let rod = make_cylinder(topo, 5.0, 20.0)?;
let outline = stadium(topo, 11.5, 0.0, -9.0, 6.0, 2.0)?;
let groove = extrude(topo, outline, v(0.0, 0.0, 1.0), 38.0)?;
Ok(cut(topo, rod, groove)?)
}
Time
16 ms; CPU time 21 ms; peak memory 26.3 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.
// A rod of radius 5 on the z axis from z = 0 to 20, grooved by a torus (axis parallel to y,// centre circle 6, tube 2) slid without turning along z from centre (11.5, 0, -9) to// (11.5, 0, 29).//// popkern has no sweep of a solid. Sliding fills the torus's hole (the slide, 38, is longer than// the hole is wide), so the torus sweeps what the solid of its outline does: the convex solid of// revolution about the torus's axis whose section is the tube's outer half-disc joined to the// axis. That solid slid along z is itself at each end of the slide and, between, its section// through the centre square to the slide (the stadium x = 11.5 ± 6 with half-discs of radius 2,// |y| <= 2) carried along the slide. At its ends the torus is wholly below the rod (its top at// z = -1) and wholly above it (its bottom at z = 21), so of everything it passes through only the// stadium extruded from z = -9 to 29 meets the rod.let m = model();
let rod = m.profile(xy()).circle(5.0).sketch("rod").extrude(blind(20.0));
let swept = m.tool(|m| m.profile(xy_at(-9.0))
.path(5.5, -2.0).line_to(17.5, -2.0).arc_to([19.5, 0.0], [17.5, 2.0])
.line_to(5.5, 2.0).arc_to([3.5, 0.0], [5.5, -2.0]).close()
.sketch("stadium").extrude(blind(38.0)));
rod = rod.subtract(swept, #{ label: "groove" });
m
Time
410 ms; CPU time 406 ms; peak memory 82.1 MB
Notes
wrong its STEP is no solid: face #34: a face whose loops bound no region of its surface
Workaround † no sweep of a solid
Data
No measures: it built no solid to measure.
STEP
B-rep advanced faces, each on a surface AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF
// The wheel's sweep follows by elementary geometry. Seen along z, edge on, the torus is a slot: the// disc of its tube's radius carried along its tube's centres, from x = 5.5 to 17.5. Sliding along// z from wholly below the rod to wholly above it, it passes through everything above or below that// slot, so the rod loses the prism on the slot: a through cut.ModelTorusSlidThroughRod {
units: mm
Profile rodSection = Circle2 { center: [0mm, 0mm]; radius: 5mm }
Profile wheelSeenEdgeOn = Slot2 { center: [11.5mm, 0mm]; length: 16mm; width: 4mm }
Compose rod {
Base stock { profile: rodSection; from: 0mm; to: 20mm; role: Stock }
RemoveOffset<Prism> groove { Target: rod; On: Top; Profile: wheelSeenEdgeOn; Termination: ThroughAll }
}
}
Time
13 ms; CPU time 12 ms; 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.
//! The rod of radius 5 about the z axis from z = 0 to z = 20, less everything a wheel passes//! through as it slides without turning along the z axis: a torus with its axis parallel to y,//! the circle through its tube's centres of radius 6 and its tube of radius 2, its centre moving//! from (11.5, 0, −9) to (11.5, 0, 29).//!//! Through the kernel's whole sweep of a solid (`sweep_solid`): the wheel, a solid of revolution//! about the line through (11.5, 0, −9) along y whose meridian is the circle of radius 2 about the//! point 6 from the axis, slid 38 up, and cut from the rod.usecrate::solids::p;
usecrate::solids::swept::{less_all, revolved_tool, slide_by, Piece};
usecrate::Refusal;
use brep_kernel::{make_cylinder_brep, sweep_solid, BrepSolid};
use std::f64::consts::{TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let (x, z) = (p(1.0, 0.0, 0.0), p(0.0, 0.0, 1.0));
let rod = make_cylinder_brep(p(0.0, 0.0, 0.0), z, 5.0, 20.0)?;
let wheel = revolved_tool(p(11.5, 0.0, -9.0), p(0.0, 1.0, 0.0), x, &[
Piece::Arc { centre: [6.0, 0.0], radius: 2.0, start: 0.0, end: TAU },
]);
less_all(rod, vec![sweep_solid(&wheel, &slide_by(p(0.0, 0.0, 38.0)))?])
}
Time
128 ms; CPU time 127 ms; peak memory 19.4 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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to 20, grooved by a torus (axis//! along y, tube centres on a circle of radius 6 about (11.5, 0, z), tube radius 2) slid along z//! from its centre at z = −9, wholly below the rod, to z = 29, wholly above it.//!//! geop sweeps a profile, not a solid, so what the torus passes through is built from what it is.//! Sliding along z, it fills at each height everything that some height of it covers: wherever//! all of it has passed (from z = −1, 8 above its start, to z = 21, 8 below its end, which takes//! in the rod), that is its shadow along z, the slot between the circles of radius 2 about//! (5.5, 0) and (17.5, 0) — its tube's sections in its mid-plane — and the lines y = ±2 tangent to//! both. So the slot, sketched on a plane at z = −1 and extruded 22, to z = 21, is cut from the//! rod.usecrate::shared::paths::{offset_plane, slot};
usecrate::shared::{Drawing, extrude, sketch, xy};
usecrate::{Bench, Refusal};
use geop_core_math::primitives::FrameAxis;
use geop_ops_model::Combine;
pubfnbuild(b: &mutBench) -> Result<(), Refusal> {
letmut end = Drawing::new();
end.circle([0.0, 0.0], 5.0);
sketch(b, "end", xy(), end)?;
extrude(b, "rod", "end", 20.0, Combine::NewBody)?;
let below = offset_plane(b, "below", FrameAxis::Z, -1.0)?;
sketch(b, "shadow", below, slot(0.0, 2.0))?;
let rod = b.solid()?;
extrude(b, "groove", "shadow", 22.0, Combine::cut(rod))
}
Time
6.7 ms; CPU time 10 ms; peak memory 10.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.
//! A rod, the cylinder of radius 5 about the z axis from z = 0 to z = 20, grooved by a wheel slid//! past it: the torus of radii 6 and 2, its axis parallel to y, slid without turning from center//! (11.5, 0, −9) up to (11.5, 0, 29), cut from the rod.//!//! The wheel is cadrs's torus primitive; its slide is cadrs's sweep of a solid//! (`Kernel::cut_swept`, one slide of 38 up the z axis), cut from the rod.usecrate::bench::{p3, torus, v3};
usecrate::shared::swept::{cut_swept, rod, slide};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let body = rod(k)?;
let wheel = torus(k, p3(11.5, 0.0, -9.0), v3(0.0, 1.0, 0.0), 6.0, 2.0)?;
cut_swept(k, body, wheel, &slide(v3(0.0, 0.0, 38.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.
Time
7.4 ms; CPU time 6.9 ms; peak memory 8.6 MB
Notes
pass Its volume and area are the expected ones, and its mesh is closed.
Workaround † its sweep of a solid declines it
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.
//! The rod of radius 5 about the z axis from z = 0 to z = 20 less everything a wheel passes//! through as it slides along z from center (11.5, 0, −9) to (11.5, 0, 29): the torus with its//! axis along y, its tube's centers 6 from it and its tube of radius 2.//!//! springrep's sweep of a solid declines this one (it leaves edges unpaired). The torus is//! everything within 2 of its tube's center circle, and the slide, longer than the hole is wide,//! carries that circle over a stadium: so the sweep is everything within 2 of the stadium, its//! middle the stadium's section square to the slide carried along, and its ends half the ring with//! its hole filled (`shared::swept::slid_ring`).use springrep::boolean::difference;
use springrep::math::Vec3;
use springrep::topo::Brep;
usecrate::shared::e;
usecrate::shared::swept::{rod, slid_ring, v3};
pubfnbuild() -> Result<Brep, String> {
let groove = slid_ring(v3(11.5, 0.0, -9.0), Vec3::Y, Vec3::Z, 6.0, 2.0, 38.0, "wheel")?;
difference(&rod()?, &groove).map_err(e)
}
Time
105 ms; CPU time 128 ms; peak memory 30.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
1493.754605
1493.754573
2.2e-08
area
794.3607232
794.3608989
2.2e-07
agrees with
no other kernel
mesh
10594 triangles, closed
centre of gravity
(-0.2225, 2.65262e-16, 10) its STEP's solid
inertia
about it, of unit density: Ixx 59554.6; Iyy 58090.8; Izz 18061.8; Ixy 9.82246e-13; Iyz -1.29027e-15; Izx -6.18063e-13
// A rod grooved by a wheel slid along it. The rod is the cylinder of radius 5 about z from z = 0// to 20. The wheel is a torus centred at (11.5, 0, -9), its axis along y, its tube (radius 2) 6// from that axis: the tube's circle drawn in the plane through the axis and x, 5.5 out from z, and// turned about the axis. It slides 38 up z, and the kernel's sweep of it is cut from the rod.unit mm
use std
use std.solids (cut)
use std.place (coords, on_u)
use std.motion (slides)
in std.top {
private o := point
fix((0, 0)) o
private rod_rim := circle(center: o) hint(r: 5)
radius(5mm) rod_rim
}
part := solid(std.solids.Prism(face(rod_rim), from: 0mm, to: 20mm))
// the wheel, drawn in the level plane through its axis, below the rodprivate across := axis
fix(dir == (1, 0, 0)) across
private along := axis
fix(dir == (0, 1, 0)) along
bench := plane(u: across, v: along)
fix(origin == (0, 0, -9)) bench
in bench {
private a0 := point
private a1 := point
a0 coords(du: 11.5mm, dv: -1mm) bench
a1 coords(du: 11.5mm, dv: 1mm) bench
private wheel_axis := line(a0, a1)
private tc := point
tc on_u(d: 5.5mm) bench
private tube := circle(center: tc) hint(r: 2)
radius(2mm) tube
}
construction wheel := solid(std.solids.Revolution(face(tube), about: wheel_axis))
// the slide up z, 38 over the roll's one turn, from wholly below the rod to wholly above it
feed := frame
feed slides(38mm) std.z
construction groove := solid({ p | some t in (0deg, 360deg): p in wheel at(under: feed) t })
groove cut part
anvilcad left no solid to show.
Time
41 ms; CPU time 40 ms; peak memory 5.3 MB
Notes
refused boolean operation failed: face split did not close
//! A rod of radius 5 on the z axis from z = 0 to 20 grooved by a wheel, a torus whose axis runs along y through (11.5, 0, −9) (middle circle 6, tube 2), slid along z past it, from//! below the rod to above it.use anvil_brep::{Solid, extrude};
usecrate::shared::{cylinder, e, frame, region, rod, stadium, subtract, torus, unite_all};
/// What a torus whose axis runs along y through (11.5, `y`, −9) (middle circle 6, tube `r`)/// fills as it slides 38 along z: the tube of radius `r` about the stadium its middle circle/// sweeps (its slab, the torus at each end, and a rod along each straight side).fnslid(y: f64, r: f64) -> Result<Solid, String> {
// anvil-brep has no sweep of a solid; a torus slid in its own plane is that tubelet plane = frame([0., y, 0.], [0., 1., 0.], [1., 0., 0.])?;
// in the plane y = const, its sketch x along world x and its sketch y along world −zlet stadium = region(&[stadium((11.5, -29.), (11.5, 9.), 6.)])?;
let slab = extrude::extrude(&plane, &stadium, -r, r).map_err(e)?;
let wheel = |z: f64| torus(&frame([11.5, y, z], [0., 1., 0.], [1., 0., 0.])?, 6., r);
// each joined to what is built so far, which it overlapslet pieces = [wheel(-9.), wheel(29.), rod([5.5, y, -9.], [5.5, y, 29.], r), rod([17.5, y, -9.], [17.5, y, 29.], r)];
unite_all(slab, pieces)
}
pubfnbuild() -> Result<Solid, String> {
let rod_ = cylinder(&anvil_brep::Frame::world(), 5., 0., 20.)?;
subtract(&rod_, &slid(0., 2.)?)
}