Skip to main content
Boundary Representation (BREP) is the core data structure used in OpenGeometry to represent geometric entities. It describes 3D objects by defining their boundaries through vertices, edges, and faces.

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)
This representation is:
  • 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:
  1. Supports complex operations - Boolean operations, offsetting, and extrusion work naturally on boundaries
  2. Maintains precision - No approximation errors from voxelization or tessellation
  3. Industry standard - Compatible with CAD file formats like STEP, IGES, and Parasolid
  4. 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 in main/opengeometry/src/brep/vertex.rs, a vertex represents a point in 3D space and may reference an outgoing half-edge for topology traversal:
Example:

HalfEdge

Defined in main/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.
Key links:
  • twin points to the opposite half-edge (when the underlying edge is shared).
  • next and prev walk the boundary of a face loop (or a closed wire).

Edge

Defined in main/opengeometry/src/brep/edge.rs, an edge is an undirected edge that points at one or two half-edges:
The endpoints of an edge come from its referenced half-edge(s).

Face

Defined in main/opengeometry/src/brep/face.rs, a face is bounded by an outer loop and zero or more inner loops (holes):
Example:

Loop

Defined in main/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 in main/opengeometry/src/brep/wire.rs, a wire is an (optionally closed) polyline stored as a list of half-edges:

Shell

Defined in main/opengeometry/src/brep/shell.rs, a shell groups faces and can be marked as open or closed:

BREP Operations

The Brep 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):
If you need to build or modify topology, use 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 via serde:
This enables passing BREP data between Rust and JavaScript via WASM.

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, and prev links 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
Last modified on March 14, 2026