A curved block with a notch cut into it by a drum swung partway into it.
The block is a sector of a ring about the z axis: everything with distance from the z axis between 8 and 12, with z between −1 and 1, and with polar angle between 0° and 60° (measured from +x toward +y).
The drum is a solid cylinder of radius 1 about the vertical line through (10, 0), from z = −0.5 to z = 0.5, its ends flat.
It turns rigidly about the z axis, right-handed (from +x toward +y), from −140° to +30°: it starts clear of the block and stops halfway across it. Cut from the block everything the drum passes through.
The notch runs in from the block's flat side at 0°, between the cylinders of radii 9 and 11 about the z axis and the planes z = ±0.5, and ends in the half of the drum's side that leads where it stops.
expected
closed form
volume
71.73303226
80π/3 − (π r²/2 + (π/6)·2Dr)·1, r = 1, D = 10: each circle about the axis loses the angle from the block's edge to 30° past it and the drum's half-width there, and ∫2ρ a(ρ) dρ is the drum's section, πr²
area
177.362818
40π + 16 − 2 (the opening in the face at 0°) + floor and roof 2(π/2 + 10π/3) + the walls at radii 9 and 11 (π/6)(9 + 11)·1 + half the drum's side π = 52π + 14
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
45 ms; CPU time 101 ms; peak memory 15.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.
//! A ring sector (radii 8 to 12 about z, z from −1 to 1, polar angle 0° to 60°) notched by a drum,//! the cylinder of radius 1 about the vertical line through (10, 0) from z = −0.5 to 0.5, turned//! rigidly about z, right-handed, from −140° to +30°: it starts clear and stops halfway across.usecrate::sketch::polygon;
use cad_kernel::build::{disc, prism, revolve};
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::FRAC_PI_3;
constUP: V = [0., 0., 1.];
constDRUM_FOOT: V = [10., 0., -0.5];
constDRUM_RADIUS: f64 = 1.;
constDRUM_HEIGHT: f64 = 1.;
/// The turn's start and stop, in degrees.constFROM: f64 = -140.;
constTO: f64 = 30.;
/// How closely the drum is meshed for the sweep's membership reads: a five-hundredth of its radius.constBAR: f64 = 0.002;
/// The ring sector: its section in the half-plane at 0° turned 60° about z.fnsector() -> Result<Brep, String> {
let section = polygon(&[[8., 0., -1.], [12., 0., -1.], [12., 0., 1.], [8., 0., 1.]]);
revolve(§ion, [0.; 3], UP, FRAC_PI_3)
}
pubfnbuild() -> Result<Brep, String> {
let block = sector()?;
let drum = prism(&disc(DRUM_FOOT, UP, DRUM_RADIUS), 0., DRUM_HEIGHT)?;
// the turn about z: a screw that does not advance, a radian a radian of the rolllet path = Trajectory::Twist(Screw { origin: [0.; 3], axis: UP, ratio: 1., advance: 0. });
// the kernel's closed swept solid cut from the sector on one arrangement: a drum about an axis// along the turn's, its side's generators in the plane through both axes turned into// cylinders about z and its flat ends kept in their planeslet size = block.size().max(drum.size());
cut_from(&block, &drum, &path, [FROM.to_radians(), TO.to_radians()], BAR, tolerance(size))
.map_err(|why| format!("the drum's sweep not built: {why:?}"))
}
Time
634 ms; CPU time 633 ms; peak memory 367.2 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 drum swung partway into a curved block. A curved block with a notch cut into it by a drum
swung partway into it.
The block is a sector of a ring about the z axis: everything with distance from the z axis between
8 and 12, with z between −1 and 1, and with polar angle between 0° and 60° (measured from +x toward
+y).
The drum is a solid cylinder of radius 1 about the vertical line through (10, 0), from z = −0.5 to
z = 0.5, its ends flat.
It turns rigidly about the z axis, right-handed (from +x toward +y), from −140° to +30°: it starts
clear of the block and stops halfway across it. Cut from the block everything the drum passes
through.
The notch runs in from the block's flat side at 0°, between the cylinders of radii 9 and 11 about
the z axis and the planes z = ±0.5, and ends in the half of the drum's side that leads where it
stops."""fromOCP.BRepPrimAPIimportBRepPrimAPI_MakeCylinderfromOCP.gp import gp, gp_Ax2, gp_Pnt
from sweep import cut, plane, ring_sector, turn, turned
BLOCK = (8, 12, -1, 1, 0, 60) # radii, heights and polar anglesDRUM_AXIS = (10, 0) # the drum stands on the vertical line through this pointDRUM_RADIUS, DRUM_LOW, DRUM_HIGH = 1, -0.5, 0.5START, STOP = -140, 30# degrees about the z axisdefbuild():
drum = BRepPrimAPI_MakeCylinder(gp_Ax2(gp_Pnt(*DRUM_AXIS, DRUM_LOW), gp.DZ_s()), DRUM_RADIUS,
DRUM_HIGH - DRUM_LOW).Shape()
drum = turn(drum, gp.OZ_s(), START)
# The turn's axis and the drum's are parallel, so the plane through both is square to the# turn's velocity all along it: the drum's side meets the motion square-on, its normal along# the velocity's own line, nowhere but there, and the two lines where that plane cuts the# side are its contact. Its flat ends turn in their own planes. (Point (10, 0) turned with the# drum to where it starts.)
through_axes = turn(plane((0, 0, 0), (0, 1, 0)), gp.OZ_s(), START)
swept = turned(drum, gp.OZ_s(), STOP - START, [through_axes])
returncut(ring_sector(*BLOCK), swept)
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
14 ms; CPU time 13 ms; peak memory 10.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.
//! A curved block, the sector of the ring about the z axis between radii 8 and 12, z from −1 to 1//! and polar angle from 0° to 60°, notched by a drum swung partway into it: the solid cylinder of//! radius 1 about the vertical line through (10, 0), |z| ≤ 0.5, turned rigidly about the z axis//! from −140° to +30°. Everything the drum passes through, cut.//!//! The drum's sweep is kentron's sweep of a solid (`sweep::solid`, one turn), cut from the block.usecrate::bench::{frame, p};
usecrate::shared::swept::ring_sector;
use kentron::math::{Axis, Direction};
use kentron::primitives::Cylinder;
use kentron::sweep::{self, RigidMotion};
use kentron::topology::{Model, Shape};
pubfnbuild(m: &mutModel) -> kentron::Result<Shape> {
let block = ring_sector(m)?;
let drum = Cylinder::new(1.0, 1.0).with_frame(frame(p(10.0, 0.0, -0.5), Direction::Z)).build(m)?;
let turn = RigidMotion::Turn { axis: Axis::Z, from: (-140f64).to_radians(), to: 30f64.to_radians() };
let swept = sweep::solid(m, drum, &turn)?;
kentron::boolean::difference(m, block, 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.
Time
68 ms; CPU time 67 ms; peak memory 49.8 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 ring sector, everything between 8 and 12 from the z axis with |z| ≤ 1 and polar angle from//! 0° to 60°, notched by a drum, the solid cylinder of radius 1 about the vertical line through//! (10, 0) from z = −0.5 to 0.5, swung about the z axis from −140° to +30°.//!//! solidcraft-kernel has no sweep of a solid, so the swing is built by elementary geometry//! ([`swung_partway`]): the drum meets each circle about the z axis in one arc holding the//! circle's point at 0°, so its section by the half-plane at 0°, the rectangle 9 ≤ x ≤ 11,//! |z| ≤ 0.5, is its shadow, and what it sweeps is that rectangle revolved through the turn with//! the drum where it starts and where it stops. Where it starts it is clear of the block, and//! where it stops only its half ahead of the half-plane through its axis lies beyond the//! revolved rectangle.usecrate::solids::*;
use std::f64::consts::PI;
/// The block the swung tools notch: the rectangle 8 ≤ x ≤ 12, |z| ≤ 1 revolved from 0° to 60°.pubfnring_sector() -> R<Body> {
revolve_z(rect(8.0, -1.0, 12.0, 1.0), 60.0)
}
/// Where the swung tools start and stop, in degrees about the z axis.pubconstSTART: f64 = -140.0;
pubconstSTOP: f64 = 30.0;
/// `body` turned by `degrees` about the z axis, right-handed.pubfnturned(body: &Body, degrees: f64) -> R<Body> {
solidcraft_kernel::transform(body, Vec3::ZERO, Vec3::ZERO, Vec3::Z, degrees.to_radians())
}
/// The ring sector less what a tool passes through as it is swung about the z axis from/// [`START`] to [`STOP`], given as it is drawn, at 0°. A tool that meets each circle about the/// z axis in arcs whose gaps are narrower than the turn passes over, on each circle, everything/// from its first point where it starts to its last point where it stops. When every circle it/// meets holds a point of its section by the half-plane at 0° (`shadow`, in x and z), that is/// the section revolved through the turn, with the tool where it starts and where it stops,/// each beyond the section's two ends. Where it starts the tool is clear of the block; where it/// stops, `lead` is what of it lies ahead of the half-plane, drawn at 0° (`None`: nothing).pubfnswung_partway(shadow: Region2, lead: Option<Body>) -> R<Body> {
letmut swept = turned(&revolve_z(shadow, STOP - START)?, START)?;
ifletSome(lead) = lead {
swept = union(&swept, &turned(&lead, STOP)?)?;
}
cut(&ring_sector()?, &swept)
}
/// The half of a tool of revolution about the vertical line through (10, 0) ahead of the/// half-plane through its axis (towards +y, where it moves): `half`, its section in x and z on/// the axis's outer side, revolved half a turn about it. (The kernel turns a section on `xz`/// towards −y for a positive angle.)pubfnhalf_ahead(half: Region2) -> R<Body> {
one(solidcraft_kernel::revolve(&xz(), &[half], v2(10.0, 0.0), Vec2::Y, -PI)?)
}
pubfnbuild() -> R<Body> {
swung_partway(rect(9.0, -0.5, 11.0, 0.5), Some(half_ahead(rect(10.0, -0.5, 11.0, 0.5))?))
}
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
316 ms; CPU time 523 ms; peak memory 29.6 MB
Notes
refused FeatureFailed at drum_swung_partway_into_ring_sector.rhai:21:7: feature 'boolean-3' (boolean) failed: result validation failed: cellular result invalid: Half-edge HalfEdgeHandle(55v1) in loop LoopHandle(10v1) ends at VertexHandle(12v1) but its successor HalfEdgeHandle(40v1) starts at VertexHandle(19v1)
// A ring sector (8 to 12 from the z axis, |z| ≤ 1, 0° to 60°) less everything a drum (radius 1 about the vertical through (10, 0), |z| ≤ 0.5) passes through as it turns about z from -140° to 30°.//// A turn about the z axis sweeps the tool where it starts and where it stops and, between them, the// shadow of the tool on a half-plane through the axis (each point carried there round its circle// about the axis) revolved through the turn: here the tool is symmetric about its own plane through// the axis, so the shadow is its section in that plane.fnblock(m) {
m.profile(xz()).polygon([[8.0, -1.0], [12.0, -1.0], [12.0, 1.0], [8.0, 1.0]]).sketch("block")
.revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), blind(60.0))
}
fnswing(m, section, from, to) {
section.sketch("shadow").revolve(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), blind(to - from))
.rotate(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), from)
}
fnturned(body, angle) { body.rotate(axis_at([0.0, 0.0, 0.0], [0.0, 0.0, 1.0]), angle) }
fncutter(m) { m.cylinder(1.0, 1.0, #{ at: [10.0, 0.0, -0.5] }) }
let m = model();
let b = block(m);
b = b.subtract(m.tool(|m| turned(cutter(m), -140.0)));
b = b.subtract(m.tool(|m| swing(m, m.profile(xz()).polygon([[9.0, -0.5], [11.0, -0.5], [11.0, 0.5], [9.0, 0.5]]), -140.0, 30.0)));
b = b.subtract(m.tool(|m| turned(cutter(m), 30.0)));
m
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
19 ms; CPU time 18 ms; peak memory 18.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 ring sector notched by a drum swung partway into it.//!//! The kernel's sweep of a solid (`sweep_solid_within`, its planar motion of a prism, which//! includes the end positions exactly): the drum is the circle of radius 1 about (10, 0) from z =//! −0.5 to 0.5, a prism along the z axis, turned about the z axis from −140° to +30°. Asked for//! between 7.5 and 12.5 from the z axis, from z = −0.5 to 0.5 along it (a prism's sweep is asked//! for between its ends) and from −10° to 70°, which holds the notch; cut from the block, the//! rectangle 8 ≤ x ≤ 12, |z| ≤ 1 revolved from 0° to 60°.usecrate::solids::{p, polygon};
usecrate::Refusal;
use brep_kernel::{
boolean_operation_nary, revolve_profile_brep, sweep_solid_within, BooleanOperation, BrepSolid,
OutlinePiece, ScrewStep, SolidMotion, SweepClip, SweptTool,
};
#[allow(unused_imports)]use std::f64::consts::{PI, TAU};
pubfnbuild() -> Result<BrepSolid, Refusal> {
let z = p(0.0, 0.0, 1.0);
let section = [p(8.0, 0.0, -1.0), p(12.0, 0.0, -1.0), p(12.0, 0.0, 1.0), p(8.0, 0.0, 1.0)];
let block = revolve_profile_brep(&polygon(§ion)?, p(0.0, 0.0, 0.0), z, 60f64.to_radians())?;
let tool = SweptTool::Prism {
origin: p(0.0, 0.0, 0.0),
normal: z,
x_axis: p(1.0, 0.0, 0.0),
outline: vec![OutlinePiece::Arc { centre: [10.0, 0.0], radius: 1.0, start: 0.0, end: TAU }],
from: -0.5,
to: 0.5,
};
let turn = SolidMotion {
steps: vec![ScrewStep { axis_origin: p(0.0, 0.0, 0.0), axis_direction: z, turn: 1.0, advance: 0.0 }],
from: (-140f64).to_radians(),
to: 30f64.to_radians(),
};
let around_notch = SweepClip {
axis_origin: p(0.0, 0.0, 0.0),
axis_direction: z,
reference: p(1.0, 0.0, 0.0),
radius: [7.5, 12.5],
axial: [-0.5, 0.5],
angle: Some([(-10f64).to_radians(), 70f64.to_radians()]),
};
letmut operands = vec![block];
operands.extend(sweep_solid_within(&tool, &turn, &around_notch)?);
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
8.2 ms; CPU time 12 ms; peak memory 10.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.
//! A curved block (the ring sector between radii 8 and 12, heights ±1, polar angles 0° to 60°)//! notched by a drum (radius 1 about the upright through (10, 0), from z = −0.5 to 0.5) turned//! about the z axis from −140° to +30°.//!//! The block is cadrs's cylindrical box; the drum a circle extruded. What the drum passes//! through is cadrs's sweep of a solid (one turn: the drum where it starts, with what its leading//! faces sweep), cut from the block.usecrate::bench::{cut, cylinder, p3, v3};
usecrate::shared::swept::{ring_sector, swung, z_axis};
usecrate::Refusal;
use cadrs_kernel::{BodyId, DefaultKernel};
pubfnbuild(k: &mutDefaultKernel) -> Result<BodyId, Refusal> {
let block = ring_sector(k, (8.0, 12.0), (-1.0, 1.0), (0.0, 60.0))?;
let drum = cylinder(k, p3(10.0, 0.0, -0.5), v3(0.0, 0.0, 1.0), 1.0, 1.0)?;
let swept = swung(k, drum, z_axis(), -140.0, 30.0)?;
cut(k, block, 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
10 ms; CPU time 9.9 ms; peak memory 8.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.
//! The ring sector (radii 8 to 12, heights −1 to 1, angles 0° to 60°) less everything the drum of//! radius 1 about the upright line through (10, 0), from z = −0.5 to 0.5, passes through as it//! turns about the z axis from −140° to 30°.use springrep::boolean::difference;
use springrep::primitive::cylinder;
use springrep::sweep::solid;
use springrep::topo::Brep;
usecrate::shared::swept::{deg, sector_block, turning};
usecrate::shared::{at, e};
pubfnbuild() -> Result<Brep, String> {
let drum = cylinder(&at([10.0, 0.0, -0.5]), 1.0, 1.0, "drum").map_err(e)?;
let notch = solid(&drum, &turning(deg(-140.0), deg(30.0)), "notch").map_err(e)?;
difference(§or_block()?, ¬ch).map_err(e)
}
Time
88 ms; CPU time 168 ms; peak memory 31.7 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 curved block, the ring sector between radii 8 and 12 about the z axis, z within 1, polar angle// from 0 to 60 degrees: its section in the front plane (x, z) turned 60 degrees about the z axis.// A drum, the cylinder of radius 1 about the upright line through (10, 0) from z = -0.5 to 0.5,// turned rigidly about the z axis from -140 to +30 degrees, and everything it passes through cut// from the block.unit mm
use std
use std.solids
use std.solids (cut)
use std.motion (turns)
in std.front {
a := point
b := point hint((12, -1))
c := point hint((12, 1))
d := point hint((8, 1))
meridian := horizontal line(a, b) -> vertical line(b, c) ->
horizontal line(c, d) -> vertical line(d, a) -> close
fix((8, -1)) a
a distance(4) b
b distance(2) c
}
part := solid(std.solids.Revolution(meridian, about: std.z, to: 60deg))
in std.top {
o := point
fix((10, 0)) o
rim := circle(center: o) hint(r: 1)
radius(1) rim
}
drum := solid(std.solids.Prism(face(rim), from: -0.5mm, to: 0.5mm))
swing := frame
swing turns(1) std.z
notch := solid({ p | some t in (-140deg, 30deg): p in drum at(under: swing) t })
notch cut part
anvilcad left no solid to show.
Time
6.9 ms; CPU time 6.6 ms; peak memory 5.1 MB
Notes
refused boolean operation failed: the result is not a closed solid (edge DVec3(9.526279441628825, 5.500000000000002, -0.5) -> DVec3(9.526279441628825, 5.500000000000002, 0.5) used 1/0 by ["s1f2~"])
//! The ring sector 8 ≤ ρ ≤ 12, |z| ≤ 1, 0° ≤ φ ≤ 60° less what a drum (radius 1 about the vertical through (10, 0), from z = −0.5 to 0.5) passes through, turned about//! the z axis from −140° to 30°.use anvil_brep::Solid;
usecrate::shared::{at, cut_all, cylinder, rect, swung, turn_z};
pubfnbuild() -> Result<Solid, String> {
let sector = swung(rect((8., -1.), (12., 1.)).segments, 0., 60.)?;
let tool = cylinder(&at([10., 0., 0.]), 1., -0.5, 0.5)?;
let fan = swung(rect((9., -0.5), (11., 0.5)).segments, -140., 170.)?;
// anvil-brep has no sweep of a solid. Turned about the z axis the tool fills the revolve of// what it covers in a half-plane through the axis, from 9 to 11 out within |z| ≤ 0.5, and itself where it starts and stopscut_all(sector, [Ok(fan), Ok(tool.transformed(&turn_z(-140.))), Ok(tool.transformed(&turn_z(30.)))])
}