Skip to main content

Crate brep_cam

Crate brep_cam 

Source
Expand description

CAM toolpath engine for the BREP kernel: contracts and geometric core.

This crate is pure Rust and builds for native targets and for wasm32-unknown-unknown. Algorithms work in MACHINE coordinates with the cutter axis along +Z; the setup’s rigid transform is the single place model coordinates become machine coordinates. Every strategy emits the same typed motion stream (model::Toolpath) that preview, simulation and the post-processors read, and the same inputs always produce a byte-identical stream.

Module map:

  • model: setups, machines, tools, operations, targets, toolpaths and reports.
  • numeric: the tolerance object.
  • mesh: the immutable triangle snapshot with body/face identity.
  • index: broad-phase triangle queries.
  • cutter: validated cutter profiles.
  • cancel: cancellation and progress at bounded work chunks.
  • stock: the setup’s stock resolved into machine coordinates.
  • stock_sim: the Z-dexel stock and exact 3-axis material removal.
  • collision: shank/holder/rapid collision checks during simulation.
  • verify: the stock-versus-part deviation map.
  • cycle_time: machining time estimates from the motion stream.
  • error: the crate error type.
  • kernel_adapter (feature kernel): BREP bodies to mesh snapshots, the only kernel dependency.

Re-exports§

pub use collision::simulate_checked;
pub use collision::simulate_checked_on_machine;
pub use collision::CheckedSimulation;
pub use collision::Collision;
pub use collision::CollisionAgainst;
pub use collision::CollisionOptions;
pub use collision::CollisionPart;
pub use cancel::CancelToken;
pub use cancel::Cancelled;
pub use cancel::NullSink;
pub use cancel::Progress;
pub use cancel::ProgressSink;
pub use cancel::RecordingSink;
pub use cancel::Runner;
pub use cancel::WorkBudget;
pub use cutter::BallConeCutter;
pub use cutter::BallCutter;
pub use cutter::BullCutter;
pub use cutter::ConeCutter;
pub use cutter::Cutter;
pub use cutter::CutterError;
pub use cutter::CutterKind;
pub use cutter::CutterProfile;
pub use cutter::FlatCutter;
pub use cutter::ProfilePoint;
pub use cutter::ProfileSegment;
pub use cutter::SegmentKind;
pub use cutter::Shank;
pub use cutter::ToolMesh;
pub use cutter::ToolMeshGroup;
pub use cutter::ToolPart;
pub use cutter::ToolProfile;
pub use cycle_time::estimate_cycle_time;
pub use cycle_time::CycleTime;
pub use cycle_time::MotionTime;
pub use error::CamError;
pub use index::AnyIndex;
pub use index::BruteForceIndex;
pub use index::IndexStats;
pub use index::ProjectionMode;
pub use index::TreeIndex;
pub use index::TreeOptions;
pub use index::TriangleIndex;
pub use mesh::to_machine;
pub use mesh::FaceSource;
pub use mesh::MeshBuildReport;
pub use mesh::MeshBuilder;
pub use mesh::MeshError;
pub use mesh::MeshSnapshot;
pub use mesh::Triangle;
pub use mesh::TriangleSource;
pub use numeric::NumericError;
pub use numeric::Tolerance;
pub use stock::resolve_stock;
pub use stock::ResolvedStock;
pub use stock::StockBox;
pub use stock::StockCylinder;
pub use stock::StockError;
pub use stock_sim::mesh::stock_mesh;
pub use stock_sim::mesh::stock_mesh_region;
pub use stock_sim::mesh::touched_region;
pub use stock_sim::mesh::StockMesh;
pub use stock_sim::remaining::remaining_stock_mesh;
pub use stock_sim::remaining::remaining_stock_mesh_region;
pub use stock_sim::remaining::RemainingStockMesh;
pub use stock_sim::removal::RemovalOptions;
pub use stock_sim::removal::SimulationReport;
pub use stock_sim::carry::carry_from_setup;
pub use stock_sim::carry::carry_stock;
pub use stock_sim::carry::CarriedStock;
pub use stock_sim::envelope::StockEnvelope;
pub use stock_sim::job::job_dexel_options;
pub use stock_sim::job::job_stock;
pub use stock_sim::job::unavailable_warning;
pub use stock_sim::job::uses_pre_op_stock;
pub use stock_sim::job::JobStock;
pub use stock_sim::job::JobStockResult;
pub use stock_sim::job::SetupHistory;
pub use stock_sim::job::SetupStart;
pub use stock_sim::preop::PlannedOp;
pub use stock_sim::preop::PreOpStockCache;
pub use stock_sim::preop::PreOpStockError;
pub use stock_sim::preop::PreOperationStock;
pub use stock_sim::Column;
pub use stock_sim::DexelGrid;
pub use stock_sim::DexelOptions;
pub use stock_sim::StockSimError;
pub use verify::deviation_map;
pub use verify::DeviationClass;
pub use verify::DeviationMap;
pub use verify::DeviationOptions;
pub use verify::FaceDeviation;
pub use model::*;

