How FreeCAD Uses the OpenCASCADE Geometry Kernel

This article explores how FreeCAD integrates OpenCASCADE Technology (OCCT) as its foundational geometric modeling engine. It outlines how FreeCAD bridges its parametric interface with OCCT’s Boundary Representation (B-Rep) architecture, the way standard modeling operations and Workbenches communicate with the underlying C++ libraries, and how OCCT facilitates advanced CAD functionalities such as Boolean operations, feature generation, and standard file interoperability.

The Role of OpenCASCADE in FreeCAD

FreeCAD is an open-source parametric 3D modeler, but it does not calculate low-level 3D geometry from scratch. Instead, it relies on OpenCASCADE Technology (OCCT), a mature, industrial-grade C++ software development platform designed for 3D surface and solid modeling. In this architecture, FreeCAD serves as the high-level application layer—handling the user interface, document management, and parametric dependency graphs—while OCCT acts as the core geometric kernel executing the heavy mathematical computations.

Boundary Representation (B-Rep) Data Structures

At the heart of the FreeCAD-OCCT integration is Boundary Representation (B-Rep). Unlike polygonal mesh modelers that define shapes using flat triangles, OCCT represents 3D solids via their mathematical boundaries:

  • Geometric Entities: Infinite mathematical definitions like curves, lines, circles, B-splines, planes, cylinders, and NURBS surfaces (Geom_* classes in OCCT).
  • Topological Entities: Boundaries that limit the geometric entities to form finite shapes (TopoDS_* classes in OCCT). These range hierarchically from vertices, edges, and wires to faces, shells, solids, and compound solids.

When a user creates a shape in FreeCAD, the software instantiates an OCCT topological object. This ensures that curves remain mathematically exact rather than approximated, which is essential for precision engineering and manufacturing.

The Parametric Bridge: FreeCAD's Part Module

FreeCAD accesses OCCT primarily through its core Part workbench and the corresponding C++ and Python Part module. FreeCAD wraps OCCT’s C++ classes inside its own Python-accessible framework:

  1. Feature Trees: When a user defines a sketch and pads it, FreeCAD’s parametric engine evaluates the inputs and passes dimensions and profiles to OCCT’s modeling algorithms (such as BRepPrimAPI_MakePrism).
  2. Boolean and Modification Operations: Operations such as unions, cuts, intersections, fillets, and chamfers are delegated directly to OCCT algorithms (BRepAlgoAPI and BRepFilletAPI). OCCT computes the complex intersections of surfaces, trims them, and stitches the resulting topology together into a valid solid.
  3. Shape Caching: To maintain performance, FreeCAD caches the OCCT TopoDS_Shape objects. When a parameter changes, FreeCAD recalculates only the affected nodes in the dependency tree, calling OCCT to generate updated geometry only when strictly necessary.

Standard File Interoperability (STEP and IGES)

A critical advantage of utilizing OCCT is native support for industry-standard CAD exchange formats. FreeCAD uses OCCT's Data Exchange libraries to read and write formats such as STEP and IGES. These libraries translate the external geometric and topological data directly into OCCT B-Rep structures without intermediate approximations, ensuring high fidelity when moving models between FreeCAD and commercial CAD software.

Python Scripting and Low-Level Access

FreeCAD exposes the underlying OCCT capabilities directly to users through its Python API. By importing the Part module, users can bypass the graphical interface and directly generate OCCT primitives, compute edge intersections, analyze surface curvatures, and construct complex solids programmatically using OCCT's robust mathematical methods.