Introduction to OCAF

What is OCAF and Why Might I Need It?

OCAF is the OpenCascade Application Framework. At it’s core, it provides the functionality to manage structured documents. The framework defines a document model but it’s up to the application to define the specific document structure (in the same way that xml defines a file format, but an application defines a specific xml schema). OCAF documents can be loaded from or saved to disk using a native format, or import/exported from a number of other formats.

Using OCAF you can:

  • Manage multiple documents and visualise document contents
  • store BRep Shapes, including their evolution (version control for Shapes), for undo/redo for example
  • define components and assemblies
  • define shape metadata like: colour, material, tolerancies, layers
  • define other metadata based on either existing standard types, or custom-defined types
  • import / export support for STEP and IGES, including layers, colours, materials and tolerances
  • define functions for reconstruction of parametric models

Basic OCAF Strucuture

OCAF documents are based on a hierarchy of labels (TDF.TDF_Label objects). At any one level in the tree, labels are identified by an index number. The series of index numbers from the root of the tree to a given label uniquely defines that label. The fully qualified label entry is writen as a colon-separated list of these integers e.g.

  • root label (0:)
    • label A (0:1)
      • label D (0:1:1)
      • label E (0:1:2)
    • label B (0:2)
    • label C (0:3)
      • label F (0:3:1)

Basic OCAF Use

Each OCAF app requires a single Application object.
Creating a new OCAF document

How is OCAF implemented in pythonOCC?

A recent developement of pythonOCC is the PAF framework, which implements Associativity, Parameters, Rules and Relations in a pythonic manner.