Modules§

adaptive
Adaptive (constant-engagement) clearing, 3D pocket clearing and rest roughing (lane C6). Everything here works on the planar engine’s exact regions (crate::planar): the material left at a Z level is a region, the tool-centre feasible set is a region, and the radial engagement of the tool at a position is the exact angular measure of the tool circle inside the remaining material (engagement).
adaptive2d
2D adaptive clearing (lane C6 row 2): constant-engagement roughing of planar regions with islands, in depth levels. Each region’s material is the region itself (or what the simulated stock still holds in it); the tool-centre feasible set is the region eroded by the radius and the allowances; predrilled holes (internal circles of the input at least the tool’s size) are the entries, else the solver seeds a helix at the deepest point. The engagement never exceeds arccos(1 - load / r) except where reported.
adaptive3d
3D adaptive clearing (lane C6 row 3): constant-engagement roughing of a part from its stock, level by level (depth levels, flat-area levels, fine step-downs above flats). Per level the material is the stock slice minus the part shadow and its allowance (or what the simulated stock still holds for rest machining), the feasible set the stock grown by the load minus the shadow grown by the radius and allowances; the solver starts in the air around the stock and seeds helices in closed pockets. Every pass is certified against the full protected mesh.
arcfit
Arc fitting (lane C4, row 2): replaces runs of straight cut chords with G2/G3 arcs, planar or helical, in the XY, XZ or YZ plane.
autoprogram
Automatic programming (lane C13 rows 3 and 4): recognised features -> a setup’s ordered operations through the technology table, tools from the library, feeds from lane C12, generation through the existing strategies, program assembly, and the report of what was recognised, programmed and skipped.
bore
Bore (lane C5 row 7): helical milling of a hole or boss wall. The tool centre runs on a circle of radius hole - cutter - radial stock (hole) or boss + cutter + radial stock (boss), descending pitch per turn as exact helical arcs, with a full circle at the bottom when a finish pass is asked for; a zero pitch cuts a full circle at every depth level instead. Climb: counter-clockwise inside a hole, clockwise around a boss. Every helix chord is certified against the full protected mesh.
cancel
Cancellation and progress at bounded work chunks.
chamfer2d
2D chamfer (lane C5 row 6): a chamfer mill or V-bit runs along the selected top edges with its tip width + tip_offset below the edge and its axis offset from the edge by tip_offset * tan(half angle), so the cone’s flank cuts a chamfer of the given width (for a 45-degree cutter the legs are equal). The chamfer removes model material by design, so only fixtures, protected bodies and avoid faces are gouge-checked.
circular
Circular (lane C5 row 7): concentric circular passes clearing a hole (inside out, down to a centre circle no larger than the cutter radius so the centre is covered) or the ring around a boss out to the given outer radius (outside in), at every depth level. Passes go through the linker (helix/ramp entry, proven links) and the arc fitter refits the circles.
collision
Collision checks during simulation: shank and holder against stock and protected bodies, and any non-cutting move (rapid, link, retract) that passes through material.
contour2d
2D contour (lane C5 row 5): the cutter follows closed or open chains on the outside or inside, with radial roughing passes, repeated finishing passes, stock to leave, holding tabs and depth levels. Corners are rolled (the exact offset’s round joins). Leads and ramps come from the linker.
cutter
Cutter profiles: the rotationally symmetric shape of the tool below the shank, as the drop-cutter, push-cutter, preview and simulation see it.
cycle_time
Cycle-time estimate from the motion stream.
dispatch
ONE entry point over every strategy: the generator the application’s worker calls per operation, without knowing which lane wrote the strategy or what inputs it takes.
drill
Hole-cycle expansion. A caller chooses canned OR expanded output; never append both to a machine program. Coordinates are machine-space tool tips.
drop
Deterministic vertical cutter projection in machine coordinates.
engrave
Engrave and V-carve (lane C5 row 6). Engraving runs the tool centre along chains in depth levels. V-carving fills closed regions with a V-bit whose depth follows the local width: at depth h the bit of half angle a is h tan a wide, so the region offset inward by h tan a at machine Z top - h is the pass whose flank touches the outline; the levels descend by the step-down until the offset empties (or the bottom is reached), which carves the region without a medial axis. Both cut into the model by design and are gouge-checked against fixtures, protected bodies and avoid faces only.
error
The crate-wide error type. Generation-stopping failures are errors; a recoverable degradation is a warning on the operation report instead.
face
Facing (lane C5 row 3): parallel passes over the stock top down to the finished face in depth levels. The pass area is the selected faces’ outlines (or the stock outline) grown by the cutter radius plus the pass extension, so the cutter fully clears every edge; passes are zig-zag or one-way at the pass angle. Every pass is certified against the full protected mesh before linking.
features
2.5D feature recognition (lane C13 row 1).
feeds
Original starting values and metric cutting formulas; see the C12 design record for provenance, units and limitations. Not a vendor cutting database.
filter
Cutter-location line filter (lane C4, row 1).
flow
Iso-parametric finishing. Cross-parameter distances are measured on the surface, using the maximum metric across each pass. On a varying metric surface the requested stepover is an upper bound, not a planar spacing.
geom
Geometry shared by CAM algorithms, independent of the optional kernel adapter.
holes
Hole recognition, grouping, and operation suggestions in machine coordinates.
index
Broad-phase triangle queries.
kinematics
Machine kinematics (lane C10, row 1): forward and inverse kinematics of 3-, 4- and 5-axis mills from the shared Machine definition.
library
Ordered, model-backed tool libraries. No machining profile is invented here.
link
Linking (lane C4, row 3): the operation-level entry point every strategy uses to turn its cut passes into a complete, safe motion stream.
mesh
The immutable triangle snapshot every CAM algorithm queries.
model
The shared CAM data model: everything the document persists and every strategy reads or writes. One owner (lane C0); field additions arrive as hunks through the integrator.
morph
Morph between two boundary polylines with normalized arc-length pairing. The caller supplies consistently oriented curves. Every intermediate curve is dropped onto the CL surface; surface bridge lengths determine spacing.
morphed_spiral
Continuous polygon-to-centre spiral for a single convex contained region.
multiaxis
Multi-axis machining (lane C10): the 3+2 indexed wrapper, contact in the tool frame, and collision avoidance by tilting. Strategies that emit simultaneous multi-axis motion live in strategy/{rotary, swarf, multiaxis_contour}.rs.
multiaxis_contour
Multi-axis contour (lane C10, row 4; spec section 7): the tool tip follows the containment curves projected onto the drive faces with the axis derived from the surface normal, lead (about the binormal, forward positive) and tilt (about the tangent, left positive), smoothed so the axis turns at most 5° per sample, then the cutter-location point is built from the contact point for the cutter’s corner radius and every point is certified: cutting part by the tool-frame drop, shank and holder by tilting (row 5). A curve sample with no drive triangle under it ends the pass and is reported as an empty region. Heights are distances along the tool axis (clearance for rapids).
multiaxis_finish
Multi-axis finishing (lane C10b, rows 1-3): any 3-axis finishing toolpath (parallel, scallop, contour, flow, …) re-run with a per-CL tool axis.
numeric
The single numeric policy every CAM algorithm reads.
parallel
Parallel finishing over explicit containment loops or selected-face projection. Source passes are clipped before projection; every cut chord is certified against the complete protected mesh. Unproven links use full clearance.
pattern
Derived operation-pattern expansion and manual NC entries. Shared persisted parameters live in model; source paths are never mutated.
pencil
Pencil traces at concave mesh creases with two finite ball/facet contacts. Fresh offset-plane intersection; no external CAM implementation is used.
planar
The 2D geometry engine (lane C5): regions bounded by lines and EXACT arcs, robust booleans and offsets, point containment and distances.
pocket2d
2D pocket (lane C5 row 4): contour-parallel clearing of planar regions with islands, inside out, in depth levels, with a wall finishing pass and radial/axial stock to leave. Offsets are exact (arcs preserved) and the stepover is capped at the cutter radius so the core of every level is covered. Entry (plunge, helix, ramp) and links come from the linker.
pocket3d
3D pocket clearing (lane C6 row 4): the classic contour-parallel roughing of a part from its stock, level by level. Every level’s tool-centre feasible set (stock slice grown by the stepover, minus the part shadow grown by the radius and allowances) is eroded by the stepover until it vanishes; the loops are cut outside in where a shell starts in the air around the stock, inside out (an entry at the innermost loop) where it is a closed pocket. Each pass is certified against the full protected mesh; rest machining takes the material from the simulated dexel stock.
polish
Optional feed optimisation and certified smoothing of linked toolpaths.
post
Post-processing (lane C4, rows 5 and 6): posts are JavaScript files run on the shared Boa interpreter (BREP_script_core, the same engine the plugin host and the app’s scripts use), with the host prelude in host.js defining the post API. A post calls post.define({...}) once with its identity, properties, capabilities and callbacks (onOpen, onSection, onRapid, onLinear, onCircular, onCycle, onDwell, onToolChange, onSpindle, onCoolant, onComment, onSectionEnd, onClose); the host walks the Program stream section by section and returns the text. Arcs a post cannot take (plane, helix, sweep) are split or linearized by the host within a declared tolerance; cycles a post does not list are expanded into rapids, feeds and dwells.
probe
Probe planning on picked geometry. Output stays local until fully checked.
probe_geometry
Expanded in-process inspection of picked nominal face points.
probe_wcs
Expanded WCS probe cycles; controller arithmetic belongs to the post.
program
Program assembly (lane C4, row 4): one NC program from ordered operations across setups.
project
Project machine-XY curves onto the complete protected mesh.
push
Constant-Z cutter sweep against triangle surfaces. Intervals are normalized along a finite fiber. The full lower profile and the finite shank participate. Numerical solves are bounded and deterministic; no elapsed-time budgets.
radial
Radial finishing: deterministic spoke paths, clipped and fully protected.
rest_finish
Reference-ball accessibility rest finishing. A surface point and its facet normal define the unique tangent ball center. If dropping that center raises the reference tool, the point is unreachable by that ball. The current ball must reach it. Stock mode instead uses residual material at dexel centres.
rest_rough
Rest roughing (lane C6 row 5): contour-parallel clearing restricted to the material a previous operation left, taken from the simulated dexel stock (RestSource::Stock) or from what a larger reference tool could not reach (RestSource::ReferenceTool). Per level the current tool’s feasible set is narrowed to the positions whose tool meets rest material, so the small tool only runs where the big one could not; every pass is certified.
rotary
Rotary (4th-axis) strategies (lane C10, row 3; spec section 6).
scallop
Constant CL-surface stepover / prescribed cusp for planar, spherical and horizontal cylindrical patches, with CL-grid distance fronts for freeform constant surface stepover. Cusp control requires verified analytic curvature.
slot
Slot (lane C5 row 6): the cutter follows the slot centre line when the slot is the cutter’s width, else clears the slot’s capsule outline (centre line grown by half the width) like a pocket, in depth levels.
spiral
Archimedean spiral with radial pitch in machine XY.
stock
Stock resolved into MACHINE coordinates for one setup: the shapes the material-removal simulation (lane C7) starts from. No simulation here.
stock_sim
Stock model for material-removal simulation: a Z-dexel grid.
strategy_linking
One operation-to-linker adapter for all 3D finishing strategies. Relinking preserves the certified cutting polyline. Filtering and arc fitting remain explicit subsequent operations, since they change its points.
swarf
5-axis swarf (lane C10, row 4; spec section 7): the side of the tool along the rulings of the selected wall faces.
template
Saved shared-model operations with explicit setup/tool/target rebinding.
thread_mill
Thread milling (lane C5 row 7): helical passes of a thread mill along a hole (internal) or boss (external). The tool centre radius is the major radius minus the mill radius (internal) or plus it (external), approached in passes radial steps over the thread depth (0.6134 x pitch, ISO 60 degree profile). A multi-point mill (cutting length at least the thread length) cuts one turn plus a small overlap; a single-point mill runs the whole length one pitch per turn. Climb: counter-clockwise inside, clockwise outside; the helix hand decides whether that climbs up or down (a right-hand helix rises counter-clockwise). The thread cuts into the wall by design, so fixtures, protected bodies and avoid faces are the gouge check; the floor at the bottom is still checked.
trace
Trace (lane C5 row 6): the tool centre follows a chain, or runs tangent to it on its left or right, in depth levels. A trace cuts along the selected curve by design, so it is certified against fixtures, protected bodies and avoid faces only; the target body itself is not gouge-checked and the report says so.
turning
Turning geometry in machine XZ: X is always a physical radius internally. Diameter programming is a post conversion, never a geometry scale factor.
verify
Stock-versus-part comparison: the deviation map.
waterline
Uniform and adaptive constant-Z fiber sampling and boundary weave.