Project 6: The B-Rep Topology Engine

Build a boundary representation (B-Rep) core that tracks faces, edges, and shells.


Project Overview

Attribute Value
Difficulty Level 3: Advanced
Time Estimate 2-3 weeks
Main Language C++
Alternative Languages Rust, C, Python
Knowledge Area Solid modeling topology
Tools Mesh viewer, validation scripts
Main Book “Geometric Modeling” by Michael E. Mortenson

What you’ll build: A B-Rep data model that represents solids as collections of faces, edges, and vertices with topological relationships.

Why it teaches computational geometry: B-Rep is the dominant CAD representation for solids. You must understand it to build real modeling operations.

Core challenges you’ll face:

  • Managing face-edge-vertex connectivity
  • Enforcing topological consistency
  • Representing shells and holes

Real World Outcome

You will model simple solids (like boxes and cylinders) and export their topology for inspection. The structure will be consistent and navigable.

Example Output:

$ ./brep_validate cube.brep
Faces: 6
Edges: 12
Vertices: 8
Shells: 1
Validation: OK

Verification steps:

  • Traverse around a face and around a vertex
  • Confirm each edge has two adjacent faces (for closed solids)

The Core Question You’re Answering

“How do CAD systems represent solids so that operations like booleans and fillets are possible?”

B-Rep turns geometry into a topological object you can operate on.


Concepts You Must Understand First

Stop and research these before coding:

  1. Boundary representation
    • Why is a solid represented by its boundary?
    • Book Reference: “Geometric Modeling” by Michael E. Mortenson, Ch. 10
  2. Euler operators
    • How do you maintain topological validity?
    • Book Reference: “Geometric Modeling” by Michael E. Mortenson, Ch. 12
  3. Manifold topology
    • What makes a solid watertight and valid?
    • Book Reference: “Geometric Modeling” by Michael E. Mortenson, Ch. 10

Questions to Guide Your Design

  1. Data relationships
    • How will you reference faces, edges, and vertices?
    • How will you handle boundary loops and holes?
  2. Validation rules
    • What invariants must always hold for a valid solid?
    • How will you detect broken topology?

Thinking Exercise

Euler Characteristic

For a cube, compute V - E + F. How does this relate to a valid closed surface?

Questions while working:

  • How does adding a hole change the characteristic?
  • Why do CAD kernels track Euler validity?

The Interview Questions They’ll Ask

Prepare to answer these:

  1. “What is B-Rep and why is it used?”
  2. “How do Euler operators maintain validity?”
  3. “What is a shell in B-Rep?”
  4. “How do you detect non-manifold edges?”
  5. “How does B-Rep differ from mesh representation?”

Hints in Layers

Hint 1: Starting Point Implement a minimal face-edge-vertex connectivity model.

Hint 2: Next Level Add loops to represent face boundaries and holes.

Hint 3: Technical Details Implement validation checks after every modification.

Hint 4: Tools/Debugging Export topology to a simple text format for inspection.


Books That Will Help

Topic Book Chapter
B-Rep fundamentals “Geometric Modeling” by Michael E. Mortenson Ch. 10
Euler operators “Geometric Modeling” by Michael E. Mortenson Ch. 12
Solid validity “Geometric Tools for Computer Graphics” by Schneider & Eberly Ch. 11

Implementation Hints

  • Start with a single solid (cube) built from primitives.
  • Keep topology independent of geometry for clarity.
  • Validate after each operation to catch errors early.

Learning Milestones

  1. First milestone: You can represent a simple closed solid.
  2. Second milestone: You can validate topology invariants.
  3. Final milestone: You can explain why B-Rep enables CAD operations.