Skip to main content

Crate ferrocad_geom

Crate ferrocad_geom 

Source
Expand description

§FerroCAD geometry seam (ferrocad_geom)

The kernel-independent vocabulary for geometry, so the document, persistence, expression and recompute layers can be written and tested now, without a geometry kernel, and gain one later without touching them.

It provides four things:

  • Shape — an opaque, cheap-to-clone handle to a kernel shape. The kernel owns the data; Rust owns the handle.
  • History, ElementRef and ElementMap — what an operation did, in the kernel’s own terms, and the stable-name registry derived from it. These are re-exports of the payload-generic vocabulary in ferrocad_lineage, specialised to Shape.
  • Lineage, ReverseMap, MapVersion and NamePolicy — the naming layer: provenance accumulated over successive histories, its inverse view, and the versioned rules that turn elements into names. Lineage is specialised to Shape; the others carry no payload and are re-exported as themselves.
  • ElementId, OperandId and Provenance — the identity an operation reports for its inputs (operand, kind and 1-based ordinal), independent of the positional name it also reports.
  • Tessellation, ElementKind and SelectionRef — the display mesh with per-primitive sub-element ids, and the neutral vocabulary a viewport or a workbench needs to turn a pick into a topology reference.
  • tangent_chain — the smooth edge chain a fillet or chamfer applies to.
  • GeometryBackend — the trait a kernel implements (OCCT, or NullBackend).

This crate depends on ferrocad_types for values such as Placement, on ferrocad_curves for edge curves, and on ferrocad_lineage for the provenance vocabulary, and on nothing else. It is the boundary OCCT must sit behind: no crate below the application depends on the kernel, and ferrocad_core stays a leaf (see docs/architecture/occt-integration.md).

§Example

use ferrocad_geom::{GeometryBackend, NullBackend};

let backend = NullBackend;
let a = backend.make_box(10.0, 10.0, 10.0).unwrap();
let b = backend.make_box(10.0, 10.0, 10.0).unwrap();
let result = backend.fuse(&a, &b).unwrap();
assert!(result.history.is_empty()); // the null backend invents no lineage

Structs§

Capabilities
The operations a backend supports.
ElementId
A kernel-independent identity for one sub-element of an operand.
MapVersion
The naming scheme a Lineage was folded under.
MassProperties
A geometry kernel.
NullBackend
A geometry kernel that produces placeholder shapes and empty History.
NullShape
A placeholder shape produced by NullBackend: enough to type-check and to assert on in tests, with no kernel behind it.
OpResult
The output of a shape operation: the resulting shape and what changed.
OperandId
Which input of an operation an element came from.
PrincipalProperties
The principal axes of a shape (Shape.PrincipalProperties).
Provenance
The identity behind one relation in a History.
ReverseMap
The element map read backwards: for each output name, the input names that produced it.
SelectionRef
One object plus the sub-elements selected on it.
Shape
An opaque handle to a kernel shape.
Tessellation
A display mesh with per-primitive sub-element ids.
TessellationOptions
How finely a kernel should tessellate a shape.
UnsupportedOperation
An operation this backend does not implement.

Enums§

Continuity
How smoothly two elements meet, as far as tangent propagation is concerned.
ElementKind
The kind of a topological element, in FreeCAD’s terms.
Relation
The relation an input element took part in.

Traits§

GeometryBackend
NamePolicy
How sub-elements are turned into stable names.

Functions§

tangent_chain
The edges tangent-continuous with seed, in the order the walk reaches them.
unsupported
The error a backend returns for an operation it does not implement.

Type Aliases§

ElementMap
The stable-name registry carried with a shape: name -> current sub-shape.
ElementRef
A reference to one sub-element of a shape (a face, an edge, …), by a stable name rather than a positional index.
GeomError
A boxed kernel error.
History
What one operation did to its inputs, in the kernel’s own terms.
Lineage
A shape’s accumulated provenance: the forward ElementMap, its reverse view, and the version of the naming rules that produced them.