To build any CAD product you need to start by defining the architecture of your application. It is now more and more accepted that a solid application can be based on the Application-Document-View architecture.
The OCAF (Open CASCADE Application Framework) module of Open CASCADE Technology, available in Open Source was designed to simplify the process of creation of this kind of architecture. In addition to architecture OCAF gives you basic functions to implement Undo/Redo, Copy/Paste and Storage/Restore mechanisms that could be very time-saving.
OCAF provides the following functionalities:
Ready to use framework for the application with the management of documents To understand the Application Framework some definitions are necessary:
- Attribute - an object which contains some elemental data;
- Label - a reference to some subset of attributes;
- Application - a class for managing of documents;
- Document - a container of the application data where data is a collection of OCAF attributes;
- View - a user-defined presentation of the whole or part of the contents of a document in a 3D viewer.
The only task the OCAF user has to do when building the application is to inherit from a basic Application class and define a couple of files to specify the process of storing documents. After that all features of OCAF are ready for use. A basic OCAF programming sample is available within Open CASCADE Technology, an advanced version can be requested within support services contracts.
Connection with the Visualization module of Open CASCADE Technology or any external Viewer Through specially defined attributes OCAF provides a direct connection with the Application Interactive Services module of Open CASCADE Technology. This allows the OCAF user to display attributes which contain topology and geometry and interactively work with their contents.
If you wish to connect application specific data with an external Viewer the pre-defined set of attributes can be easily extended by user defined attributes.
Topological Naming One of the most important benefits of OCAF is the Topological Naming mechanism. It allows the user to put shapes into a document and using the parametric approach to modify them. The Topological Naming keeps the modifications of shapes, which gives the possibility to track shapes and sub shapes during all their life cycle. Using selection tools the Topological Naming enables also an interactive modification of shapes stored in a document.
When it is used together with the OCAF Function mechanism, Topological Naming provides a framework for propagation of modifications thus giving the possibility to build complex parametric models.
Undo/Redo mechanism The OCAF user doesn't need to worry about implementation of any tool to manage this transaction mechanism as it is integrated in OCAF. All you need to do is manage the opening/committing of the transactions using the API provided by the OCAF Document. Of course, it is possible to abort a transaction or undo it after commitment. The number of possible Undo steps is limited only by available memory and can be set dynamically. After an Undo step it is possible to return to the previous state of the model which was before using the Undo command by calling the Redo method of the OCAF Document.
Persistence of documents When working with almost any kind of application you will need to store the current state of your work in some persistent storage so that you can return to it later. OCAF gives you such a possibility through a document's translation from transient state (that is stored in RAM) to persistent state and vice versa. The OCAF storage mechanism is plug-in based and supports document's versions. Thanks to its plug-in status, the storing tool can be extended very simply. OCAF gives the user the choice of either storing the persistent documents in an OS file system or in a database.
OCAF Persistence comes in several file formats - native ASCII (available in open source), as well as XML and Binary format for faster compact conversions and more compact files.
Ready-made set of standard attributes OCAF provides already defined sets of attributes which allow the user to store data most commonly used in CAD/CAM/CAE applications. These are digital or string data, BRep shapes, geometry, constraints between shapes and other data.
If you need to store some specific data the pre-defined set of attributes can be easily extended by user defined attributes. Often you can reach the same goal by a combination of several attributes provided by OCAF. As a matter of fact the second approach, a combination of standard OCAF attributes, is preferable as it implies no changes in a process of translation from transient to persistent documents and vice versa.