What is BREP?
BREP is a method of representing shapes by explicitly defining their boundaries. Instead of storing a solid as a filled volume, BREP stores:- Vertices - Points in 3D space
- Edges - Connectivity between vertices
- Faces - Surfaces bounded by edges (with explicit boundary loops)
- Exact - Preserves geometric precision
- Topology-aware - Maintains relationships between elements
- Efficient - Avoids redundant storage of shared vertices/edges
Why BREP?
OpenGeometry uses BREP because it:- Supports complex operations - Boolean operations, offsetting, and extrusion work naturally on boundaries
- Maintains precision - No approximation errors from voxelization or tessellation
- Industry standard - Compatible with CAD file formats like STEP, IGES, and Parasolid
- Flexible - Can represent wireframes, surfaces, and solids with the same structure
BREP Body Types
OpenGeometry can represent different types of geometric bodies:- Solid body - Has volume (e.g., cube, sphere)
- Shell body - Has surface but no volume (e.g., car body)
- Sheet body - Has 2D surface (e.g., flat plate)
- Wireframe body - Has only edges (e.g., line drawing)
- Point body - Single vertex in space
Data Structure
The BREP structure is defined in the Rust core (main/opengeometry/src/brep/mod.rs in this repo):
IDs (
u32) in the BREP are array indices. For example, brep.vertices[vertex_id as usize] is the
vertex with id vertex_id.Core Components
Vertex
Defined inmain/opengeometry/src/brep/vertex.rs, a vertex represents a point in 3D space and may
reference an outgoing half-edge for topology traversal:
HalfEdge
Defined inmain/opengeometry/src/brep/halfedge.rs, a half-edge is the directed topology primitive.
Half-edges are the basis for efficient adjacency queries, loop traversal, and hidden line removal.
twinpoints to the opposite half-edge (when the underlying edge is shared).nextandprevwalk the boundary of a face loop (or a closed wire).
Edge
Defined inmain/opengeometry/src/brep/edge.rs, an edge is an undirected edge that points at one
or two half-edges:
Face
Defined inmain/opengeometry/src/brep/face.rs, a face is bounded by an outer loop and zero or
more inner loops (holes):
Loop
Defined inmain/opengeometry/src/brep/loop.rs, a loop is a face boundary (outer boundary or an
inner hole) represented by a half-edge cycle:
Wire
Defined inmain/opengeometry/src/brep/wire.rs, a wire is an (optionally closed) polyline stored as
a list of half-edges:
Shell
Defined inmain/opengeometry/src/brep/shell.rs, a shell groups faces and can be marked as open or
closed:
BREP Operations
TheBrep struct provides several utility methods. Most callers should construct BReps through
BrepBuilder (see below) and treat the resulting BRep as an immutable kernel output.
Querying Geometry
Handling Holes
Faces can contain holes (inner loops):BrepBuilder (below). You can also clear all geometry
with brep.clear().
Example: building a BREP with BrepBuilder
BrepBuilder creates consistent half-edge/edge/loop links and validates topology on build():
Serialization
BREP structures are serializable viaserde:
Topology Validation
BrepBuilder::build() calls brep.validate_topology() before returning. Exporters can also validate
topology (depending on the export config).
Valid BREP structures should maintain:
- Vertex references - All referenced vertex IDs exist in vertex list
- Half-edge symmetry -
twin,next, andprevlinks are consistent - Manifold edges - An edge has at most two incident faces
References
The BREP implementation is based on:Next Steps
Architecture
Understand how BREP fits in the system architecture
Primitives and Shapes
Explore the available 2D and 3D primitives you can create

